Skip to content
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

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

Open
bgergely0 opened this issue Nov 20, 2024 · 4 comments
Labels
bug Undesired behaviour tools Related to the tooling scripts

Comments

@bgergely0
Copy link

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
Copy link
Contributor

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

@bgergely0
Copy link
Author

bgergely0 commented Nov 20, 2024

@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
Copy link
Author

After some more investigation, the issue is more clear:

  • during compilation the -mbranch-protection=pac-ret gets passed to the linker as well
  • in my case, that's gcc even though I used clang for compilation
  • the linker rejects the flag, because it's not a linker flag
  • even though gcc supports it as a compiler

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

@LaszloLango LaszloLango added bug Undesired behaviour tools Related to the tooling scripts labels Nov 26, 2024
@LaszloLango LaszloLango changed the title Cannot build with pointer authentication (-mbranch-protection flag) [Clang] Cannot build with pointer authentication (-mbranch-protection flag) Nov 26, 2024
@LaszloLango
Copy link
Contributor

Contributions through new PRs are always welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Undesired behaviour tools Related to the tooling scripts
Projects
None yet
Development

No branches or pull requests

3 participants