Open nickdesaulniers opened 2 weeks ago
@llvm/issue-subscribers-clang-driver
Author: Nick Desaulniers (paternity leave) (nickdesaulniers)
Would it be possible to say which preprocessor defines these are, or an example of one? Would help speed up any investigation.
I can only see three uses of -mthumb OPT_mthumb in the clang driver. Two in Driver/Toolchains/Arch/ARM.cpp and one in Driver/Toolchains/GNU.cpp , none look related to pre-processor macros though. I can only assume that some macros are being defined prior to the triple being normalised?
$ comm -3 <(clang --target=thumbv7-linux-gnueabihf -dM -E -x c - < /dev/null | sort ) <(clang --target=thumbv7-linux-gnueabihf -dM -E -mthumb -x c - < /dev/null | sort )
#define __thumb__ 1
#define __thumb2__ 1
#define __THUMBEL__ 1
Thank you!
The clang driver canonicalizes the triple, so you're not actually producing thumb code at all. The defines reflect this.
Arguably --target=thumbv7-linux-gnueabihf should imply -mthumb.
I could have sworn that --target=thumbv7-*-*-* implied -mthumb, but it seems like I'm remembering llvm-mc --triple=thumbv7-a. I agree that --target=thumbv7-linux-gnueabihf should imply -mthumb (presumably in the absence of -marm)
I guess I was surprised to find that
--target=thumbv7-linux-gnueabihf
did not imply the same preprocessor defines that-mthumb
does. This requires llvm-libc to set-mthumb
in addition to--target=thumbv7-linux-gnueabihf
, which is obnoxious.See also #96550. cc @kbeyls @smithp35 @rengolin @DanielKristofKiss