Skip to content

Commit

Permalink
build: fix arm64 cross-compilation
Browse files Browse the repository at this point in the history
Commit 938212f added -msign-return-address=all to _all_ cflags but that
is wrong when cross-compiling, it should only be added to the target's
cflags.

The flag being deprecated, it is also changed to
`-mbranch-protection=standard`.

Fixes: nodejs#42888
Co-Authored-By: Michaël Zasso <[email protected]>
  • Loading branch information
bnoordhuis and targos committed Dec 22, 2023
1 parent a81788c commit 39916bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 0 additions & 2 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1273,9 +1273,7 @@ def configure_node(o):

o['variables']['want_separate_host_toolset'] = int(cross_compiling)

# Enable branch protection for arm64
if target_arch == 'arm64':
o['cflags']+=['-msign-return-address=all']
o['variables']['arm_fpu'] = options.arm_fpu or 'neon'

if options.node_snapshot_main is not None:
Expand Down
3 changes: 3 additions & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@
},

'conditions': [
['target_arch=="arm64"', {
'cflags': ['-mbranch-protection=standard'], # Pointer authentication.
}],
['OS in "aix os400"', {
'ldflags': [
'-Wl,-bnoerrmsg',
Expand Down

0 comments on commit 39916bf

Please sign in to comment.