From: Jan Polensky <japo@linux.ibm.com>
To: 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, tmricht@linux.ibm.com,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] perf build: Fix Python extension build with GCC 16 hardening
Date: Wed, 20 May 2026 14:56:37 +0200 [thread overview]
Message-ID: <20260520125637.105681-1-japo@linux.ibm.com> (raw)
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; \
--
2.51.0
next reply other threads:[~2026-05-20 12:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 12:56 Jan Polensky [this message]
2026-05-20 13:09 ` [PATCH 1/1] perf build: Fix Python extension build with GCC 16 hardening sashiko-bot
2026-05-24 2:49 ` Arnaldo Carvalho de Melo
2026-05-26 10:30 ` Jan Polensky
2026-05-26 15:23 ` Ian Rogers
2026-05-26 16:20 ` Jan Polensky
2026-05-26 16:59 ` Ian Rogers
2026-05-27 18:02 ` Jan Polensky
2026-05-27 21:08 ` Namhyung Kim
2026-05-20 13:38 ` Thomas Richter
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=20260520125637.105681-1-japo@linux.ibm.com \
--to=japo@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=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 \
--cc=tmricht@linux.ibm.com \
/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