[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1121836: FTBFS on parallel building



Package: bglibs
Version: 2.04+dfsg-9
Severity: normal
Tags: patch, ftbfs

Dear maintainer,

I found bglibs fails to build from scratch when the number of parallel
processes is relative high. The reason lies in the Makefile of bglibs, where
commands generate more than one files are not handled correctly. For example,
a command generating foo and bar cannot be expressed like this:

foo bar: deps
	command-generate-foo-and-bar

It is because when run in parallel, the command may be executed twice. In
bglibs, the target crc-gentab depends on a series of .o files, but other
binaries depends on .lo files. When the number of parallel processes is high
enough, the command generating the same .o and .lo file can be run twice.
What's worse, if the command linking crc-gentab is executed at the same time
as the second run of the command compiling a .o/.lo file, the compiling
command may remove the .o file and the linking command would fail with missing
input files.

The recommended way to handle this is documented in [1]. For this particular
project, however, it seems that the Makefile is generated by a tool written
by the upstream author, which is not packaged by Debian. I recommend using a
dirty fix to amend the Makefile so that the target crc-gentab is declared to
depend on .lo files, instead of .o files, without changing the actual 
linking command.
Cheers,

Miao Wang

diff -Nru bglibs-2.04+dfsg/debian/rules bglibs-2.04+dfsg/debian/rules
--- bglibs-2.04+dfsg/debian/rules	2025-05-30 10:30:31.000000000 +0000
+++ bglibs-2.04+dfsg/debian/rules	2025-12-02 13:20:00.000000000 +0000
@@ -19,6 +19,9 @@
 	echo $(DESTDIR)/usr/bin > conf-bin
 	echo $(CURDIR)/$(PKG_DEV)/usr/include > conf-include
 	echo $(CURDIR)/$(PKG_LIB)/usr/lib > conf-lib
+	cp $(CURDIR)/Makefile $(CURDIR)/Makefile.orig && \
+	sed -r -i '/:/{h; s/^([^:]*:)//; s/\.o/.lo/g; x; s/^([^:]*:).*$$/\1/; G; s/\n//}' $(CURDIR)/Makefile && \
+	printf "%%.lo:%%.o\n\t:\n" >> $(CURDIR)/Makefile
 
 override_dh_auto_build:
 	dh_auto_build -- libraries man programs
@@ -37,3 +40,7 @@
 
 override_dh_gencontrol:
 	dh_gencontrol -- -Vmisc:Built-Using="$(shell dpkg-query -f '$${source:Package} (= $${source:Version})' -W libc-dev-bin)"
+
+override_dh_clean:
+	dh_clean
+	-mv $(CURDIR)/Makefile.orig $(CURDIR)/Makefile


[1]: https://www.gnu.org/software/automake/manual/html_node/Multiple-Outputs.html

Reply to: