From: Thomas Richter <tmricht@linux.ibm.com>
To: Jan Polensky <japo@linux.ibm.com>,
peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
namhyung@kernel.org
Cc: mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com,
james.clark@linaro.org, linux-perf-users@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] perf build: Fix Python extension build with GCC 16 hardening
Date: Wed, 20 May 2026 15:38:48 +0200 [thread overview]
Message-ID: <26791984-36c3-441b-b48a-208c078aaf76@linux.ibm.com> (raw)
In-Reply-To: <20260520125637.105681-1-japo@linux.ibm.com>
On 5/20/26 14:56, Jan Polensky wrote:
> The Python extension build fails with modern GCC versions (16+) due to
> the new hardening feature that prevents dynamic relocations in read-only
> segments:
>
> /usr/bin/ld.bfd: error: read-only segment has dynamic relocations
> collect2: error: ld returned 1 exit status
>
> This occurs when building the perf Python bindings because the linker
> enforces stricter security policies by default.
>
> Add -Wl,-z,notext to LDSHARED to explicitly allow text relocations in
> the Python extension shared object. This is necessary for the Python
> C extension to link successfully while maintaining compatibility with
> the Python build system.
>
> The flag only affects the Python extension build and does not impact
> the security of the main perf binary or other components.
>
> Tested on Fedora 44 with GCC 16.1.1 20260501 (Red Hat 16.1.1-1) and
> Python 3.14.4 on s390x architecture.
>
> Reported-by: Thomas Richter <tmricht@linux.ibm.com>
> Signed-off-by: Jan Polensky <japo@linux.ibm.com>
> ---
> tools/perf/Makefile.perf | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index bfb37f527241..12af424dd5c1 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -749,7 +749,7 @@ all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
> $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')
>
> $(OUTPUT)python/perf$(PYTHON_EXTENSION_SUFFIX): util/python.c util/setup.py $(PERFLIBS_PY)
> - $(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
> + $(QUIET_GEN)LDSHARED="$(CC) -pthread -shared -Wl,-z,notext" \
> CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBS_PY)' \
> $(PYTHON_WORD) util/setup.py \
> --quiet build_ext; \
Thanks for fixing this.
Reviewed-by: Thomas Richter <tmricht@linux.ibm.com>
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
--
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
--
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
prev parent reply other threads:[~2026-05-20 13:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 12:56 Jan Polensky
2026-05-20 13:38 ` Thomas Richter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=26791984-36c3-441b-b48a-208c078aaf76@linux.ibm.com \
--to=tmricht@linux.ibm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=japo@linux.ibm.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®