Best option right now is to use -ffile-prefix-map (a superset of -fdebug-prefix-map and -fmacro-prefix-map). Can be enabled by passing DEB_BUILD_OPTIONS=reproducible=+fixfilepath as of dpkg 1.19.7. Used in reproducible builds test infrastructure but not on the official Debian archive.

Limitations:

Eventually get some form of BUILD_PATH_PREFIX_MAP accepted in GCC and other compilers:

https://reproducible-builds.org/specs/build-path-prefix-map/

Previous attempt at GCC was rejected: FIXME: GCC bug/discussions upstream Basically rejected due to environment variables affecting compile time behavior

possible counter-proposal: commandline argument to explicitly load from a specified variable. something like:

$ export BUILD_PATH_PREFIX_MAP=/path/to/source=. $ gcc -ffile-prefix-map-from-variable=BUILD_PATH_PREFIX_MAP

Get BUILD_PATH_PREFIX_MAP into other compilers.