Control: severity -1 normal Hi!
On Mon, 2026-01-12 at 16:53:26 +0200, Adrian Bunk wrote: > Package: dpkg > Version: 4.2-1 > Severity: serious > Tags: ftbfs > X-Debbugs-Cc: Salvatore Bonaccorso <[email protected]> > Control: affects -1 src:criu > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/criu.html > > ... > ld -fcf-protection -r -o images/built-in.o images/stats.o images/core.o > images/core-x86.o images/core-mips.o images/core-loongarch64.o > images/core-arm.o images/core-aarch64.o images/core-ppc64.o > images/core-s390.o images/core-riscv64.o images/cpuinfo.o images/inventory.o > images/fdinfo.o images/fown.o images/ns.o images/regfile.o > images/ghost-file.o images/fifo.o images/remap-file-path.o images/eventfd.o > images/eventpoll.o images/fh.o images/fsnotify.o images/signalfd.o > images/fs.o images/pstree.o images/pipe.o images/tcp-stream.o > images/sk-packet.o images/mnt.o images/pipe-data.o images/sa.o images/timer.o > images/timerfd.o images/mm.o images/sk-opts.o images/sk-unix.o > images/sk-inet.o images/tun.o images/sk-netlink.o images/packet-sock.o > images/ipc-var.o images/ipc-desc.o images/ipc-shm.o images/ipc-msg.o > images/ipc-sem.o images/utsns.o images/creds.o images/vma.o images/netdev.o > images/tty.o images/file-lock.o images/rlimit.o images/pagemap.o > images/siginfo.o images/rpc.o images/ext-file.o images/cgroup.o > images/userns.o images/pidns.o images/opts.o images/seccomp.o > images/binfmt-misc.o images/time.o images/sysctl.o images/autofs.o > images/macvlan.o images/sit.o images/memfd.o images/timens.o > images/img-streamer.o images/bpfmap-file.o images/bpfmap-data.o > images/apparmor.o images/rseq.o images/pidfd.o > ld: -f may not be used without -shared > make[3]: *** [images/Makefile:135: images/built-in.o] Error 1 > > > > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/arm64/criu.html > > ... > ld -mbranch-protection=standard -r -o images/built-in.o images/stats.o > images/core.o images/core-x86.o images/core-mips.o images/core-loongarch64.o > images/core-arm.o images/core-aarch64.o images/core-ppc64.o > images/core-s390.o images/core-riscv64.o images/cpuinfo.o images/inventory.o > images/fdinfo.o images/fown.o images/ns.o images/regfile.o > images/ghost-file.o images/fifo.o images/remap-file-path.o images/eventfd.o > images/eventpoll.o images/fh.o images/fsnotify.o images/signalfd.o > images/fs.o images/pstree.o images/pipe.o images/tcp-stream.o > images/sk-packet.o images/mnt.o images/pipe-data.o images/sa.o images/timer.o > images/timerfd.o images/mm.o images/sk-opts.o images/sk-unix.o > images/sk-inet.o images/tun.o images/sk-netlink.o images/packet-sock.o > images/ipc-var.o images/ipc-desc.o images/ipc-shm.o images/ipc-msg.o > images/ipc-sem.o images/utsns.o images/creds.o images/vma.o images/netdev.o > images/tty.o images/file-lock.o images/rlimit.o images/pagemap.o > images/siginfo.o images/rpc.o images/ext-file.o images/cgroup.o > images/userns.o images/pidns.o images/opts.o images/seccomp.o > images/binfmt-misc.o images/time.o images/sysctl.o images/autofs.o > images/macvlan.o images/sit.o images/memfd.o images/timens.o > images/img-streamer.o images/bpfmap-file.o images/bpfmap-data.o > images/apparmor.o images/rseq.o images/pidfd.o > ld: unrecognised emulation mode: branch-protection=standard > Supported emulations: aarch64linux aarch64elf aarch64elf32 aarch64elf32b > aarch64elfb armelf armelfb aarch64linuxb aarch64linux32 aarch64linux32b > armelfb_linux_eabi armelf_linux_eabi > make[3]: *** [images/Makefile:135: images/built-in.o] Error 1 > dpkg-buildflags(1) says: > > LDFLAGS > Options passed to the compiler when linking executables or shared > objects (if the linker is called directly, then -Wl and , have to > be stripped from these options). Default value: empty. > > This documented behaviour was broken with #1115292. Ugh, this looks like a misfeature to me, as I think in general in the autotools world, LDFLAGS is expected to be used always with a compiler. As it stands, other build flag features have already broken that direct ld behavior, such as when passing: -flto=auto -ffat-lto-objects -fsanitize=address -fsanitize=thread -fsanitize=leak -fsanitize=undefined -specs=... -mbranch-protection=standard -fcf-protection And the current documented handling of «,» is also incorrect. I don't see a sane way to have working LDFLAGS to be used in a compiler which (I think is the expected behavior and more widespread usage), and at the same time supporting the current documented semantics for direct calls to ld. I've lowered the severity because I think this is something that in dpkg should be fixed via a documentation change (something like the attached draft), and the affected package modified to work either by switching to use a compiler for linking, or to improve their option filtering. I don't think this would impact many packages though? But if you think otherwise I'm happy to get corrected, but then I'm not sure what other avenue would be there besides the above. :/ Thanks, Guillem
diff --git i/man/dpkg-buildflags.pod w/man/dpkg-buildflags.pod index 7a759eb7a..9f1fc3d6c 100644 --- i/man/dpkg-buildflags.pod +++ w/man/dpkg-buildflags.pod @@ -322,11 +322,15 @@ Since dpkg 1.17.7. =item B<LDFLAGS> Options passed to the host compiler when linking executables or shared -objects (if the linker is called directly, then -B<-Wl> -and -B<,> -have to be stripped from these options). +objects. + +If the linker is called directly +(a discouraged practice in the common case, +unless necessary for low level projects), +then only the B<-o>, B<--output>, B<-l>, B<-L>, B<-f>, B<-Wl> options and +their arguments should be passed over, +with B<-Wl> getting stripped and B<,> in its arguments replaced with spaces. + Default value: empty. =item B<ASFLAGS_FOR_BUILD> diff --git i/scripts/mk/buildflags.mk w/scripts/mk/buildflags.mk index 7998d99f5..7ae544b47 100644 --- i/scripts/mk/buildflags.mk +++ w/scripts/mk/buildflags.mk @@ -10,7 +10,7 @@ # DFLAGS: Flags for the host D compiler. # FFLAGS: Flags for the host Fortran 77 compiler. # FCFLAGS: Flags for the host Fortran 9x compiler. -# LDFLAGS: Flags for the host linker. +# LDFLAGS: Flags for the host linker called by the compiler. # # And the following variables for the build tools (since dpkg 1.22.1): # @@ -23,7 +23,7 @@ # DFLAGS_FOR_BUILD: Flags for the build D compiler. # FFLAGS_FOR_BUILD: Flags for the build Fortran 77 compiler. # FCFLAGS_FOR_BUILD: Flags for the build Fortran 9x compiler. -# LDFLAGS_FOR_BUILD: Flags for the build linker. +# LDFLAGS_FOR_BUILD: Flags for the build linker called by the compiler. # # You can also export them in the environment by setting # DPKG_EXPORT_BUILDFLAGS to a non-empty value.

