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 <targos@protonmail.com>
PR-URL: #51256
Fixes: nodejs/build#3319
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
targos authored and marco-ippolito committed May 2, 2024
1 parent c530520 commit 297368a
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 @@ -1280,9 +1280,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 @@ -464,6 +464,9 @@
},

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

0 comments on commit 297368a

Please sign in to comment.