jerryscript-project / jerryscript

Ultra-lightweight JavaScript engine for the Internet of Things.
https://jerryscript.net
Apache License 2.0
6.96k stars 673 forks source link

[Clang] Cannot build with pointer authentication (-mbranch-protection flag) #5171

Open bgergely0 opened 6 days ago

bgergely0 commented 6 days ago

I am trying to build the project on an aarch64 Linux machine, and when passing the compiler flag -mbranch-protection=pac-ret, I cannot build, the build process terminates with: clang: error: argument unused during compilation: '-mbranch-protection=pac-ret' [-Werror,-Wunused-command-line-argument]

JerryScript revision

Many versions

Build platform

Ubuntu 22.04.5 LTS (Linux 5.15.0-125-generic aarch64)

Build steps
export CC=clang;
python3 tools/build.py --compile-flag="-mbranch-protection=pac-ret"
Build log
[ 99%] Linking C executable ../bin/jerry
clang: error: argument unused during compilation: '-mbranch-protection=pac-ret' [-Werror,-Wunused-command-line-argument]
gmake[2]: *** [jerry-main/CMakeFiles/jerry.dir/build.make:133: bin/jerry] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:259: jerry-main/CMakeFiles/jerry.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2
==============================
Build failed with exit code: 2
==============================
lygstate commented 5 days ago

its your compiler does not support this option, try to not use it

bgergely0 commented 5 days ago

@lygstate I use clang 14, it does support it.

It even warns if I misspell the flag:

clang: error: unknown argument '-mbranch-protectionn=pac-ret'; did you mean '-mbranch-protection=pac-ret'?

So it definately knows about it, but still decides not to use it.

bgergely0 commented 5 days ago

After some more investigation, the issue is more clear:

So the issue is that all compilation flags get passed to the linker, regardless of support by the linker.

LaszloLango commented 3 hours ago

Contributions through new PRs are always welcome!