From e03ac83c19a15b62b5c3ef49f98ba91b1c7c3c6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Wed, 27 Dec 2023 07:19:24 +0100 Subject: [PATCH] build: fix arm64 cross-compilation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 PR-URL: https://github.com/nodejs/node/pull/51256 Fixes: https://github.com/nodejs/build/issues/3319 Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca --- configure.py | 2 -- node.gyp | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/configure.py b/configure.py index 84b016cd853080..5e014bf7a75e2a 100755 --- a/configure.py +++ b/configure.py @@ -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: diff --git a/node.gyp b/node.gyp index 2e591eea59d413..a89b467e84a96f 100644 --- a/node.gyp +++ b/node.gyp @@ -471,6 +471,9 @@ }, 'conditions': [ + ['target_arch=="arm64"', { + 'cflags': ['-mbranch-protection=standard'], # Pointer authentication. + }], ['OS in "aix os400"', { 'ldflags': [ '-Wl,-bnoerrmsg',