LDFLAGS filtering in `check()` no longer works correctly
(The original title of this issue was "Pacman 6.1 makepkg.conf changes break glibc builds", but it turned out Sam had a very messed up local install caused by relentless experimentation)
Pacman 6.1 and devtools 1.1.1-1 have shipped with a change to LDFLAGS
in makepkg.conf that looks like this:
This causes the LDFLAGS filtering performed in check()
to no longer work, resulting in errors that look like this:
gcc -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl -Wl,-z,pack-relative-relocs -shared -nostdlib -nostartfiles \
-x assembler /dev/null -o /build/glibc/src/glibc-build/format.lds.so
gcc: error: unrecognized command-line option ‘-Wl’; did you mean ‘-W’?
make[2]: *** [Makerules:992: /build/glibc/src/glibc-build/format.lds] Error 1
make[2]: Leaving directory '/build/glibc/src/glibc'
make[1]: *** [Makefile:633: /build/glibc/src/glibc-build/testroot.pristine/install.stamp] Error 2
make: *** [Makefile:9: check] Error 2
Note the empty -Wl
sandwiched between -z,relro
and -z,pack-relative-relocs
Original incoherent rambling
(I'm not sure if this issue should be opened here, or on archlinux/packaging/packages/pacman ... But the issue seems specific to glibc, so here we are)
It seems that the recent changes made to LDFLAGS break glibc build.
I first ran into this a couple of days ago when trying to build newer glibc for ALARM: https://github.com/archlinuxarm/PKGBUILDs/pull/2021#issuecomment-2039157864
At the time, I just assumed this is because ALARM is still on glibc 2.35 and GCC12. But just now I've tried to build glibc on x86 and I'm seeing the same issue.
This happens during check()
:
make[3]: Entering directory '/build/glibc/src/glibc/elf'
echo '#define RUNTIME_LINKER "/usr/lib/ld-linux-x86-64.so.2"' \
> /build/glibc/src/glibc-build/runtime-linker.T
/bin/sh ../scripts/move-if-change /build/glibc/src/glibc-build/runtime-linker.T /build/glibc/src/glibc-build/runtime-linker.h
touch /build/glibc/src/glibc-build/runtime-linker.stamp
make[3]: Leaving directory '/build/glibc/src/glibc/elf'
make[2]: Entering directory '/build/glibc/src/glibc'
/usr/bin/install -c -m 644 /build/glibc/src/glibc-build/libc.a /build/glibc/src/glibc-build/testroot.pristine/usr/lib/libc.a
make[2]: Leaving directory '/build/glibc/src/glibc'
make[2]: Entering directory '/build/glibc/src/glibc'
/usr/bin/install -c -m 644 /build/glibc/src/glibc-build/libc_nonshared.a /build/glibc/src/glibc-build/testroot.pristine/usr/lib/libc_nonshared.a
make[2]: Leaving directory '/build/glibc/src/glibc'
make[2]: Entering directory '/build/glibc/src/glibc'
/usr/bin/install -c /build/glibc/src/glibc-build/libc.so /build/glibc/src/glibc-build/testroot.pristine/usr/lib/libc.so.6.new
mv -f /build/glibc/src/glibc-build/testroot.pristine/usr/lib/libc.so.6.new /build/glibc/src/glibc-build/testroot.pristine/usr/lib/libc.so.6
make[2]: Leaving directory '/build/glibc/src/glibc'
make[2]: Entering directory '/build/glibc/src/glibc'
gcc -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl -Wl,-z,pack-relative-relocs -shared -nostdlib -nostartfiles \
-x assembler /dev/null -o /build/glibc/src/glibc-build/format.lds.so
gcc: error: unrecognized command-line option ‘-Wl’; did you mean ‘-W’?
make[2]: *** [Makerules:992: /build/glibc/src/glibc-build/format.lds] Error 1
make[2]: Leaving directory '/build/glibc/src/glibc'
make[1]: *** [Makefile:633: /build/glibc/src/glibc-build/testroot.pristine/install.stamp] Error 2
make: *** [Makefile:9: check] Error 2
I resolved this by reverting the recent LDFLAGS changes in makepkg.conf.
It's possible the change to _FORTIFY_SOURCE also breaks things further, since I also ran into that with ALARM. But in that case it might be that glibc <2.39 has defined _FORTIFY_SOURCE=2 somewhere...