-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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 warns for unused Arm -march even when used by preprocessor #55656
Comments
@llvm/issue-subscribers-clang-driver |
@llvm/issue-subscribers-backend-arm |
The warning is emitted in
Unfortunately it's not as simple as checking if The spirit of the warning is "hey you gave us two architecture values but we're going to prefer one hopefully it's the right one". So "unused" makes sense as the type of warning. We do get told if this is for the assembler but it's true either way. We can't tell if this is for the preprocessor and the assembler. I could add that context.
|
I think that
just needs an additional check for
I guess you could do something odd like But I think for the kernel, the versions match. Maybe we could not warn if the versions match? |
https://reviews.llvm.org/D65233 (and abandoned https://reviews.llvm.org/D65108) were in this area, maybe they can provide inspiration. (Or maybe they can't, I didn't look into this issue very closely. It just looked "vaguely related" to me, and maybe that assessment is just wrong.) |
Similar, thanks for the pointers. I think that issue is assembler vs not assembler where this is assembler vs preprocessor+assembler.
Agreed, if I can find a way to get to that or something like it. Perhaps there is an equivalent hidden within the job object but I haven't found it yet.
As a new warning? Where the compiler flag is not unused, just different to the assembler one. Sounds like a good idea. |
I'm not going to have time for this for the next few weeks. Anyone else feel free to pick it up. |
When both -march= and -Wa,-march= are specified for assembler or assembler-with-cpp sources, GCC and Clang will prefer the -Wa,-march= value but Clang will warn that -march= is unused. warning: argument unused during compilation: '-march=armv6k' [-Wunused-command-line-argument] This is the top group of warnings we observe when using clang to assemble the kernel via `ARCH=arm make LLVM=1`. Split the arch-y make variable into two, so that -march= flags only get passed to the compiler, not the assembler. -D flags are added to KBUILD_CPPFLAGS which is used for both C and assembler-with-cpp sources. Clang is trying to warn that it doesn't support different values for -march= and -Wa,-march= (like GCC does, but the kernel doesn't need this) though the value of the preprocessor define __thumb2__ is based on -march=. Make sure to re-set __thumb2__ via -D flag for assembler sources now that we're no longer passing -march= to the assembler. Set it to a different value than the preprocessor would for -march= in case -march= gets accidentally re-added to KBUILD_AFLAGS in the future. Thanks to Ard and Nathan for this suggestion. Link: ClangBuiltLinux#1315 Link: ClangBuiltLinux#1587 Link: llvm/llvm-project#55656 Suggested-by: Ard Biesheuvel <ardb@kernel.org> Suggested-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
When both -march= and -Wa,-march= are specified for assembler or assembler-with-cpp sources, GCC and Clang will prefer the -Wa,-march= value but Clang will warn that -march= is unused. warning: argument unused during compilation: '-march=armv6k' [-Wunused-command-line-argument] This is the top group of warnings we observe when using clang to assemble the kernel via `ARCH=arm make LLVM=1`. Split the arch-y make variable into two, so that -march= flags only get passed to the compiler, not the assembler. -D flags are added to KBUILD_CPPFLAGS which is used for both C and assembler-with-cpp sources. Clang is trying to warn that it doesn't support different values for -march= and -Wa,-march= (like GCC does, but the kernel doesn't need this) though the value of the preprocessor define __thumb2__ is based on -march=. Make sure to re-set __thumb2__ via -D flag for assembler sources now that we're no longer passing -march= to the assembler. Set it to a different value than the preprocessor would for -march= in case -march= gets accidentally re-added to KBUILD_AFLAGS in the future. Thanks to Ard and Nathan for this suggestion. Link: ClangBuiltLinux#1315 Link: ClangBuiltLinux#1587 Link: llvm/llvm-project#55656 Suggested-by: Ard Biesheuvel <ardb@kernel.org> Suggested-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
When both -march= and -Wa,-march= are specified for assembler or assembler-with-cpp sources, GCC and Clang will prefer the -Wa,-march= value but Clang will warn that -march= is unused. warning: argument unused during compilation: '-march=armv6k' [-Wunused-command-line-argument] This is the top group of warnings we observe when using clang to assemble the kernel via `ARCH=arm make LLVM=1`. Split the arch-y make variable into two, so that -march= flags only get passed to the compiler, not the assembler. -D flags are added to KBUILD_CPPFLAGS which is used for both C and assembler-with-cpp sources. Clang is trying to warn that it doesn't support different values for -march= and -Wa,-march= (like GCC does, but the kernel doesn't need this) though the value of the preprocessor define __thumb2__ is based on -march=. Make sure to re-set __thumb2__ via -D flag for assembler sources now that we're no longer passing -march= to the assembler. Set it to a different value than the preprocessor would for -march= in case -march= gets accidentally re-added to KBUILD_AFLAGS in the future. Thanks to Ard and Nathan for this suggestion. Link: ClangBuiltLinux#1315 Link: ClangBuiltLinux#1587 Link: llvm/llvm-project#55656 Suggested-by: Ard Biesheuvel <ardb@kernel.org> Suggested-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Same problem on Arch when I try to compile
|
(derived from ClangBuiltLinux/linux#1315)
Summary: clang should not warn that compiler
-march
arguments are unused when the preprocessor is run on assembly files./tmp/test.s
is just an empty file. Each time we're going to pass-march
to the compiler and assembler with-Wa
.If we assemble only then we are warned that the compiler
-march
is unused. So far so good.If we assemble but apply the preprocessor first we are still warned that it is unused. Which isn't correct because this option actually sets some preprocessor defines (justification for that at the end).
Now if we only preprocess an assembly file there's nothing to do so everything is unused. Fine.
If we run the preprocessor on the assembly file, everything is used. Part of me says that the
-Wa,-march
should be unused here. You are running the preprocessor on an assembly file but also we know that only the compiler-march
is used to set defines. Not sure.The key issue is that the compiler
-march
should be used if you're running the preprocessor. Clang should not be warning you that it is unused.Since it governs defines like
__thumb2__
so clearly it does something. Here we see that removing the compiler-march
causes this file to fail to assemble, therefore it is "used". If you put it back clang then tells you it is unused despite clearly being used to add the define.Somehow
-march
fixes the issue but is also unused.The text was updated successfully, but these errors were encountered: