Skip to contentSkip to conversation

tests: do not pass -flto to the compiler or linker

PATCH In review Nick Alcock 2 participants 4 messages Jan 16, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tests: do not pass -flto to the compiler or linker

We don't want to compile tests with -flto by default: if the distro compiler automatically activates it, turn it off by explicitly passing -fno-lto to all compiler and linker invocations in the testsuite.

(This is a bit fiddly because this is the first CPPFLAG which is not also a valid flag to dtrace(1) itself, so we have to split a variable up a bit.)

---
 runtest.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
runtest.sh +4 -3
index 94634f80c2ebf..1cb5be8213396 100755
@@ -589,8 +589,9 @@ else
         exit 1
     fi
 fi
-export test_cppflags
-export test_ldflags
+core_raw_dt_flags="$test_cppflags"
+export test_cppflags="$test_cppflags -fno-lto"
+export test_ldflags="$test_ldflags -fno-lto"
 export test_libdir
 
 # Figure out if the preprocessor supports -fno-diagnostics-show-option: if it
@@ -1085,7 +1086,7 @@ for dt in $dtrace; do
         # Default and substitute in flags.  The raw_dt_flags apply even to a
         # sh invocation.
 
-        raw_dt_flags="$test_cppflags"
+        raw_dt_flags="$core_raw_dt_flags"
 
         expected_tag=
         if [[ $testonly =~ ^err\.D_ ]]; then
Signature · 1 line
2.47.1.279.g84c5f4e78e
#1 lore raw

PATCH 2/2 drti: do not compile with LTO

drti.o is shipped as object code and can be reused by many compiler
versions: we must not put LTO IR into it.

---
 libdtrace/Build | 4 ++++
 1 file changed, 4 insertions(+)
libdtrace/Build +4 -0
index 722351591aaea..307d7e8bf6434 100644
@@ -122,6 +122,10 @@ dt_prov_uprobe.c_CFLAGS := -Wno-pedantic
 dt_debug.c_CFLAGS := -Wno-prio-ctor-dtor
 drti.c_CFLAGS := -Wno-prio-ctor-dtor
 
+# drti is shipped as an object file, so do not ever generate
+# LTO for it, since that is compiler-version-specific.
+drti.c_CFLAGS += -fno-lto
+
 SHORTKERNELS := $(foreach kernel,$(KERNELS),$(shell printf %s $(kernel) | sed -e 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*$$/\1.\2.\3/'))
 
 -include libdtrace/$(ARCHINC)/Build
Signature · 1 line
2.47.1.279.g84c5f4e78e
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drti: do not compile with LTO

Quoted 4 lines · Nick Alcock

drti.o is shipped as object code and can be reused by many compiler
versions: we must not put LTO IR into it.

Quoted 22 lines
---
 libdtrace/Build | 4 ++++
 1 file changed, 4 insertions(+)
libdtrace/Build +4 -0
index 722351591aaea..307d7e8bf6434 100644
@@ -122,6 +122,10 @@ dt_prov_uprobe.c_CFLAGS := -Wno-pedantic
 dt_debug.c_CFLAGS := -Wno-prio-ctor-dtor
 drti.c_CFLAGS := -Wno-prio-ctor-dtor
 
+# drti is shipped as an object file, so do not ever generate
+# LTO for it, since that is compiler-version-specific.
+drti.c_CFLAGS += -fno-lto
+
 SHORTKERNELS := $(foreach kernel,$(KERNELS),$(shell printf %s $(kernel) | sed -e 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*$$/\1.\2.\3/'))
 
 -include libdtrace/$(ARCHINC)/Build
Signature · 1 line
2.47.1.279.g84c5f4e78e
Reviewed-by on v1 1/2
#3 lore raw
In reply to Nick Alcock
Quoted 9 lines · Nick Alcock

We don't want to compile tests with -flto by default: if the distro compiler automatically activates it, turn it off by explicitly passing -fno-lto to all compiler and linker invocations in the testsuite.

(This is a bit fiddly because this is the first CPPFLAG which is not also a valid flag to dtrace(1) itself, so we have to split a variable up a bit.)

Quoted 32 lines
---
 runtest.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
runtest.sh +4 -3
index 94634f80c2ebf..1cb5be8213396 100755
@@ -589,8 +589,9 @@ else
         exit 1
     fi
 fi
-export test_cppflags
-export test_ldflags
+core_raw_dt_flags="$test_cppflags"
+export test_cppflags="$test_cppflags -fno-lto"
+export test_ldflags="$test_ldflags -fno-lto"
 export test_libdir
 
 # Figure out if the preprocessor supports -fno-diagnostics-show-option: if it
@@ -1085,7 +1086,7 @@ for dt in $dtrace; do
         # Default and substitute in flags.  The raw_dt_flags apply even to a
         # sh invocation.
 
-        raw_dt_flags="$test_cppflags"
+        raw_dt_flags="$core_raw_dt_flags"
 
         expected_tag=
         if [[ $testonly =~ ^err\.D_ ]]; then
Signature · 1 line
2.47.1.279.g84c5f4e78e