-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: fix arm64 cross-compilation #51256
Conversation
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 <targos@protonmail.com>
Review requested:
|
Landed in c21b2be |
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>
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>
I've tried cross compiling node 21.7.2, which has this patch, on x86_64 targetting aarch64. The build fails:
If I remove the |
This means you are using a compiler earlier than gcc 9 -- |
Hi @richardlau, thanks for looking at this.
I thought this too, but I double-checked and I'd built GCC13. It seems like the build is trying to use the host gcc (it's passing |
Do you have |
Hi @richardlau, I was using:
|
I was able to cross-compile for ARM64 on my x64 machine with #52559. Here are the commands I used: # Setting up the env
export CC_host="gcc"
export CXX_host="g++"
export CC="aarch64-linux-gnu-gcc"
export CXX="aarch64-linux-gnu-g++"
export AS="aarch64-linux-gnu-as"
export LD="aarch64-linux-gnu-ld"
export RANLIB="aarch64-linux-gnu-ranlib"
# Building as a shared library also works with --shared
./configure --dest-cpu arm64 --dest-os linux
# Build it
make -j12 |
Thanks a lot @richardlau and @devraymondsh, I got a successful cross-compilation with those patches too. |
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>
Alternative to #45756 (@bnoordhuis)
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
Fixes: nodejs/build#3319