build: fix arm64 cross-compilation

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: https://github.com/nodejs/node/issues/42888
Co-Authored-By: Michaël Zasso <targos@protonmail.com>
PR-URL: https://github.com/nodejs/node/pull/51256
Fixes: https://github.com/nodejs/build/issues/3319
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Michaël Zasso 2023-12-27 07:19:24 +01:00 committed by GitHub
parent c3664227a8
commit c21b2bee72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -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:

View File

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