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: #42888
Co-Authored-By: Michaël Zasso <[email protected]>
PR-URL: #51256
Fixes: nodejs/build#3319
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
targos authored Dec 27, 2023
1 parent c366422 commit c21b2be
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 @@ -471,6 +471,9 @@
},

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

0 comments on commit c21b2be

Please sign in to comment.