diff mbox series

[net] selftests: net/{lib,openvswitch}: extend CFLAGS to keep options from environment

Message ID 3d173603ee258f419d0403363765c9f9494ff79a.1737635092.git.jstancek@redhat.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series [net] selftests: net/{lib,openvswitch}: extend CFLAGS to keep options from environment | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success Errors and warnings before: 26 (+1) this patch: 26 (+1)
netdev/cc_maintainers fail 1 blamed authors not CCed: willemb@google.com; 5 maintainers not CCed: dev@openvswitch.org petrm@nvidia.com willemb@google.com shuah@kernel.org horms@kernel.org
netdev/build_clang success Errors and warnings before: 47 this patch: 47
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 10 this patch: 10
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2025-01-23--15-00 (tests: 877)

Commit Message

Jan Stancek Jan. 23, 2025, 12:38 p.m. UTC
Package build environments like Fedora rpmbuild introduced hardening
options (e.g. -pie -Wl,-z,now) by passing a -spec option to CFLAGS
and LDFLAGS.

Some Makefiles currently override CFLAGS but not LDFLAGS, which leads
to a mismatch and build failure, for example:
  /usr/bin/ld: /tmp/ccd2apay.o: relocation R_X86_64_32 against
    `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
  /usr/bin/ld: failed to set dynamic section sizes: bad value
  collect2: error: ld returned 1 exit status
  make[1]: *** [../../lib.mk:222: tools/testing/selftests/net/lib/csum] Error 1

openvswitch/Makefile CFLAGS currently do not appear to be used, but
fix it anyway for the case when new tests are introduced in future.

Fixes: 1d0dc857b5d8 ("selftests: drv-net: add checksum tests")
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 tools/testing/selftests/net/lib/Makefile         | 2 +-
 tools/testing/selftests/net/openvswitch/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Matthieu Baerts Jan. 23, 2025, 12:51 p.m. UTC | #1
Hi Jan,

On 23/01/2025 13:38, Jan Stancek wrote:
> Package build environments like Fedora rpmbuild introduced hardening
> options (e.g. -pie -Wl,-z,now) by passing a -spec option to CFLAGS
> and LDFLAGS.
> 
> Some Makefiles currently override CFLAGS but not LDFLAGS, which leads
> to a mismatch and build failure, for example:
>   /usr/bin/ld: /tmp/ccd2apay.o: relocation R_X86_64_32 against
>     `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
>   /usr/bin/ld: failed to set dynamic section sizes: bad value
>   collect2: error: ld returned 1 exit status
>   make[1]: *** [../../lib.mk:222: tools/testing/selftests/net/lib/csum] Error 1

Thank you for the fix!

> openvswitch/Makefile CFLAGS currently do not appear to be used, but
> fix it anyway for the case when new tests are introduced in future.
> 
> Fixes: 1d0dc857b5d8 ("selftests: drv-net: add checksum tests")

Note that this commit is only for the Makefile in 'lib', not in
'openvswitch', but I guess there is no need to backport that all along.
Maybe the two modifications should be split, but I guess that's fine here.

> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> ---
>  tools/testing/selftests/net/lib/Makefile         | 2 +-
>  tools/testing/selftests/net/openvswitch/Makefile | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/lib/Makefile b/tools/testing/selftests/net/lib/Makefile
> index 18b9443454a9..578de40cc5e3 100644
> --- a/tools/testing/selftests/net/lib/Makefile
> +++ b/tools/testing/selftests/net/lib/Makefile
> @@ -1,6 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0
>  
> -CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g
> +CFLAGS +=  -Wall -Wl,--no-as-needed -O2 -g

(small detail: I guess the double whitespaces after the '=' were there
to keep the alignment with the next line, so probably there should be
only one now, but I don't think this alone is enough to ask for a v2!)

Apart from that:

Acked-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>

>  CFLAGS += -I../../../../../usr/include/ $(KHDR_INCLUDES)
>  # Additional include paths needed by kselftest.h
>  CFLAGS += -I../../
> diff --git a/tools/testing/selftests/net/openvswitch/Makefile b/tools/testing/selftests/net/openvswitch/Makefile
> index 2f1508abc826..1567a549ba34 100644
> --- a/tools/testing/selftests/net/openvswitch/Makefile
> +++ b/tools/testing/selftests/net/openvswitch/Makefile
> @@ -2,7 +2,7 @@
>  
>  top_srcdir = ../../../../..
>  
> -CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES)
> +CFLAGS +=  -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES)
>  
>  TEST_PROGS := openvswitch.sh
>  

Cheers,
Matt
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/lib/Makefile b/tools/testing/selftests/net/lib/Makefile
index 18b9443454a9..578de40cc5e3 100644
--- a/tools/testing/selftests/net/lib/Makefile
+++ b/tools/testing/selftests/net/lib/Makefile
@@ -1,6 +1,6 @@ 
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g
+CFLAGS +=  -Wall -Wl,--no-as-needed -O2 -g
 CFLAGS += -I../../../../../usr/include/ $(KHDR_INCLUDES)
 # Additional include paths needed by kselftest.h
 CFLAGS += -I../../
diff --git a/tools/testing/selftests/net/openvswitch/Makefile b/tools/testing/selftests/net/openvswitch/Makefile
index 2f1508abc826..1567a549ba34 100644
--- a/tools/testing/selftests/net/openvswitch/Makefile
+++ b/tools/testing/selftests/net/openvswitch/Makefile
@@ -2,7 +2,7 @@ 
 
 top_srcdir = ../../../../..
 
-CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES)
+CFLAGS +=  -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES)
 
 TEST_PROGS := openvswitch.sh