[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] m4/pma.m4: disable PIE in both CFLAGS and LDFLAGS consistently
From: |
Sergei Trofimovich |
Subject: |
[PATCH] m4/pma.m4: disable PIE in both CFLAGS and LDFLAGS consistently |
Date: |
Wed, 11 Jan 2023 00:02:03 +0000 |
In https://github.com/NixOS/nixpkgs/pull/207478#issuecomment-1378021841
Alyssa noticed that gawk build fails on x86_64-unknown-linux-musl target
in nixpkgs as:
ld: .../x86_64-unknown-linux-musl/11.3.0/crtbegin.o:
relocation R_X86_64_32 against hidden symbol `__TMC_END__'
can not be used when making a PIE object
ld: failed to set dynamic section sizes: bad value
This happens because both compiler (CFLAGS=-fPIE) and linker
(LDFLAGS=-pie) enable PIE by default.
As a result just disabling linker flag is not enough and `ld`
detects unresolvable dynamic relocations for non-PIE binary.
The change disables PIE for both CFLAGS and LDFLAGS.
---
m4/pma.m4 | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/m4/pma.m4 b/m4/pma.m4
index c0535a26..73f6b316 100644
--- a/m4/pma.m4
+++ b/m4/pma.m4
@@ -19,9 +19,13 @@ then
use_persistent_malloc=yes
case $host_os in
linux-*)
+ # Guard against toolchains that default to CFLAGS=-fPIE
LDFLAGS=-pie
AX_CHECK_COMPILE_FLAG([-no-pie],
[LDFLAGS="${LDFLAGS} -no-pie"
export LDFLAGS])
+ AX_CHECK_COMPILE_FLAG([-fno-PIE],
+ [CFLAGS="${CFLAGS} -fno-PIE"
+ export CFLAGS])
;;
*darwin*)
# 27 November 2022: PMA only works on Intel.
--
2.38.1
- [PATCH] m4/pma.m4: disable PIE in both CFLAGS and LDFLAGS consistently,
Sergei Trofimovich <=