diff mbox series

[v3,5/7] selftests/x86: avoid -no-pie warnings from clang during compilation

Message ID 20240531193838.108454-6-jhubbard@nvidia.com (mailing list archive)
State Accepted
Commit 54df8db8c658f29a35e3bfe651e49f87f72dec76
Headers show
Series selftests/x86: fix build errors and warnings found via clang | expand

Commit Message

John Hubbard May 31, 2024, 7:38 p.m. UTC
When building with clang, via:

    make LLVM=1 -C tools/testing/selftests

...clang warns that -no-pie is "unused during compilation".

This occurs because clang only wants to see -no-pie during linking.
Here, we don't have a separate linking stage, so a compiler warning is
unavoidable without (wastefully) restructuring the Makefile.

Avoid the warning by simply disabling that warning, for clang builds.

Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
 tools/testing/selftests/x86/Makefile | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

John Hubbard June 7, 2024, 10:23 p.m. UTC | #1
On 5/31/24 12:38 PM, John Hubbard wrote:
...
> diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
> index d0bb32bd5538..5c8757a25998 100644
> --- a/tools/testing/selftests/x86/Makefile
> +++ b/tools/testing/selftests/x86/Makefile
> @@ -40,6 +40,13 @@ CFLAGS := -O2 -g -std=gnu99 -pthread -Wall $(KHDR_INCLUDES)
>   # call32_from_64 in thunks.S uses absolute addresses.
>   ifeq ($(CAN_BUILD_WITH_NOPIE),1)
>   CFLAGS += -no-pie
> +
> +ifneq ($(LLVM),)
> +# clang only wants to see -no-pie during linking. Here, we don't have a separate
> +# linking stage, so a compiler warning is unavoidable without (wastefully)
> +# restructuring the Makefile. Avoid this by simply disabling that warning.
> +CFLAGS += -Wno-unused-command-line-argument
> +endif
>   endif
>   
>   define gen-target-rule-32

This actually can be improved slightly, as per our latest tentative
decision about how to handle both LLVM=1 and CC=clang cases [1].

If this series goes via Shuah's next tree, then I can put the
CC_IS_CLANG fix from [1] on top of previous patches, that will work
nicely.

In other words, I think we can use this series as-is, and let the
CC_IS_CLANG fix proceed just after that. Because it gets better a piece
at a time: first we get rid of the warning for most cases, then we get
rid of it for the odd "make CC=clang" case as well.

[1] https://lore.kernel.org/6b32399f-d9c6-4df5-b1e5-755ef4acf25d@nvidia.com

thanks,
diff mbox series

Patch

diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
index d0bb32bd5538..5c8757a25998 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -40,6 +40,13 @@  CFLAGS := -O2 -g -std=gnu99 -pthread -Wall $(KHDR_INCLUDES)
 # call32_from_64 in thunks.S uses absolute addresses.
 ifeq ($(CAN_BUILD_WITH_NOPIE),1)
 CFLAGS += -no-pie
+
+ifneq ($(LLVM),)
+# clang only wants to see -no-pie during linking. Here, we don't have a separate
+# linking stage, so a compiler warning is unavoidable without (wastefully)
+# restructuring the Makefile. Avoid this by simply disabling that warning.
+CFLAGS += -Wno-unused-command-line-argument
+endif
 endif
 
 define gen-target-rule-32