* [PATCH] perf s390: Fix TEXTREL in Python extension by compiling as PIC
@ 2026-06-10 11:24 Jens Remus
2026-06-10 13:39 ` James Clark
0 siblings, 1 reply; 4+ messages in thread
From: Jens Remus @ 2026-06-10 11:24 UTC (permalink / raw)
To: linux-s390, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, James Clark, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt, linux-perf-users,
linux-kernel, llvm
Cc: Jens Remus, Jan Polensky, Thomas Richter, Hendrik Brueckner,
Heiko Carstens
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.
Reported-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
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/ahV2XGx_6h7upuc3@li-276bd24c-2dcc-11b2-a85c-945b6f05615c.ibm.com/T/
tools/perf/Makefile.config | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 333ddd0e4bd8..33f90968c8a9 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -109,6 +109,7 @@ endif
ifeq ($(ARCH),s390)
CFLAGS += -fPIC
+ CXXFLAGS += -fPIC
endif
ifeq ($(ARCH),mips)
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] perf s390: Fix TEXTREL in Python extension by compiling as PIC
2026-06-10 11:24 [PATCH] perf s390: Fix TEXTREL in Python extension by compiling as PIC Jens Remus
@ 2026-06-10 13:39 ` James Clark
2026-06-10 16:19 ` Ian Rogers
2026-06-10 20:05 ` Arnaldo Carvalho de Melo
0 siblings, 2 replies; 4+ messages in thread
From: James Clark @ 2026-06-10 13:39 UTC (permalink / raw)
To: Jens Remus
Cc: Jan Polensky, Thomas Richter, Hendrik Brueckner, Heiko Carstens,
linux-s390, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, linux-perf-users, linux-kernel, llvm
On 10/06/2026 12:24 pm, Jens Remus wrote:
> 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.
>
> Reported-by: Thomas Richter <tmricht@linux.ibm.com>
> Signed-off-by: Jens Remus <jremus@linux.ibm.com>
> ---
>
> 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/ahV2XGx_6h7upuc3@li-276bd24c-2dcc-11b2-a85c-945b6f05615c.ibm.com/T/
>
> tools/perf/Makefile.config | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 333ddd0e4bd8..33f90968c8a9 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -109,6 +109,7 @@ endif
>
> ifeq ($(ARCH),s390)
> CFLAGS += -fPIC
> + CXXFLAGS += -fPIC
> endif
>
> ifeq ($(ARCH),mips)
Reviewed-by: James Clark <james.clark@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf s390: Fix TEXTREL in Python extension by compiling as PIC
2026-06-10 13:39 ` James Clark
@ 2026-06-10 16:19 ` Ian Rogers
2026-06-10 20:05 ` Arnaldo Carvalho de Melo
1 sibling, 0 replies; 4+ messages in thread
From: Ian Rogers @ 2026-06-10 16:19 UTC (permalink / raw)
To: James Clark
Cc: Jens Remus, Jan Polensky, Thomas Richter, Hendrik Brueckner,
Heiko Carstens, linux-s390, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Adrian Hunter, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt, linux-perf-users,
linux-kernel, llvm
On Wed, Jun 10, 2026 at 6:39 AM James Clark <james.clark@linaro.org> wrote:
>
>
>
> On 10/06/2026 12:24 pm, Jens Remus wrote:
> > 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.
> >
> > Reported-by: Thomas Richter <tmricht@linux.ibm.com>
> > Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Great! Perhaps we should add a fixes tag for backports. Perhaps:
Fixes: a9a3f1d18a6c ("perf s390: Always build with -fPIC")
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> > ---
> >
> > 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/ahV2XGx_6h7upuc3@li-276bd24c-2dcc-11b2-a85c-945b6f05615c.ibm.com/T/
> >
> > tools/perf/Makefile.config | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > index 333ddd0e4bd8..33f90968c8a9 100644
> > --- a/tools/perf/Makefile.config
> > +++ b/tools/perf/Makefile.config
> > @@ -109,6 +109,7 @@ endif
> >
> > ifeq ($(ARCH),s390)
> > CFLAGS += -fPIC
> > + CXXFLAGS += -fPIC
> > endif
> >
> > ifeq ($(ARCH),mips)
>
> Reviewed-by: James Clark <james.clark@linaro.org>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf s390: Fix TEXTREL in Python extension by compiling as PIC
2026-06-10 13:39 ` James Clark
2026-06-10 16:19 ` Ian Rogers
@ 2026-06-10 20:05 ` Arnaldo Carvalho de Melo
1 sibling, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-06-10 20:05 UTC (permalink / raw)
To: James Clark
Cc: Jens Remus, Jan Polensky, Thomas Richter, Hendrik Brueckner,
Heiko Carstens, linux-s390, Peter Zijlstra, Ingo Molnar,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, linux-perf-users, linux-kernel, llvm
On Wed, Jun 10, 2026 at 02:39:10PM +0100, James Clark wrote:
> On 10/06/2026 12:24 pm, Jens Remus wrote:
> > +++ b/tools/perf/Makefile.config
> > @@ -109,6 +109,7 @@ endif
> > ifeq ($(ARCH),s390)
> > CFLAGS += -fPIC
> > + CXXFLAGS += -fPIC
> > endif
> > ifeq ($(ARCH),mips)
>
> Reviewed-by: James Clark <james.clark@linaro.org>
Thanks, applied to perf-tools-next, for v7.2.
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-10 20:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-10 11:24 [PATCH] perf s390: Fix TEXTREL in Python extension by compiling as PIC Jens Remus
2026-06-10 13:39 ` James Clark
2026-06-10 16:19 ` Ian Rogers
2026-06-10 20:05 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox