[Reproducible-builds] Bug#757629: kfreebsd-10: build path compiled into kernel modules

Steven Chamberlain steven at pyro.eu.org
Sun Aug 10 00:01:24 UTC 2014

Package: src:kfreebsd-10
Version: 10.0-6
Severity: wishlist
Tags: patch
User: reproducible-builds at lists.alioth.debian.org
Usertags: toolchain


Some of kfreebsd's .ko module files contain the build path of the
Debian package, for example:



These are _not_ DWARF debugging symbols, but appear in the ELF .text

Having the absolute (rather than relative) path here is:
* not helpful, it conveys no useful information
* wastes disk space and memory
* often different for each build, and thus a problem in terms of the
 Reproducible Builds effort:  https://wiki.debian.org/ReproducibleBuilds

In most cases it seems because:
* modules are built with -DKLD_MODULE
* KLD_MODULE causes LOCK_DEBUG to be defined (sys/lock.h)
* LOCK_DEBUG causes mtx_assert() to use __FILE__ in debug messages

* __FILE__ contains what was literally given to the compiler as the
 source file argument
* freebsd-make compiles many source files giving the full path
* this seems to come from $(.PATH) in the Makefiles
* most Makefiles set .PATH: $(.CURDIR)/foo/bar
* $(.CURDIR) returns an absolute path

But that seems to be unnecessary -- $(.CURDIR)/ is already implied if
you give a relative path (should be true because Make targets are not
supposed to change working directory) -- so when I tried removing it
like this, it seems to have just worked:

$ find sys/modules/ \( -name Makefile -o -name Makefile.inc \) \
   -exec sed -i 's@${.CURDIR}/@@' \{\} \;

The whole build succeeded, the build log is somewhat cleaner, and the
strings in the _text sections now look like this, which is clean enough
for our purposes:



I wanted to document all of this because:
* I've been trying for weeks to figure this out, and many hours today
* I wouldn't want to forget
* I'd like to be able to point to this bug as a full explanation, if I
 commit something odd like this to our debian/rules
* someone else may like to give some input or opinions before I do that


-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable')
Architecture: kfreebsd-amd64 (x86_64)

Kernel: kFreeBSD 9.0-2-amd64-xenhvm-ipsec
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

More information about the Reproducible-builds mailing list