* [PATCH 00/14] Remove clang's -Qunused-arguments from KBUILD_CPPFLAGS
@ 2023-01-04 19:54 Nathan Chancellor
2023-01-04 19:54 ` [PATCH 05/14] powerpc: Remove linker flag from KBUILD_AFLAGS Nathan Chancellor
` (4 more replies)
0 siblings, 5 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-01-04 19:54 UTC (permalink / raw)
To: masahiroy, ndesaulniers
Cc: trix, dave.hansen, dri-devel, amd-gfx, agordeev, linux-s390,
kernel test robot, x86, Rodrigo.Siqueira, mingo, borntraeger,
harry.wentland, llvm, nicolas, gor, linux-kbuild, sunpeng.li, hca,
npiggin, Nathan Chancellor, bp, tglx, tsbogend, Xinhui.Pan,
linux-mips, svens, alexander.deucher, linuxppc-dev,
christian.koenig
Hi all,
Clang can emit a few different warnings when it encounters a flag that it
recognizes but does not support internally. These warnings are elevated to
errors within {as,cc}-option via -Werror to catch unsupported flags that should
not be added to KBUILD_{A,C}FLAGS; see commit c3f0d0bc5b01 ("kbuild, LLVMLinux:
Add -Werror to cc-option to support clang").
If an unsupported flag is unconditionally to KBUILD_{A,C}FLAGS, all subsequent
{as,cc}-option will always fail, preventing supported and even potentially
necessary flags from getting adding to the tool flags.
One would expect these warnings to be visible in the kernel build logs since
they are added to KBUILD_{A,C}FLAGS but unfortunately, these warnings are
hidden with clang's -Qunused-arguments flag, which is added to KBUILD_CPPFLAGS
and used for both compiling and assembling files.
Patches 1-4 address the internal inconsistencies of invoking the assembler
within kbuild by using KBUILD_AFLAGS consistently and using '-x
assembler-with-cpp' over '-x assembler'. This matches how assembly files are
built across the kernel and helps avoid problems in situations where macro
definitions or warning flags are present in KBUILD_AFLAGS, which cause
instances of -Wunused-command-line-argument when the preprocessor is not called
to consume them. There were a couple of places in architecture code where this
change would break things so those are fixed first.
Patches 5-12 clean up warnings that will show up when -Qunused-argument is
dropped. I hope none of these are controversial.
Patch 13 turns two warnings into errors so that the presence of unused flags
cannot be easily ignored.
Patch 14 drops -Qunused-argument. This is done last so that it can be easily
reverted if need be.
This series has seen my personal test framework, which tests several different
configurations and architectures, with LLVM tip of tree (16.0.0). I have done
defconfig, allmodconfig, and allnoconfig builds for arm, arm64, i386, mips,
powerpc, riscv, s390, and x86_64 with GCC 12.2.0 as well but I am hoping the
rest of the test infrastructure will catch any lurking problems.
I would like this series to stay together so that there is no opportunity for
breakage so please consider giving acks so that this can be carried via the
kbuild tree.
---
Nathan Chancellor (12):
MIPS: Always use -Wa,-msoft-float and eliminate GAS_HAS_SET_HARDFLOAT
MIPS: Prefer cc-option for additions to cflags
powerpc: Remove linker flag from KBUILD_AFLAGS
powerpc/vdso: Remove unused '-s' flag from ASFLAGS
powerpc/vdso: Improve linker flags
powerpc/vdso: Remove an unsupported flag from vgettimeofday-32.o with clang
s390/vdso: Drop unused '-s' flag from KBUILD_AFLAGS_64
s390/vdso: Drop '-shared' from KBUILD_CFLAGS_64
s390/purgatory: Remove unused '-MD' and unnecessary '-c' flags
drm/amd/display: Do not add '-mhard-float' to dml_ccflags for clang
kbuild: Turn a couple more of clang's unused option warnings into errors
kbuild: Stop using '-Qunused-arguments' with clang
Nick Desaulniers (2):
x86/boot/compressed: prefer cc-option for CFLAGS additions
kbuild: Update assembler calls to use proper flags and language target
Makefile | 1 -
arch/mips/Makefile | 13 ++-------
arch/mips/include/asm/asmmacro-32.h | 4 +--
arch/mips/include/asm/asmmacro.h | 42 ++++++++++++++---------------
arch/mips/include/asm/fpregdef.h | 14 ----------
arch/mips/include/asm/mipsregs.h | 20 +++-----------
arch/mips/kernel/genex.S | 2 +-
arch/mips/kernel/r2300_fpu.S | 4 +--
arch/mips/kernel/r4k_fpu.S | 12 ++++-----
arch/mips/kvm/fpu.S | 6 ++---
arch/mips/loongson2ef/Platform | 2 +-
arch/powerpc/Makefile | 2 +-
arch/powerpc/kernel/vdso/Makefile | 25 +++++++++++------
arch/s390/kernel/vdso64/Makefile | 4 +--
arch/s390/purgatory/Makefile | 2 +-
arch/x86/boot/compressed/Makefile | 2 +-
drivers/gpu/drm/amd/display/dc/dml/Makefile | 3 ++-
scripts/Kconfig.include | 2 +-
scripts/Makefile.clang | 2 ++
scripts/Makefile.compiler | 8 +++---
scripts/as-version.sh | 2 +-
21 files changed, 74 insertions(+), 98 deletions(-)
---
base-commit: 88603b6dc419445847923fcb7fe5080067a30f98
change-id: 20221228-drop-qunused-arguments-0c5c7dae54fb
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 05/14] powerpc: Remove linker flag from KBUILD_AFLAGS
2023-01-04 19:54 [PATCH 00/14] Remove clang's -Qunused-arguments from KBUILD_CPPFLAGS Nathan Chancellor
@ 2023-01-04 19:54 ` Nathan Chancellor
2023-01-09 21:24 ` Nick Desaulniers
2023-01-04 19:54 ` [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS Nathan Chancellor
` (3 subsequent siblings)
4 siblings, 1 reply; 24+ messages in thread
From: Nathan Chancellor @ 2023-01-04 19:54 UTC (permalink / raw)
To: masahiroy, ndesaulniers
Cc: kernel test robot, linux-kbuild, trix, llvm, npiggin,
Nathan Chancellor, linuxppc-dev, nicolas
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
points out that KBUILD_AFLAGS contains a linker flag, which will be
used:
clang: error: -Wl,-a32: 'linker' input unused [-Werror,-Wunused-command-line-argument]
This was likely supposed to be '-Wa,-a$(BITS)'. However, this change is
unnecessary, as all supported versions of clang and gcc will pass '-a64'
or '-a32' to GNU as based on the value of '-m'; the behavior of the
latest stable release of the oldest supported major version of each
compiler is shown below and each compiler's latest release exhibits the
same behavior (GCC 12.2.0 and Clang 15.0.6).
$ powerpc64-linux-gcc --version | head -1
powerpc64-linux-gcc (GCC) 5.5.0
$ powerpc64-linux-gcc -m64 -### -x assembler-with-cpp -c -o /dev/null /dev/null &| grep 'as '
.../as -a64 -mppc64 -many -mbig -o /dev/null /tmp/cctwuBzZ.s
$ powerpc64-linux-gcc -m32 -### -x assembler-with-cpp -c -o /dev/null /dev/null &| grep 'as '
.../as -a32 -mppc -many -mbig -o /dev/null /tmp/ccaZP4mF.sg
$ clang --version | head -1
Ubuntu clang version 11.1.0-++20211011094159+1fdec59bffc1-1~exp1~20211011214622.5
$ clang --target=powerpc64-linux-gnu -fno-integrated-as -m64 -### \
-x assembler-with-cpp -c -o /dev/null /dev/null &| grep gnu-as
"/usr/bin/powerpc64-linux-gnu-as" "-a64" "-mppc64" "-many" "-o" "/dev/null" "/tmp/null-80267c.s"
$ clang --target=powerpc64-linux-gnu -fno-integrated-as -m64 -### \
-x assembler-with-cpp -c -o /dev/null /dev/null &| grep gnu-as
"/usr/bin/powerpc64-linux-gnu-as" "-a32" "-mppc" "-many" "-o" "/dev/null" "/tmp/null-ab8f8d.s"
Remove this flag altogether to avoid future issues.
Fixes: 1421dc6d4829 ("powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Cc: mpe@ellerman.id.au
Cc: npiggin@gmail.com
Cc: christophe.leroy@csgroup.eu
Cc: linuxppc-dev@lists.ozlabs.org
---
arch/powerpc/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index dc4cbf0a5ca9..4fd630efe39d 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -90,7 +90,7 @@ aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
ifeq ($(HAS_BIARCH),y)
KBUILD_CFLAGS += -m$(BITS)
-KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS)
+KBUILD_AFLAGS += -m$(BITS)
KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION)
endif
--
2.39.0
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS
2023-01-04 19:54 [PATCH 00/14] Remove clang's -Qunused-arguments from KBUILD_CPPFLAGS Nathan Chancellor
2023-01-04 19:54 ` [PATCH 05/14] powerpc: Remove linker flag from KBUILD_AFLAGS Nathan Chancellor
@ 2023-01-04 19:54 ` Nathan Chancellor
2023-01-09 21:58 ` Nick Desaulniers
2023-01-04 19:54 ` [PATCH 07/14] powerpc/vdso: Improve linker flags Nathan Chancellor
` (2 subsequent siblings)
4 siblings, 1 reply; 24+ messages in thread
From: Nathan Chancellor @ 2023-01-04 19:54 UTC (permalink / raw)
To: masahiroy, ndesaulniers
Cc: kernel test robot, linux-kbuild, trix, llvm, npiggin,
Nathan Chancellor, linuxppc-dev, nicolas
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
warns that ASFLAGS contains '-s', which is a linking phase option, so it
is unused.
clang-16: error: argument unused during compilation: '-s' [-Werror,-Wunused-command-line-argument]
Looking at the GAS sources, '-s' is only useful when targeting Solaris
and it is ignored for the powerpc target so just drop the flag
altogether, as it is not needed.
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Cc: mpe@ellerman.id.au
Cc: npiggin@gmail.com
Cc: christophe.leroy@csgroup.eu
Cc: linuxppc-dev@lists.ozlabs.org
---
arch/powerpc/kernel/vdso/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
index 6a977b0d8ffc..45c0cc5d34b6 100644
--- a/arch/powerpc/kernel/vdso/Makefile
+++ b/arch/powerpc/kernel/vdso/Makefile
@@ -51,10 +51,10 @@ ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both
ccflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld)
CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32
-AS32FLAGS := -D__VDSO32__ -s
+AS32FLAGS := -D__VDSO32__
CC64FLAGS := -Wl,-soname=linux-vdso64.so.1
-AS64FLAGS := -D__VDSO64__ -s
+AS64FLAGS := -D__VDSO64__
targets += vdso32.lds
CPPFLAGS_vdso32.lds += -P -C -Upowerpc
--
2.39.0
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 07/14] powerpc/vdso: Improve linker flags
2023-01-04 19:54 [PATCH 00/14] Remove clang's -Qunused-arguments from KBUILD_CPPFLAGS Nathan Chancellor
2023-01-04 19:54 ` [PATCH 05/14] powerpc: Remove linker flag from KBUILD_AFLAGS Nathan Chancellor
2023-01-04 19:54 ` [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS Nathan Chancellor
@ 2023-01-04 19:54 ` Nathan Chancellor
2023-01-09 22:08 ` Nick Desaulniers
2023-01-04 19:54 ` [PATCH 08/14] powerpc/vdso: Remove an unsupported flag from vgettimeofday-32.o with clang Nathan Chancellor
2023-01-05 8:00 ` [PATCH 00/14] Remove clang's -Qunused-arguments from KBUILD_CPPFLAGS Heiko Carstens
4 siblings, 1 reply; 24+ messages in thread
From: Nathan Chancellor @ 2023-01-04 19:54 UTC (permalink / raw)
To: masahiroy, ndesaulniers
Cc: kernel test robot, linux-kbuild, trix, llvm, npiggin,
Nathan Chancellor, linuxppc-dev, nicolas
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, there
are several warnings in the PowerPC vDSO:
clang-16: error: -Wl,-soname=linux-vdso32.so.1: 'linker' input unused [-Werror,-Wunused-command-line-argument]
clang-16: error: -Wl,--hash-style=both: 'linker' input unused [-Werror,-Wunused-command-line-argument]
clang-16: error: argument unused during compilation: '-shared' [-Werror,-Wunused-command-line-argument]
clang-16: error: argument unused during compilation: '-nostdinc' [-Werror,-Wunused-command-line-argument]
clang-16: error: argument unused during compilation: '-Wa,-maltivec' [-Werror,-Wunused-command-line-argument]
The first group of warnings point out that linker flags were being added
to all invocations of $(CC), even though they will only be used during
the final vDSO link. Move those flags to ldflags-y.
The second group of warnings are compiler or assembler flags that will
be unused during linking. Filter them out from KBUILD_CFLAGS so that
they are not used during linking.
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Cc: mpe@ellerman.id.au
Cc: npiggin@gmail.com
Cc: christophe.leroy@csgroup.eu
Cc: linuxppc-dev@lists.ozlabs.org
---
arch/powerpc/kernel/vdso/Makefile | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
index 45c0cc5d34b6..769b62832b38 100644
--- a/arch/powerpc/kernel/vdso/Makefile
+++ b/arch/powerpc/kernel/vdso/Makefile
@@ -47,13 +47,17 @@ KCOV_INSTRUMENT := n
UBSAN_SANITIZE := n
KASAN_SANITIZE := n
-ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both
-ccflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld)
-
-CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32
+ccflags-y := -fno-common -fno-builtin
+ldflags-y := -Wl,--hash-style=both -nostdlib -shared
+ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld)
+# Filter flags that clang will warn are unused for linking
+ldflags-y += $(filter-out $(CC_FLAGS_FTRACE) -Wa$(comma)%, $(KBUILD_CFLAGS))
+
+CC32FLAGS := -m32
+LD32FLAGS := -Wl,-soname=linux-vdso32.so.1
AS32FLAGS := -D__VDSO32__
-CC64FLAGS := -Wl,-soname=linux-vdso64.so.1
+LD64FLAGS := -Wl,-soname=linux-vdso64.so.1
AS64FLAGS := -D__VDSO64__
targets += vdso32.lds
@@ -92,14 +96,14 @@ include/generated/vdso64-offsets.h: $(obj)/vdso64.so.dbg FORCE
# actual build commands
quiet_cmd_vdso32ld_and_check = VDSO32L $@
- cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
+ cmd_vdso32ld_and_check = $(VDSOCC) $(ldflags-y) $(CC32FLAGS) $(LD32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
quiet_cmd_vdso32as = VDSO32A $@
cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $<
quiet_cmd_vdso32cc = VDSO32C $@
cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $<
quiet_cmd_vdso64ld_and_check = VDSO64L $@
- cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
+ cmd_vdso64ld_and_check = $(VDSOCC) $(ldflags-y) $(CC64FLAGS) $(LD64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
quiet_cmd_vdso64as = VDSO64A $@
cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $<
--
2.39.0
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 08/14] powerpc/vdso: Remove an unsupported flag from vgettimeofday-32.o with clang
2023-01-04 19:54 [PATCH 00/14] Remove clang's -Qunused-arguments from KBUILD_CPPFLAGS Nathan Chancellor
` (2 preceding siblings ...)
2023-01-04 19:54 ` [PATCH 07/14] powerpc/vdso: Improve linker flags Nathan Chancellor
@ 2023-01-04 19:54 ` Nathan Chancellor
2023-01-09 22:12 ` Nick Desaulniers
2023-01-05 8:00 ` [PATCH 00/14] Remove clang's -Qunused-arguments from KBUILD_CPPFLAGS Heiko Carstens
4 siblings, 1 reply; 24+ messages in thread
From: Nathan Chancellor @ 2023-01-04 19:54 UTC (permalink / raw)
To: masahiroy, ndesaulniers
Cc: kernel test robot, linux-kbuild, trix, llvm, npiggin,
Nathan Chancellor, linuxppc-dev, nicolas
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
warns:
clang-16: error: argument unused during compilation: '-fno-stack-clash-protection' [-Werror,-Wunused-command-line-argument]
This flag is supported for 64-bit powerpc but not 32-bit, hence the warning.
Just remove the flag from vgettimeofday-32.o's CFLAGS when using clang, as has
been done for other flags previously.
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Cc: mpe@ellerman.id.au
Cc: npiggin@gmail.com
Cc: christophe.leroy@csgroup.eu
Cc: linuxppc-dev@lists.ozlabs.org
---
arch/powerpc/kernel/vdso/Makefile | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
index 769b62832b38..4ee7d36ce752 100644
--- a/arch/powerpc/kernel/vdso/Makefile
+++ b/arch/powerpc/kernel/vdso/Makefile
@@ -16,6 +16,11 @@ ifneq ($(c-gettimeofday-y),)
CFLAGS_vgettimeofday-32.o += -ffreestanding -fasynchronous-unwind-tables
CFLAGS_REMOVE_vgettimeofday-32.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_vgettimeofday-32.o += -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc
+ # This flag is supported by clang for 64-bit but not 32-bit so it will cause
+ # an unused command line flag warning for this file.
+ ifdef CONFIG_CC_IS_CLANG
+ CFLAGS_REMOVE_vgettimeofday-32.o += -fno-stack-clash-protection
+ endif
CFLAGS_vgettimeofday-64.o += -include $(c-gettimeofday-y)
CFLAGS_vgettimeofday-64.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
CFLAGS_vgettimeofday-64.o += $(call cc-option, -fno-stack-protector)
--
2.39.0
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH 00/14] Remove clang's -Qunused-arguments from KBUILD_CPPFLAGS
2023-01-04 19:54 [PATCH 00/14] Remove clang's -Qunused-arguments from KBUILD_CPPFLAGS Nathan Chancellor
` (3 preceding siblings ...)
2023-01-04 19:54 ` [PATCH 08/14] powerpc/vdso: Remove an unsupported flag from vgettimeofday-32.o with clang Nathan Chancellor
@ 2023-01-05 8:00 ` Heiko Carstens
4 siblings, 0 replies; 24+ messages in thread
From: Heiko Carstens @ 2023-01-05 8:00 UTC (permalink / raw)
To: Nathan Chancellor
Cc: trix, dave.hansen, dri-devel, amd-gfx, agordeev, linux-s390,
kernel test robot, masahiroy, x86, Rodrigo.Siqueira, mingo,
borntraeger, harry.wentland, llvm, nicolas, gor, linux-kbuild,
sunpeng.li, npiggin, bp, tglx, tsbogend, Xinhui.Pan, ndesaulniers,
linux-mips, svens, alexander.deucher, linuxppc-dev,
christian.koenig
On Wed, Jan 04, 2023 at 12:54:18PM -0700, Nathan Chancellor wrote:
> Hi all,
...
> This series has seen my personal test framework, which tests several different
> configurations and architectures, with LLVM tip of tree (16.0.0). I have done
> defconfig, allmodconfig, and allnoconfig builds for arm, arm64, i386, mips,
> powerpc, riscv, s390, and x86_64 with GCC 12.2.0 as well but I am hoping the
> rest of the test infrastructure will catch any lurking problems.
>
> I would like this series to stay together so that there is no opportunity for
> breakage so please consider giving acks so that this can be carried via the
> kbuild tree.
...
> s390/vdso: Drop unused '-s' flag from KBUILD_AFLAGS_64
> s390/vdso: Drop '-shared' from KBUILD_CFLAGS_64
> s390/purgatory: Remove unused '-MD' and unnecessary '-c' flags
...
> arch/s390/kernel/vdso64/Makefile | 4 +--
> arch/s390/purgatory/Makefile | 2 +-
For the s390 bits:
Acked-by: Heiko Carstens <hca@linux.ibm.com>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 05/14] powerpc: Remove linker flag from KBUILD_AFLAGS
2023-01-04 19:54 ` [PATCH 05/14] powerpc: Remove linker flag from KBUILD_AFLAGS Nathan Chancellor
@ 2023-01-09 21:24 ` Nick Desaulniers
0 siblings, 0 replies; 24+ messages in thread
From: Nick Desaulniers @ 2023-01-09 21:24 UTC (permalink / raw)
To: Nathan Chancellor
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm, npiggin,
linuxppc-dev, nicolas
On Wed, Jan 4, 2023 at 11:54 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> points out that KBUILD_AFLAGS contains a linker flag, which will be
> used:
>
> clang: error: -Wl,-a32: 'linker' input unused [-Werror,-Wunused-command-line-argument]
>
> This was likely supposed to be '-Wa,-a$(BITS)'. However, this change is
> unnecessary, as all supported versions of clang and gcc will pass '-a64'
> or '-a32' to GNU as based on the value of '-m'; the behavior of the
> latest stable release of the oldest supported major version of each
> compiler is shown below and each compiler's latest release exhibits the
> same behavior (GCC 12.2.0 and Clang 15.0.6).
>
> $ powerpc64-linux-gcc --version | head -1
> powerpc64-linux-gcc (GCC) 5.5.0
>
> $ powerpc64-linux-gcc -m64 -### -x assembler-with-cpp -c -o /dev/null /dev/null &| grep 'as '
> .../as -a64 -mppc64 -many -mbig -o /dev/null /tmp/cctwuBzZ.s
>
> $ powerpc64-linux-gcc -m32 -### -x assembler-with-cpp -c -o /dev/null /dev/null &| grep 'as '
> .../as -a32 -mppc -many -mbig -o /dev/null /tmp/ccaZP4mF.sg
>
> $ clang --version | head -1
> Ubuntu clang version 11.1.0-++20211011094159+1fdec59bffc1-1~exp1~20211011214622.5
>
> $ clang --target=powerpc64-linux-gnu -fno-integrated-as -m64 -### \
> -x assembler-with-cpp -c -o /dev/null /dev/null &| grep gnu-as
> "/usr/bin/powerpc64-linux-gnu-as" "-a64" "-mppc64" "-many" "-o" "/dev/null" "/tmp/null-80267c.s"
>
> $ clang --target=powerpc64-linux-gnu -fno-integrated-as -m64 -### \
> -x assembler-with-cpp -c -o /dev/null /dev/null &| grep gnu-as
> "/usr/bin/powerpc64-linux-gnu-as" "-a32" "-mppc" "-many" "-o" "/dev/null" "/tmp/null-ab8f8d.s"
>
> Remove this flag altogether to avoid future issues.
>
> Fixes: 1421dc6d4829 ("powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> Cc: mpe@ellerman.id.au
> Cc: npiggin@gmail.com
> Cc: christophe.leroy@csgroup.eu
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
> arch/powerpc/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index dc4cbf0a5ca9..4fd630efe39d 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -90,7 +90,7 @@ aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
>
> ifeq ($(HAS_BIARCH),y)
> KBUILD_CFLAGS += -m$(BITS)
> -KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS)
> +KBUILD_AFLAGS += -m$(BITS)
> KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION)
> endif
>
>
> --
> 2.39.0
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS
2023-01-04 19:54 ` [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS Nathan Chancellor
@ 2023-01-09 21:58 ` Nick Desaulniers
2023-01-09 22:15 ` Nathan Chancellor
` (2 more replies)
0 siblings, 3 replies; 24+ messages in thread
From: Nick Desaulniers @ 2023-01-09 21:58 UTC (permalink / raw)
To: Nathan Chancellor
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm, npiggin,
linuxppc-dev, nicolas
On Wed, Jan 4, 2023 at 11:55 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> warns that ASFLAGS contains '-s', which is a linking phase option, so it
> is unused.
>
> clang-16: error: argument unused during compilation: '-s' [-Werror,-Wunused-command-line-argument]
>
> Looking at the GAS sources, '-s' is only useful when targeting Solaris
> and it is ignored for the powerpc target so just drop the flag
> altogether, as it is not needed.
Do you have any more info where you found this? I don't see -s
documented as an assembler flag.
https://sourceware.org/binutils/docs/as/PowerPC_002dOpts.html
https://sourceware.org/binutils/docs/as/Invoking.html
The patch seems fine to me, but what was this ever supposed to be?
FWICT it predates git history (looking at
arch/powerpc/kernel/vdso32/Makefile at fc15351d9d63)
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> Cc: mpe@ellerman.id.au
> Cc: npiggin@gmail.com
> Cc: christophe.leroy@csgroup.eu
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
> arch/powerpc/kernel/vdso/Makefile | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
> index 6a977b0d8ffc..45c0cc5d34b6 100644
> --- a/arch/powerpc/kernel/vdso/Makefile
> +++ b/arch/powerpc/kernel/vdso/Makefile
> @@ -51,10 +51,10 @@ ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both
> ccflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld)
>
> CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32
> -AS32FLAGS := -D__VDSO32__ -s
> +AS32FLAGS := -D__VDSO32__
>
> CC64FLAGS := -Wl,-soname=linux-vdso64.so.1
> -AS64FLAGS := -D__VDSO64__ -s
> +AS64FLAGS := -D__VDSO64__
>
> targets += vdso32.lds
> CPPFLAGS_vdso32.lds += -P -C -Upowerpc
>
> --
> 2.39.0
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 07/14] powerpc/vdso: Improve linker flags
2023-01-04 19:54 ` [PATCH 07/14] powerpc/vdso: Improve linker flags Nathan Chancellor
@ 2023-01-09 22:08 ` Nick Desaulniers
2023-01-09 22:15 ` Nathan Chancellor
0 siblings, 1 reply; 24+ messages in thread
From: Nick Desaulniers @ 2023-01-09 22:08 UTC (permalink / raw)
To: Nathan Chancellor
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm, npiggin,
linuxppc-dev, nicolas
On Wed, Jan 4, 2023 at 11:55 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, there
> are several warnings in the PowerPC vDSO:
>
> clang-16: error: -Wl,-soname=linux-vdso32.so.1: 'linker' input unused [-Werror,-Wunused-command-line-argument]
> clang-16: error: -Wl,--hash-style=both: 'linker' input unused [-Werror,-Wunused-command-line-argument]
> clang-16: error: argument unused during compilation: '-shared' [-Werror,-Wunused-command-line-argument]
>
> clang-16: error: argument unused during compilation: '-nostdinc' [-Werror,-Wunused-command-line-argument]
> clang-16: error: argument unused during compilation: '-Wa,-maltivec' [-Werror,-Wunused-command-line-argument]
>
> The first group of warnings point out that linker flags were being added
> to all invocations of $(CC), even though they will only be used during
> the final vDSO link. Move those flags to ldflags-y.
>
> The second group of warnings are compiler or assembler flags that will
> be unused during linking. Filter them out from KBUILD_CFLAGS so that
> they are not used during linking.
>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> Cc: mpe@ellerman.id.au
> Cc: npiggin@gmail.com
> Cc: christophe.leroy@csgroup.eu
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
> arch/powerpc/kernel/vdso/Makefile | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
> index 45c0cc5d34b6..769b62832b38 100644
> --- a/arch/powerpc/kernel/vdso/Makefile
> +++ b/arch/powerpc/kernel/vdso/Makefile
> @@ -47,13 +47,17 @@ KCOV_INSTRUMENT := n
> UBSAN_SANITIZE := n
> KASAN_SANITIZE := n
>
> -ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both
> -ccflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld)
> -
> -CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32
> +ccflags-y := -fno-common -fno-builtin
> +ldflags-y := -Wl,--hash-style=both -nostdlib -shared
> +ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld)
> +# Filter flags that clang will warn are unused for linking
> +ldflags-y += $(filter-out $(CC_FLAGS_FTRACE) -Wa$(comma)%, $(KBUILD_CFLAGS))
> +
> +CC32FLAGS := -m32
> +LD32FLAGS := -Wl,-soname=linux-vdso32.so.1
> AS32FLAGS := -D__VDSO32__
>
> -CC64FLAGS := -Wl,-soname=linux-vdso64.so.1
> +LD64FLAGS := -Wl,-soname=linux-vdso64.so.1
> AS64FLAGS := -D__VDSO64__
>
> targets += vdso32.lds
> @@ -92,14 +96,14 @@ include/generated/vdso64-offsets.h: $(obj)/vdso64.so.dbg FORCE
>
> # actual build commands
> quiet_cmd_vdso32ld_and_check = VDSO32L $@
> - cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
> + cmd_vdso32ld_and_check = $(VDSOCC) $(ldflags-y) $(CC32FLAGS) $(LD32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
> quiet_cmd_vdso32as = VDSO32A $@
> cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $<
> quiet_cmd_vdso32cc = VDSO32C $@
> cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $<
>
> quiet_cmd_vdso64ld_and_check = VDSO64L $@
> - cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
> + cmd_vdso64ld_and_check = $(VDSOCC) $(ldflags-y) $(CC64FLAGS) $(LD64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
Let's move `-z noexecstack` up into ldflags-y? (you may add my RB with
that modification)
> quiet_cmd_vdso64as = VDSO64A $@
> cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $<
>
>
> --
> 2.39.0
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 08/14] powerpc/vdso: Remove an unsupported flag from vgettimeofday-32.o with clang
2023-01-04 19:54 ` [PATCH 08/14] powerpc/vdso: Remove an unsupported flag from vgettimeofday-32.o with clang Nathan Chancellor
@ 2023-01-09 22:12 ` Nick Desaulniers
2023-01-09 22:38 ` Nathan Chancellor
0 siblings, 1 reply; 24+ messages in thread
From: Nick Desaulniers @ 2023-01-09 22:12 UTC (permalink / raw)
To: Nathan Chancellor
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm, npiggin,
linuxppc-dev, nicolas
On Wed, Jan 4, 2023 at 11:55 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> warns:
>
> clang-16: error: argument unused during compilation: '-fno-stack-clash-protection' [-Werror,-Wunused-command-line-argument]
>
> This flag is supported for 64-bit powerpc but not 32-bit, hence the warning.
> Just remove the flag from vgettimeofday-32.o's CFLAGS when using clang, as has
> been done for other flags previously.
>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Hmm...so this was added by the top level Makefile doing a cc-option
test. How did the test pass if this was unsupported? That worries me
that perhaps other cc-option tests are passing erroneously for certain
ppc -m32/-m64 configs?
> ---
> Cc: mpe@ellerman.id.au
> Cc: npiggin@gmail.com
> Cc: christophe.leroy@csgroup.eu
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
> arch/powerpc/kernel/vdso/Makefile | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
> index 769b62832b38..4ee7d36ce752 100644
> --- a/arch/powerpc/kernel/vdso/Makefile
> +++ b/arch/powerpc/kernel/vdso/Makefile
> @@ -16,6 +16,11 @@ ifneq ($(c-gettimeofday-y),)
> CFLAGS_vgettimeofday-32.o += -ffreestanding -fasynchronous-unwind-tables
> CFLAGS_REMOVE_vgettimeofday-32.o = $(CC_FLAGS_FTRACE)
> CFLAGS_REMOVE_vgettimeofday-32.o += -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc
> + # This flag is supported by clang for 64-bit but not 32-bit so it will cause
> + # an unused command line flag warning for this file.
> + ifdef CONFIG_CC_IS_CLANG
> + CFLAGS_REMOVE_vgettimeofday-32.o += -fno-stack-clash-protection
> + endif
> CFLAGS_vgettimeofday-64.o += -include $(c-gettimeofday-y)
> CFLAGS_vgettimeofday-64.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
> CFLAGS_vgettimeofday-64.o += $(call cc-option, -fno-stack-protector)
>
> --
> 2.39.0
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS
2023-01-09 21:58 ` Nick Desaulniers
@ 2023-01-09 22:15 ` Nathan Chancellor
2023-01-09 22:21 ` Nick Desaulniers
2023-01-09 22:23 ` Segher Boessenkool
[not found] ` <20230109222337.GM25951__25255.3859770828$1673303520$gmane$org@gate.crashing.org>
2 siblings, 1 reply; 24+ messages in thread
From: Nathan Chancellor @ 2023-01-09 22:15 UTC (permalink / raw)
To: Nick Desaulniers
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm, npiggin,
linuxppc-dev, nicolas
On Mon, Jan 09, 2023 at 01:58:32PM -0800, Nick Desaulniers wrote:
> On Wed, Jan 4, 2023 at 11:55 AM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> > warns that ASFLAGS contains '-s', which is a linking phase option, so it
> > is unused.
> >
> > clang-16: error: argument unused during compilation: '-s' [-Werror,-Wunused-command-line-argument]
> >
> > Looking at the GAS sources, '-s' is only useful when targeting Solaris
> > and it is ignored for the powerpc target so just drop the flag
> > altogether, as it is not needed.
>
> Do you have any more info where you found this? I don't see -s
> documented as an assembler flag.
> https://sourceware.org/binutils/docs/as/PowerPC_002dOpts.html
> https://sourceware.org/binutils/docs/as/Invoking.html
Sure thing, sorry I did not include it initially. See the section from
line 1284 to 1291 or search for "case 's':":
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gas/config/tc-ppc.c;h=9450fa74de1b61542c9a18babf8c8f621ef904fb;hb=HEAD
> The patch seems fine to me, but what was this ever supposed to be?
> FWICT it predates git history (looking at
> arch/powerpc/kernel/vdso32/Makefile at fc15351d9d63)
Right, I could not figure it out either, it has been there since the
vDSO was introduced back in 2005 (I was three days away from 10!) and
there is no comment about it so *shrug*:
https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=054eb7153aeb84cc92da84210cf93b0e2a34811b
If someone else's archeological skills are better and can provide more
information, I am happy to include that.
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Thanks as always for the review! I'll include this and a note about
where in binutils I found that information for v2.
> >
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> > Cc: mpe@ellerman.id.au
> > Cc: npiggin@gmail.com
> > Cc: christophe.leroy@csgroup.eu
> > Cc: linuxppc-dev@lists.ozlabs.org
> > ---
> > arch/powerpc/kernel/vdso/Makefile | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
> > index 6a977b0d8ffc..45c0cc5d34b6 100644
> > --- a/arch/powerpc/kernel/vdso/Makefile
> > +++ b/arch/powerpc/kernel/vdso/Makefile
> > @@ -51,10 +51,10 @@ ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both
> > ccflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld)
> >
> > CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32
> > -AS32FLAGS := -D__VDSO32__ -s
> > +AS32FLAGS := -D__VDSO32__
> >
> > CC64FLAGS := -Wl,-soname=linux-vdso64.so.1
> > -AS64FLAGS := -D__VDSO64__ -s
> > +AS64FLAGS := -D__VDSO64__
> >
> > targets += vdso32.lds
> > CPPFLAGS_vdso32.lds += -P -C -Upowerpc
> >
> > --
> > 2.39.0
>
>
>
> --
> Thanks,
> ~Nick Desaulniers
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 07/14] powerpc/vdso: Improve linker flags
2023-01-09 22:08 ` Nick Desaulniers
@ 2023-01-09 22:15 ` Nathan Chancellor
0 siblings, 0 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-01-09 22:15 UTC (permalink / raw)
To: Nick Desaulniers
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm, npiggin,
linuxppc-dev, nicolas
On Mon, Jan 09, 2023 at 02:08:41PM -0800, Nick Desaulniers wrote:
> On Wed, Jan 4, 2023 at 11:55 AM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, there
> > are several warnings in the PowerPC vDSO:
> >
> > clang-16: error: -Wl,-soname=linux-vdso32.so.1: 'linker' input unused [-Werror,-Wunused-command-line-argument]
> > clang-16: error: -Wl,--hash-style=both: 'linker' input unused [-Werror,-Wunused-command-line-argument]
> > clang-16: error: argument unused during compilation: '-shared' [-Werror,-Wunused-command-line-argument]
> >
> > clang-16: error: argument unused during compilation: '-nostdinc' [-Werror,-Wunused-command-line-argument]
> > clang-16: error: argument unused during compilation: '-Wa,-maltivec' [-Werror,-Wunused-command-line-argument]
> >
> > The first group of warnings point out that linker flags were being added
> > to all invocations of $(CC), even though they will only be used during
> > the final vDSO link. Move those flags to ldflags-y.
> >
> > The second group of warnings are compiler or assembler flags that will
> > be unused during linking. Filter them out from KBUILD_CFLAGS so that
> > they are not used during linking.
> >
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> > Cc: mpe@ellerman.id.au
> > Cc: npiggin@gmail.com
> > Cc: christophe.leroy@csgroup.eu
> > Cc: linuxppc-dev@lists.ozlabs.org
> > ---
> > arch/powerpc/kernel/vdso/Makefile | 18 +++++++++++-------
> > 1 file changed, 11 insertions(+), 7 deletions(-)
> >
> > diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
> > index 45c0cc5d34b6..769b62832b38 100644
> > --- a/arch/powerpc/kernel/vdso/Makefile
> > +++ b/arch/powerpc/kernel/vdso/Makefile
> > @@ -47,13 +47,17 @@ KCOV_INSTRUMENT := n
> > UBSAN_SANITIZE := n
> > KASAN_SANITIZE := n
> >
> > -ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both
> > -ccflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld)
> > -
> > -CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32
> > +ccflags-y := -fno-common -fno-builtin
> > +ldflags-y := -Wl,--hash-style=both -nostdlib -shared
> > +ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld)
> > +# Filter flags that clang will warn are unused for linking
> > +ldflags-y += $(filter-out $(CC_FLAGS_FTRACE) -Wa$(comma)%, $(KBUILD_CFLAGS))
> > +
> > +CC32FLAGS := -m32
> > +LD32FLAGS := -Wl,-soname=linux-vdso32.so.1
> > AS32FLAGS := -D__VDSO32__
> >
> > -CC64FLAGS := -Wl,-soname=linux-vdso64.so.1
> > +LD64FLAGS := -Wl,-soname=linux-vdso64.so.1
> > AS64FLAGS := -D__VDSO64__
> >
> > targets += vdso32.lds
> > @@ -92,14 +96,14 @@ include/generated/vdso64-offsets.h: $(obj)/vdso64.so.dbg FORCE
> >
> > # actual build commands
> > quiet_cmd_vdso32ld_and_check = VDSO32L $@
> > - cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
> > + cmd_vdso32ld_and_check = $(VDSOCC) $(ldflags-y) $(CC32FLAGS) $(LD32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
> > quiet_cmd_vdso32as = VDSO32A $@
> > cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $<
> > quiet_cmd_vdso32cc = VDSO32C $@
> > cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $<
> >
> > quiet_cmd_vdso64ld_and_check = VDSO64L $@
> > - cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
> > + cmd_vdso64ld_and_check = $(VDSOCC) $(ldflags-y) $(CC64FLAGS) $(LD64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
>
> Let's move `-z noexecstack` up into ldflags-y? (you may add my RB with
> that modification)
Ack, done locally, will be included in v2.
> > quiet_cmd_vdso64as = VDSO64A $@
> > cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $<
> >
> >
> > --
> > 2.39.0
>
>
>
> --
> Thanks,
> ~Nick Desaulniers
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS
2023-01-09 22:15 ` Nathan Chancellor
@ 2023-01-09 22:21 ` Nick Desaulniers
0 siblings, 0 replies; 24+ messages in thread
From: Nick Desaulniers @ 2023-01-09 22:21 UTC (permalink / raw)
To: Nathan Chancellor
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm, npiggin,
linuxppc-dev, nicolas
On Mon, Jan 9, 2023 at 2:15 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Mon, Jan 09, 2023 at 01:58:32PM -0800, Nick Desaulniers wrote:
> > On Wed, Jan 4, 2023 at 11:55 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > >
> > > When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> > > warns that ASFLAGS contains '-s', which is a linking phase option, so it
> > > is unused.
> > >
> > > clang-16: error: argument unused during compilation: '-s' [-Werror,-Wunused-command-line-argument]
> > >
> > > Looking at the GAS sources, '-s' is only useful when targeting Solaris
> > > and it is ignored for the powerpc target so just drop the flag
> > > altogether, as it is not needed.
> >
> > Do you have any more info where you found this? I don't see -s
> > documented as an assembler flag.
> > https://sourceware.org/binutils/docs/as/PowerPC_002dOpts.html
> > https://sourceware.org/binutils/docs/as/Invoking.html
>
> Sure thing, sorry I did not include it initially. See the section from
> line 1284 to 1291 or search for "case 's':":
>
> https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gas/config/tc-ppc.c;h=9450fa74de1b61542c9a18babf8c8f621ef904fb;hb=HEAD
>
> > The patch seems fine to me, but what was this ever supposed to be?
> > FWICT it predates git history (looking at
> > arch/powerpc/kernel/vdso32/Makefile at fc15351d9d63)
>
> Right, I could not figure it out either, it has been there since the
> vDSO was introduced back in 2005 (I was three days away from 10!) and
> there is no comment about it so *shrug*:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=054eb7153aeb84cc92da84210cf93b0e2a34811b
>
> If someone else's archeological skills are better and can provide more
> information, I am happy to include that.
>
> > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>
> Thanks as always for the review! I'll include this and a note about
> where in binutils I found that information for v2.
Yeah, I think the comment from binutils sources would be good to add
to a v2 commit message. Thanks!
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS
2023-01-09 21:58 ` Nick Desaulniers
2023-01-09 22:15 ` Nathan Chancellor
@ 2023-01-09 22:23 ` Segher Boessenkool
2023-01-09 22:37 ` Nathan Chancellor
2023-01-09 23:14 ` Nick Desaulniers
[not found] ` <20230109222337.GM25951__25255.3859770828$1673303520$gmane$org@gate.crashing.org>
2 siblings, 2 replies; 24+ messages in thread
From: Segher Boessenkool @ 2023-01-09 22:23 UTC (permalink / raw)
To: Nick Desaulniers
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm, npiggin,
Nathan Chancellor, linuxppc-dev, nicolas
Hi! Happy new year all.
On Mon, Jan 09, 2023 at 01:58:32PM -0800, Nick Desaulniers wrote:
> On Wed, Jan 4, 2023 at 11:55 AM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> > warns that ASFLAGS contains '-s', which is a linking phase option, so it
> > is unused.
> >
> > clang-16: error: argument unused during compilation: '-s' [-Werror,-Wunused-command-line-argument]
> >
> > Looking at the GAS sources, '-s' is only useful when targeting Solaris
> > and it is ignored for the powerpc target so just drop the flag
> > altogether, as it is not needed.
>
> Do you have any more info where you found this? I don't see -s
> documented as an assembler flag.
> https://sourceware.org/binutils/docs/as/PowerPC_002dOpts.html
> https://sourceware.org/binutils/docs/as/Invoking.html
It is required by POSIX (for the c99 command, anyway). It *also* is
required to be supported when producing object files (so when no linking
is done).
It is a GCC flag, and documented just fine:
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-s
(Yes, that says it is for linking; but the option is allowed without
error of any kind always).
(ASFLAGS sounds like it is for assembler commands, but it really is
for compiler commands that just happen to get .S input files).
> The patch seems fine to me, but what was this ever supposed to be?
> FWICT it predates git history (looking at
> arch/powerpc/kernel/vdso32/Makefile at fc15351d9d63)
Yeah, good question. This compiler flag does the moral equivalent of
strip -s (aka --strip-all). Maybe this was needed at some point, or
the symbol or debug info was just annoying (during bringup or similar)?
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Segher Boessenkool <segher@kernel.crashing.org>
Segher
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS
2023-01-09 22:23 ` Segher Boessenkool
@ 2023-01-09 22:37 ` Nathan Chancellor
2023-01-09 22:47 ` Segher Boessenkool
2023-01-09 23:14 ` Nick Desaulniers
1 sibling, 1 reply; 24+ messages in thread
From: Nathan Chancellor @ 2023-01-09 22:37 UTC (permalink / raw)
To: Segher Boessenkool
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm,
Nick Desaulniers, npiggin, linuxppc-dev, nicolas
On Mon, Jan 09, 2023 at 04:23:37PM -0600, Segher Boessenkool wrote:
> Hi! Happy new year all.
>
> On Mon, Jan 09, 2023 at 01:58:32PM -0800, Nick Desaulniers wrote:
> > On Wed, Jan 4, 2023 at 11:55 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > >
> > > When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> > > warns that ASFLAGS contains '-s', which is a linking phase option, so it
> > > is unused.
> > >
> > > clang-16: error: argument unused during compilation: '-s' [-Werror,-Wunused-command-line-argument]
> > >
> > > Looking at the GAS sources, '-s' is only useful when targeting Solaris
> > > and it is ignored for the powerpc target so just drop the flag
> > > altogether, as it is not needed.
> >
> > Do you have any more info where you found this? I don't see -s
> > documented as an assembler flag.
> > https://sourceware.org/binutils/docs/as/PowerPC_002dOpts.html
> > https://sourceware.org/binutils/docs/as/Invoking.html
>
> It is required by POSIX (for the c99 command, anyway). It *also* is
> required to be supported when producing object files (so when no linking
> is done).
>
> It is a GCC flag, and documented just fine:
> https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-s
>
> (Yes, that says it is for linking; but the option is allowed without
> error of any kind always).
>
> (ASFLAGS sounds like it is for assembler commands, but it really is
> for compiler commands that just happen to get .S input files).
>
> > The patch seems fine to me, but what was this ever supposed to be?
> > FWICT it predates git history (looking at
> > arch/powerpc/kernel/vdso32/Makefile at fc15351d9d63)
>
> Yeah, good question. This compiler flag does the moral equivalent of
> strip -s (aka --strip-all). Maybe this was needed at some point, or
> the symbol or debug info was just annoying (during bringup or similar)?
>
> > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> Reviewed-by: Segher Boessenkool <segher@kernel.crashing.org>
Thank you for the review and extra explanation! I had kind of expanded
on this in the s390 version of this patch [1], I will go ahead and do
the same thing for the powerpc version too.
[1]: https://lore.kernel.org/llvm/20221228-drop-qunused-arguments-v1-9-658cbc8fc592@kernel.org/
Cheers,
Nathan
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 08/14] powerpc/vdso: Remove an unsupported flag from vgettimeofday-32.o with clang
2023-01-09 22:12 ` Nick Desaulniers
@ 2023-01-09 22:38 ` Nathan Chancellor
2023-01-09 23:16 ` Nick Desaulniers
0 siblings, 1 reply; 24+ messages in thread
From: Nathan Chancellor @ 2023-01-09 22:38 UTC (permalink / raw)
To: Nick Desaulniers
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm, npiggin,
linuxppc-dev, nicolas
On Mon, Jan 09, 2023 at 02:12:55PM -0800, Nick Desaulniers wrote:
> On Wed, Jan 4, 2023 at 11:55 AM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> > warns:
> >
> > clang-16: error: argument unused during compilation: '-fno-stack-clash-protection' [-Werror,-Wunused-command-line-argument]
> >
> > This flag is supported for 64-bit powerpc but not 32-bit, hence the warning.
> > Just remove the flag from vgettimeofday-32.o's CFLAGS when using clang, as has
> > been done for other flags previously.
> >
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>
> Hmm...so this was added by the top level Makefile doing a cc-option
> test. How did the test pass if this was unsupported? That worries me
> that perhaps other cc-option tests are passing erroneously for certain
> ppc -m32/-m64 configs?
Sure, that is a reasonable concern. I should have expanded upon this a
little bit more in the commit message. Is this any better?
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
warns:
clang-16: error: argument unused during compilation: '-fno-stack-clash-protection' [-Werror,-Wunused-command-line-argument]
This warning happens because vgettimeofday-32.c gets its base CFLAGS
from the main kernel, which may contain flags that are only supported
on a 64-bit target but not a 32-bit one, which is the case here.
-fstack-clash-protection and its negation are only suppported by the
64-bit powerpc target but that flag is included in an invocation for a
32-bit powerpc target, so clang points out that while the flag is one
that it recognizes, it is not actually used by this compiler job.
To eliminate the warning, remove -fno-stack-clash-protection from
vgettimeofday-32.c's CFLAGS when using clang, as has been done for
other flags previously.
Cheers,
Nathan
> > ---
> > Cc: mpe@ellerman.id.au
> > Cc: npiggin@gmail.com
> > Cc: christophe.leroy@csgroup.eu
> > Cc: linuxppc-dev@lists.ozlabs.org
> > ---
> > arch/powerpc/kernel/vdso/Makefile | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
> > index 769b62832b38..4ee7d36ce752 100644
> > --- a/arch/powerpc/kernel/vdso/Makefile
> > +++ b/arch/powerpc/kernel/vdso/Makefile
> > @@ -16,6 +16,11 @@ ifneq ($(c-gettimeofday-y),)
> > CFLAGS_vgettimeofday-32.o += -ffreestanding -fasynchronous-unwind-tables
> > CFLAGS_REMOVE_vgettimeofday-32.o = $(CC_FLAGS_FTRACE)
> > CFLAGS_REMOVE_vgettimeofday-32.o += -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc
> > + # This flag is supported by clang for 64-bit but not 32-bit so it will cause
> > + # an unused command line flag warning for this file.
> > + ifdef CONFIG_CC_IS_CLANG
> > + CFLAGS_REMOVE_vgettimeofday-32.o += -fno-stack-clash-protection
> > + endif
> > CFLAGS_vgettimeofday-64.o += -include $(c-gettimeofday-y)
> > CFLAGS_vgettimeofday-64.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
> > CFLAGS_vgettimeofday-64.o += $(call cc-option, -fno-stack-protector)
> >
> > --
> > 2.39.0
>
>
>
> --
> Thanks,
> ~Nick Desaulniers
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS
2023-01-09 22:37 ` Nathan Chancellor
@ 2023-01-09 22:47 ` Segher Boessenkool
0 siblings, 0 replies; 24+ messages in thread
From: Segher Boessenkool @ 2023-01-09 22:47 UTC (permalink / raw)
To: Nathan Chancellor
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm,
Nick Desaulniers, npiggin, linuxppc-dev, nicolas
On Mon, Jan 09, 2023 at 03:37:53PM -0700, Nathan Chancellor wrote:
> On Mon, Jan 09, 2023 at 04:23:37PM -0600, Segher Boessenkool wrote:
> > Hi! Happy new year all.
> >
> > On Mon, Jan 09, 2023 at 01:58:32PM -0800, Nick Desaulniers wrote:
> > > On Wed, Jan 4, 2023 at 11:55 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > > >
> > > > When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> > > > warns that ASFLAGS contains '-s', which is a linking phase option, so it
> > > > is unused.
> > > >
> > > > clang-16: error: argument unused during compilation: '-s' [-Werror,-Wunused-command-line-argument]
> > > >
> > > > Looking at the GAS sources, '-s' is only useful when targeting Solaris
> > > > and it is ignored for the powerpc target so just drop the flag
> > > > altogether, as it is not needed.
> > >
> > > Do you have any more info where you found this? I don't see -s
> > > documented as an assembler flag.
> > > https://sourceware.org/binutils/docs/as/PowerPC_002dOpts.html
> > > https://sourceware.org/binutils/docs/as/Invoking.html
> >
> > It is required by POSIX (for the c99 command, anyway). It *also* is
> > required to be supported when producing object files (so when no linking
> > is done).
> >
> > It is a GCC flag, and documented just fine:
> > https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-s
> >
> > (Yes, that says it is for linking; but the option is allowed without
> > error of any kind always).
> >
> > (ASFLAGS sounds like it is for assembler commands, but it really is
> > for compiler commands that just happen to get .S input files).
> >
> > > The patch seems fine to me, but what was this ever supposed to be?
> > > FWICT it predates git history (looking at
> > > arch/powerpc/kernel/vdso32/Makefile at fc15351d9d63)
> >
> > Yeah, good question. This compiler flag does the moral equivalent of
> > strip -s (aka --strip-all). Maybe this was needed at some point, or
> > the symbol or debug info was just annoying (during bringup or similar)?
> >
> > > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> > Reviewed-by: Segher Boessenkool <segher@kernel.crashing.org>
>
> Thank you for the review and extra explanation! I had kind of expanded
> on this in the s390 version of this patch [1], I will go ahead and do
> the same thing for the powerpc version too.
>
> [1]: https://lore.kernel.org/llvm/20221228-drop-qunused-arguments-v1-9-658cbc8fc592@kernel.org/
The underwhelming GCC source code for this is
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/gcc.cc;h=d629ca5e424ad3120be13e82b9f38b7bf8f1cdf2;hb=HEAD#l1148
which says that the -s flag is passed through unmodified to the linker
when invoking the linker. See #l603 for the %{s} specs syntax.
This is not a flag to the assembler at all. It is a flag to the
compiler, which passes it on to the linker :-)
> > (ASFLAGS sounds like it is for assembler commands, but it really is
> > for compiler commands that just happen to get .S input files).
Segher
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS
2023-01-09 22:23 ` Segher Boessenkool
2023-01-09 22:37 ` Nathan Chancellor
@ 2023-01-09 23:14 ` Nick Desaulniers
2023-01-10 0:51 ` Nathan Chancellor
1 sibling, 1 reply; 24+ messages in thread
From: Nick Desaulniers @ 2023-01-09 23:14 UTC (permalink / raw)
To: Segher Boessenkool, Nathan Chancellor
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm, npiggin,
linuxppc-dev, nicolas
On Mon, Jan 9, 2023 at 2:29 PM Segher Boessenkool
<segher@kernel.crashing.org> wrote:
>
> Hi! Happy new year all.
HNY Segher! :)
>
> On Mon, Jan 09, 2023 at 01:58:32PM -0800, Nick Desaulniers wrote:
> > On Wed, Jan 4, 2023 at 11:55 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > >
> > > When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> > > warns that ASFLAGS contains '-s', which is a linking phase option, so it
> > > is unused.
> > >
> > > clang-16: error: argument unused during compilation: '-s' [-Werror,-Wunused-command-line-argument]
> > >
> > > Looking at the GAS sources, '-s' is only useful when targeting Solaris
> > > and it is ignored for the powerpc target so just drop the flag
> > > altogether, as it is not needed.
> >
> > Do you have any more info where you found this? I don't see -s
> > documented as an assembler flag.
> > https://sourceware.org/binutils/docs/as/PowerPC_002dOpts.html
> > https://sourceware.org/binutils/docs/as/Invoking.html
>
> It is required by POSIX (for the c99 command, anyway). It *also* is
> required to be supported when producing object files (so when no linking
> is done).
>
> It is a GCC flag, and documented just fine:
> https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-s
>
> (Yes, that says it is for linking; but the option is allowed without
> error of any kind always).
>
> (ASFLAGS sounds like it is for assembler commands, but it really is
> for compiler commands that just happen to get .S input files).
>
> > The patch seems fine to me, but what was this ever supposed to be?
> > FWICT it predates git history (looking at
> > arch/powerpc/kernel/vdso32/Makefile at fc15351d9d63)
>
> Yeah, good question. This compiler flag does the moral equivalent of
> strip -s (aka --strip-all). Maybe this was needed at some point, or
> the symbol or debug info was just annoying (during bringup or similar)?
Ah right! Ok then, I think we might keep the patch's diff, but update
the commit message to mention this is a linker flag that's unused
since the compiler is being invoked but not the linker (the compiler
is being used as the driver to assemble a single assembler source
without linking it; linking is then driven by the linker in a separate
make rule).
Then we might want to revisit that s390 patch, too?
https://lore.kernel.org/llvm/20221228-drop-qunused-arguments-v1-9-658cbc8fc592@kernel.org/
>
> > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> Reviewed-by: Segher Boessenkool <segher@kernel.crashing.org>
>
>
> Segher
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 08/14] powerpc/vdso: Remove an unsupported flag from vgettimeofday-32.o with clang
2023-01-09 22:38 ` Nathan Chancellor
@ 2023-01-09 23:16 ` Nick Desaulniers
0 siblings, 0 replies; 24+ messages in thread
From: Nick Desaulniers @ 2023-01-09 23:16 UTC (permalink / raw)
To: Nathan Chancellor
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm, npiggin,
linuxppc-dev, nicolas
On Mon, Jan 9, 2023 at 2:38 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Mon, Jan 09, 2023 at 02:12:55PM -0800, Nick Desaulniers wrote:
> > On Wed, Jan 4, 2023 at 11:55 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > >
> > > When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> > > warns:
> > >
> > > clang-16: error: argument unused during compilation: '-fno-stack-clash-protection' [-Werror,-Wunused-command-line-argument]
> > >
> > > This flag is supported for 64-bit powerpc but not 32-bit, hence the warning.
> > > Just remove the flag from vgettimeofday-32.o's CFLAGS when using clang, as has
> > > been done for other flags previously.
> > >
> > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> >
> > Hmm...so this was added by the top level Makefile doing a cc-option
> > test. How did the test pass if this was unsupported? That worries me
> > that perhaps other cc-option tests are passing erroneously for certain
> > ppc -m32/-m64 configs?
>
> Sure, that is a reasonable concern. I should have expanded upon this a
> little bit more in the commit message. Is this any better?
>
> When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> warns:
>
> clang-16: error: argument unused during compilation: '-fno-stack-clash-protection' [-Werror,-Wunused-command-line-argument]
>
> This warning happens because vgettimeofday-32.c gets its base CFLAGS
> from the main kernel, which may contain flags that are only supported
> on a 64-bit target but not a 32-bit one, which is the case here.
> -fstack-clash-protection and its negation are only suppported by the
> 64-bit powerpc target but that flag is included in an invocation for a
> 32-bit powerpc target, so clang points out that while the flag is one
> that it recognizes, it is not actually used by this compiler job.
>
> To eliminate the warning, remove -fno-stack-clash-protection from
> vgettimeofday-32.c's CFLAGS when using clang, as has been done for
> other flags previously.
Ah, ok that makes more sense. Sorry for my confusion, but if you
wouldn't mind adding the additional info in v3 it might help others
(or just me!)
You may add my RB to such a v3 w/ updated commit message.
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS
[not found] ` <20230109222337.GM25951__25255.3859770828$1673303520$gmane$org@gate.crashing.org>
@ 2023-01-10 0:22 ` Andreas Schwab
2023-01-10 0:43 ` Segher Boessenkool
0 siblings, 1 reply; 24+ messages in thread
From: Andreas Schwab @ 2023-01-10 0:22 UTC (permalink / raw)
To: Segher Boessenkool
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm,
Nick Desaulniers, npiggin, Nathan Chancellor, linuxppc-dev,
nicolas
On Jan 09 2023, Segher Boessenkool wrote:
> It is required by POSIX (for the c99 command, anyway). It *also* is
> required to be supported when producing object files (so when no linking
> is done).
>
> It is a GCC flag, and documented just fine:
> https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-s
Most assembler flags are unrelated to the flags passed to the compiler
driver, and -s is no exception. POSIX has nothing to say about the
sub-commands of the compiler anyway.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS
2023-01-10 0:22 ` Andreas Schwab
@ 2023-01-10 0:43 ` Segher Boessenkool
0 siblings, 0 replies; 24+ messages in thread
From: Segher Boessenkool @ 2023-01-10 0:43 UTC (permalink / raw)
To: Andreas Schwab
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm,
Nick Desaulniers, npiggin, Nathan Chancellor, linuxppc-dev,
nicolas
On Tue, Jan 10, 2023 at 01:22:38AM +0100, Andreas Schwab wrote:
> On Jan 09 2023, Segher Boessenkool wrote:
>
> > It is required by POSIX (for the c99 command, anyway). It *also* is
> > required to be supported when producing object files (so when no linking
> > is done).
> >
> > It is a GCC flag, and documented just fine:
> > https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-s
>
> Most assembler flags are unrelated to the flags passed to the compiler
> driver, and -s is no exception. POSIX has nothing to say about the
> sub-commands of the compiler anyway.
But this is not an assembler flag!
quiet_cmd_vdso32as = VDSO32A $@
cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $<
where
ifdef CROSS32_COMPILE
VDSOCC := $(CROSS32_COMPILE)gcc
else
VDSOCC := $(CC)
endif
The name of the make variable AS32FLAGS is a bit misleading. This
variable does not hold arguments to as, it holds arguments to the
compiler driver, "gcc".
Segher
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS
2023-01-09 23:14 ` Nick Desaulniers
@ 2023-01-10 0:51 ` Nathan Chancellor
2023-01-10 11:45 ` Segher Boessenkool
0 siblings, 1 reply; 24+ messages in thread
From: Nathan Chancellor @ 2023-01-10 0:51 UTC (permalink / raw)
To: Nick Desaulniers
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm, npiggin,
linuxppc-dev, nicolas
On Mon, Jan 09, 2023 at 03:14:33PM -0800, Nick Desaulniers wrote:
> On Mon, Jan 9, 2023 at 2:29 PM Segher Boessenkool
> <segher@kernel.crashing.org> wrote:
> >
> > Hi! Happy new year all.
>
> HNY Segher! :)
>
> >
> > On Mon, Jan 09, 2023 at 01:58:32PM -0800, Nick Desaulniers wrote:
> > > On Wed, Jan 4, 2023 at 11:55 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > > >
> > > > When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> > > > warns that ASFLAGS contains '-s', which is a linking phase option, so it
> > > > is unused.
> > > >
> > > > clang-16: error: argument unused during compilation: '-s' [-Werror,-Wunused-command-line-argument]
> > > >
> > > > Looking at the GAS sources, '-s' is only useful when targeting Solaris
> > > > and it is ignored for the powerpc target so just drop the flag
> > > > altogether, as it is not needed.
> > >
> > > Do you have any more info where you found this? I don't see -s
> > > documented as an assembler flag.
> > > https://sourceware.org/binutils/docs/as/PowerPC_002dOpts.html
> > > https://sourceware.org/binutils/docs/as/Invoking.html
> >
> > It is required by POSIX (for the c99 command, anyway). It *also* is
> > required to be supported when producing object files (so when no linking
> > is done).
> >
> > It is a GCC flag, and documented just fine:
> > https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-s
> >
> > (Yes, that says it is for linking; but the option is allowed without
> > error of any kind always).
> >
> > (ASFLAGS sounds like it is for assembler commands, but it really is
> > for compiler commands that just happen to get .S input files).
> >
> > > The patch seems fine to me, but what was this ever supposed to be?
> > > FWICT it predates git history (looking at
> > > arch/powerpc/kernel/vdso32/Makefile at fc15351d9d63)
> >
> > Yeah, good question. This compiler flag does the moral equivalent of
> > strip -s (aka --strip-all). Maybe this was needed at some point, or
> > the symbol or debug info was just annoying (during bringup or similar)?
>
> Ah right! Ok then, I think we might keep the patch's diff, but update
> the commit message to mention this is a linker flag that's unused
> since the compiler is being invoked but not the linker (the compiler
> is being used as the driver to assemble a single assembler source
> without linking it; linking is then driven by the linker in a separate
> make rule).
Yes, sorry, I thought that was clear with the "which is a linking phase
option" comment in the commit message but clearly not :)
> Then we might want to revisit that s390 patch, too?
> https://lore.kernel.org/llvm/20221228-drop-qunused-arguments-v1-9-658cbc8fc592@kernel.org/
So for this patch, I have
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
warns:
clang-16: error: argument unused during compilation: '-s' [-Werror,-Wunused-command-line-argument]
The compiler's '-s' flag is a linking option (it is passed along to the
linker directly), which means it does nothing when the linker is not
invoked by the compiler. The kernel builds all .o files with either '-c'
or '-S', which do not run the linker, so '-s' can be safely dropped from
ASFLAGS.
as a new commit message. Is that sufficient for everyone? If so, I'll
adjust the s390 commit to match, as it is the same exact problem.
Alternatively, if '-s' should actually remain around, we could move it
to ldflags-y, which is added in patch 7. However, I assume that nobody
has noticed that it has not been doing its job for a while, so it should
be safe to remove.
Cheers,
Nathan
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS
2023-01-10 0:51 ` Nathan Chancellor
@ 2023-01-10 11:45 ` Segher Boessenkool
2023-01-10 15:02 ` Nathan Chancellor
0 siblings, 1 reply; 24+ messages in thread
From: Segher Boessenkool @ 2023-01-10 11:45 UTC (permalink / raw)
To: Nathan Chancellor
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm,
Nick Desaulniers, npiggin, linuxppc-dev, nicolas
On Mon, Jan 09, 2023 at 05:51:23PM -0700, Nathan Chancellor wrote:
> So for this patch, I have
>
> When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> warns:
>
> clang-16: error: argument unused during compilation: '-s' [-Werror,-Wunused-command-line-argument]
>
> The compiler's '-s' flag is a linking option (it is passed along to the
> linker directly), which means it does nothing when the linker is not
> invoked by the compiler. The kernel builds all .o files with either '-c'
> or '-S', which do not run the linker, so '-s' can be safely dropped from
> ASFLAGS.
>
> as a new commit message. Is that sufficient for everyone? If so, I'll
> adjust the s390 commit to match, as it is the same exact problem.
Almost? -S doesn't write .o files, it writes a .s file. To go from an
assembler file (.s, or .S if you want to run the C preprocessor on non-C
code for some strange reason, the assembler macro facilities are vastly
superior) to an object file is just -c as well.
> Alternatively, if '-s' should actually remain around, we could move it
> to ldflags-y, which is added in patch 7. However, I assume that nobody
> has noticed that it has not been doing its job for a while, so it should
> be safe to remove.
+1
Segher
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS
2023-01-10 11:45 ` Segher Boessenkool
@ 2023-01-10 15:02 ` Nathan Chancellor
0 siblings, 0 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-01-10 15:02 UTC (permalink / raw)
To: Segher Boessenkool
Cc: kernel test robot, linux-kbuild, trix, masahiroy, llvm,
Nick Desaulniers, npiggin, linuxppc-dev, nicolas
On Tue, Jan 10, 2023 at 05:45:23AM -0600, Segher Boessenkool wrote:
> On Mon, Jan 09, 2023 at 05:51:23PM -0700, Nathan Chancellor wrote:
> > So for this patch, I have
> >
> > When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it
> > warns:
> >
> > clang-16: error: argument unused during compilation: '-s' [-Werror,-Wunused-command-line-argument]
> >
> > The compiler's '-s' flag is a linking option (it is passed along to the
> > linker directly), which means it does nothing when the linker is not
> > invoked by the compiler. The kernel builds all .o files with either '-c'
> > or '-S', which do not run the linker, so '-s' can be safely dropped from
> > ASFLAGS.
> >
> > as a new commit message. Is that sufficient for everyone? If so, I'll
> > adjust the s390 commit to match, as it is the same exact problem.
>
> Almost? -S doesn't write .o files, it writes a .s file. To go from an
> assembler file (.s, or .S if you want to run the C preprocessor on non-C
> code for some strange reason, the assembler macro facilities are vastly
> superior) to an object file is just -c as well.
Heh, right, that is what I get for not paying attention and rushing at
the end of my day :) thanks for being pendantic, I will get that ironed
out for v2, which I should have out later today or tomorrow, time
permitting.
Cheers,
Nathan
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2023-01-10 15:03 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-04 19:54 [PATCH 00/14] Remove clang's -Qunused-arguments from KBUILD_CPPFLAGS Nathan Chancellor
2023-01-04 19:54 ` [PATCH 05/14] powerpc: Remove linker flag from KBUILD_AFLAGS Nathan Chancellor
2023-01-09 21:24 ` Nick Desaulniers
2023-01-04 19:54 ` [PATCH 06/14] powerpc/vdso: Remove unused '-s' flag from ASFLAGS Nathan Chancellor
2023-01-09 21:58 ` Nick Desaulniers
2023-01-09 22:15 ` Nathan Chancellor
2023-01-09 22:21 ` Nick Desaulniers
2023-01-09 22:23 ` Segher Boessenkool
2023-01-09 22:37 ` Nathan Chancellor
2023-01-09 22:47 ` Segher Boessenkool
2023-01-09 23:14 ` Nick Desaulniers
2023-01-10 0:51 ` Nathan Chancellor
2023-01-10 11:45 ` Segher Boessenkool
2023-01-10 15:02 ` Nathan Chancellor
[not found] ` <20230109222337.GM25951__25255.3859770828$1673303520$gmane$org@gate.crashing.org>
2023-01-10 0:22 ` Andreas Schwab
2023-01-10 0:43 ` Segher Boessenkool
2023-01-04 19:54 ` [PATCH 07/14] powerpc/vdso: Improve linker flags Nathan Chancellor
2023-01-09 22:08 ` Nick Desaulniers
2023-01-09 22:15 ` Nathan Chancellor
2023-01-04 19:54 ` [PATCH 08/14] powerpc/vdso: Remove an unsupported flag from vgettimeofday-32.o with clang Nathan Chancellor
2023-01-09 22:12 ` Nick Desaulniers
2023-01-09 22:38 ` Nathan Chancellor
2023-01-09 23:16 ` Nick Desaulniers
2023-01-05 8:00 ` [PATCH 00/14] Remove clang's -Qunused-arguments from KBUILD_CPPFLAGS Heiko Carstens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).