[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] m4/pma.m4: disable PIE in both CFLAGS and LDFLAGS consistent
From: |
arnold |
Subject: |
Re: [PATCH] m4/pma.m4: disable PIE in both CFLAGS and LDFLAGS consistently |
Date: |
Wed, 11 Jan 2023 00:29:17 -0700 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
Hi.
Thank you for the report. I will get this into the repo in the next
few days.
Arnold
Sergei Trofimovich <slyich@gmail.com> wrote:
> 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
>