[Pkg-cmake-team] Bug#1088017: cmake 3.31 regression: injects -Wl in middle of linker flags
Drew Parsons
dparsons at debian.org
Thu Nov 21 23:34:22 GMT 2024
Package: cmake
Version: 3.31.0-2
Severity: serious
Justification: FTBFS
Control: block 1087764 by -1
cmake 3.31 has made a radical overhaul of LINKER handling, and appears
to have introduced a regression handling -Wl in LDFLAGS.
We applied a linker-related upstream patch in Bug#1087983, but the
problem persists, see the FTBFS in paraview,
https://buildd.debian.org/status/fetch.php?pkg=paraview&arch=arm64&ver=5.13.1%2Bdfsg-8&stamp=1732229551&raw=0
The debian build system (dpkg-buildflags) sets
LDFLAGS=-Wl,-z,relro
cmake seems to acknowledge LDFLAGS appropriately, for instance
CMakeCache.txt contains entries like
CMAKE_SHARED_LINKER_FLAGS:STRING=-Wl,-z,relro
But the linker.txt generated for specific targets gives linker flags
as, for instance
/usr/bin/cc -fPIC -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -Wdate-time -D_FORTIFY_SOURCE=2 -Wall -pedantic -g -Wl,-lc,-Wl,-z,relro,-Wl,--as-needed -Wl,--dependency-file,CMakeFiles/WrappingTools.dir/link.d -Wl,-z,relro -Wl,--as-needed ...
(linking libvtkWrappingTools-pv5.13.so.5.13 in
https://buildd.debian.org/status/fetch.php?pkg=paraview&arch=arm64&ver=5.13.1%2Bdfsg-8&stamp=1732229551&raw=0
)
Later in the options we see "-Wl,-z,relro -Wl,--as-needed -shared",
which would be fine. But before that, linker.txt has been generated with
-Wl,-lc,-Wl,-z,relro,-Wl,--as-needed
Here the linker flags have been amalgamated into one -Wl linker string,
but the -Wl before each separate flag (used in LDFLAGS) has not been
stripped out. Then -Wl appears in the middle of the linker flags, so
is treated as a linker flag itself rather than a compiler flag to send
to the linker. Hence a build error results,
[ 0%] Linking C shared library ../../../lib/aarch64-linux-gnu/libvtkWrappingTools-pv5.13.so
cd /<<PKGBUILDDIR>>/build.python3.13/VTK/Wrapping/Tools && /usr/bin/cmake -E cmake_link_script CMakeFiles/WrappingTools.dir/link.txt --verbose=1
/usr/bin/ld: unrecognized option '-Wl'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
It looks the new cmake 3.31 LINKER system would be supposed to strip out the
intermediate -Wl substrings, but is not doing so. It also looks wrong
that the linker flags are set concatenated like this, but then
repeated separately further down the command line.
The failing concatenated option has prepended -Wl,-lc which is not in
dpkg-buildflags and not in paraview's debian/rules. This might be a
clue where the problem is happening.
-- System Information:
Debian Release: trixie/sid
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 6.11.9-amd64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_WARN, TAINT_OOT_MODULE
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8), LANGUAGE=en_AU:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages cmake depends on:
ii cmake-data 3.31.0-2
ii libarchive13t64 3.7.4-1.1
ii libc6 2.40-3
ii libcurl4t64 8.11.0-1
ii libexpat1 2.6.4-1
ii libgcc-s1 14.2.0-8
ii libjsoncpp26 1.9.6-3
ii librhash1 1.4.5-1
ii libstdc++6 14.2.0-8
ii libuv1t64 1.48.0-7
ii procps 2:4.0.4-6
ii zlib1g 1:1.3.dfsg+really1.3.1-1+b1
Versions of packages cmake recommends:
ii gcc 4:14.2.0-1
ii make 4.3-4.1
Versions of packages cmake suggests:
pn cmake-doc <none>
pn cmake-format <none>
pn elpa-cmake-mode <none>
ii ninja-build 1.12.1-1
-- no debconf information
More information about the Pkg-cmake-team
mailing list