AArch64 Options in clang

I stumbled upon some options for the arm64/aarch64 architecture, such as aarch64-use-tbi and so on. I noticed that they seem to be available for the Swift compiler but not for clang.

I looked into the libLLVM.dylib on my system (I am aware that Swift links the LLVM mostly statically into the compiler) and the shared library seems to atleast contain the symbols. In an additional step, I build clang myself, and wrapped the initialisation of the variable UseAddressTopByteIgnored that is repsonsible for adding the option aarch64-use-tbi. I am a bit dumb-founded as to why the variable has been initialised and the flag has been “added” but I cannot find the option with clang.

There is an LLVM option and not a clang option:

The Swift way is swiftc -Xllvm aarch64-use-tbi. So it passes the option to LLVM. It is available to Clang. You have to use the same trick to pass the option to LLVM.

1 Like

Thank you for the fast answer. I kept using -Xllvm instead of clang’s -mllvm.

I stumbled on another problem in this context as well. With my self-built version I get following error

clang (LLVM option parsing): Unknown command line argument '--aarch64-use-tbi'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--aarch64-use-aa'?

Would you happen to have a pointer for this problem as well?

Unfortunately no. It tried clang-16 -mllvm aarch64-use-tbi ..., but I got similar problems.