perf s390: Fix TEXTREL in Python extension by compiling as PIC
Subsystems (2)
PATCH 1/1 perf s390: Fix TEXTREL in Python extension by compiling as PIC
On s390 the Python extension build fails as follows when using a linker that is configured to treat text relocations (TEXTREL) in shared libraries as error by default:
GEN python/perf.cpython-314-s390x-linux-gnu.so/usr/bin/ld.bfd: error: read-only segment has dynamic relocations
This occurrs because util/llvm-c-helpers.o is erroneously built from util/llvm-c-helpers.cpp without compiler option -fPIC but linked into the shared library (via libperf-util.a(perf-util-in.o)).
On s390, object files must be compiled as position-indepedent code (PIC) in order to be linked into shared libraries. Commit a9a3f1d18a6c ("perf
s390: Always build with -fPIC") added compiler option -fPIC to CFLAGS for s390, which is used in C compiles. Add -fPIC to CXXFLAGS for s390 as well, so that it is also used in C++ compiles.
---
Notes (jremus):
This patch applies on top of the perf-tools-next tree:
git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git master
Note that this resolves the issue discussed in thread "[PATCH 1/1] perf
build: Fix Python extension build with GCC 16 hardening":
https://lore.kernel.org/all/[email protected]/T/
tools/perf/Makefile.config | 1 + 1 file changed, 1 insertion(+)
tools/perf/Makefile.config +1 -0
@@ -109,6 +109,7 @@ endif ifeq ($(ARCH),s390) CFLAGS += -fPIC + CXXFLAGS += -fPIC endif ifeq ($(ARCH),mips)
Signature · 1 line
2.53.0
Quoted 38 lines · Jens Remus
On s390 the Python extension build fails as follows when using a linker that is configured to treat text relocations (TEXTREL) in shared libraries as error by default:
GEN python/perf.cpython-314-s390x-linux-gnu.so
/usr/bin/ld.bfd: error: read-only segment has dynamic relocationsThis occurrs because
util/llvm-c-helpers.ois erroneously built from util/llvm-c-helpers.cpp without compiler option -fPIC but linked into the shared library (via libperf-util.a(perf-util-in.o)).On s390, object files must be compiled as position-indepedent code (PIC) in order to be linked into shared libraries. Commit
a9a3f1d18a6c("perf
s390: Always build with -fPIC") added compiler option -fPIC to CFLAGS for s390, which is used in C compiles. Add -fPIC to CXXFLAGS for s390 as well, so that it is also used in C++ compiles.Reported-by Thomas Richter <[email protected]>Signed-off-by Jens Remus <[email protected]>---
Notes (jremus):
This patch applies on top of the perf-tools-next tree:
git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.gitmasterNote that this resolves the issue discussed in thread "[PATCH 1/1] perf
build: Fix Python extension build with GCC 16 hardening":
https://lore.kernel.org/all/[email protected]/T/tools/perf/Makefile.config | 1 + 1 file changed, 1 insertion(+)tools/perf/Makefile.config +0
-0
tools/perf/Makefile.config endif · line 115
Quoted 7 lines
tools/perf/Makefile.config +1
-0@@ -109,6 +109,7 @@ endif ifeq ($(ARCH),s390) CFLAGS += -fPIC + CXXFLAGS += -fPIC endif ifeq ($(ARCH),mips)
Quoted 15 lines · James Clark
Quoted 11 lines · Jens Remus
On s390 the Python extension build fails as follows when using a linker that is configured to treat text relocations (TEXTREL) in shared libraries as error by default:
GEN python/perf.cpython-314-s390x-linux-gnu.so
/usr/bin/ld.bfd: error: read-only segment has dynamic relocationsThis occurrs because
util/llvm-c-helpers.ois erroneously built from util/llvm-c-helpers.cpp without compiler option -fPIC but linked into the shared library (via libperf-util.a(perf-util-in.o)).
Quoted 8 lines
Quoted 8 lines
On s390, object files must be compiled as position-indepedent code (PIC) in order to be linked into shared libraries. Commit
a9a3f1d18a6c("perf
s390: Always build with -fPIC") added compiler option -fPIC to CFLAGS for s390, which is used in C compiles. Add -fPIC to CXXFLAGS for s390 as well, so that it is also used in C++ compiles.Reported-by Thomas Richter <[email protected]>Signed-off-by Jens Remus <[email protected]>
Great! Perhaps we should add a fixes tag for backports. Perhaps:
Thanks,
Ian
Quoted 29 lines
Quoted 19 lines
---
Notes (jremus):
This patch applies on top of the perf-tools-next tree:
git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.gitmasterNote that this resolves the issue discussed in thread "[PATCH 1/1] perf
build: Fix Python extension build with GCC 16 hardening":
https://lore.kernel.org/all/[email protected]/T/tools/perf/Makefile.config | 1 + 1 file changed, 1 insertion(+)tools/perf/Makefile.config +0
-0tools/perf/Makefile.config endif · line 115
Quoted 7 lines
tools/perf/Makefile.config +1
-0@@ -109,6 +109,7 @@ endif ifeq ($(ARCH),s390) CFLAGS += -fPIC + CXXFLAGS += -fPIC endif ifeq ($(ARCH),mips)Reviewed-by James Clark <[email protected]>
Quoted 10 lines · James Clark
tools/perf/Makefile.config endif · line 113
Quoted 7 lines · Jens Remus
+++
b/tools/perf/Makefile.configtools/perf/Makefile.config +1
-0@@ -109,6 +109,7 @@ endif ifeq ($(ARCH),s390) CFLAGS += -fPIC + CXXFLAGS += -fPIC endif ifeq ($(ARCH),mips)Reviewed-by James Clark <[email protected]>
Thanks, applied to perf-tools-next, for v7.2.
- Arnaldo