build: add -ffile-prefix-map to CFLAGS

Add -ffile-prefix-map to CFLAGS, which is a way to prevent the full
absolute path of build-time source filenames from ending up in (the
debugging symbols of) the binaries we install.

The RHEL8 version of the code (in /usr/lib/rpm/find-debuginfo.sh) for
scanning for the list of source files to include in the -debugsource
package is confused by the remapping, so disable it.
This commit is contained in:
Allison Karlitskaya 2022-01-20 23:09:06 +01:00
parent 2a1399d3df
commit c66a65feac

View file

@ -247,13 +247,23 @@ AC_DEFINE_UNQUOTED([PATH_SSH_AGENT], ["$SSH_AGENT"], [Location of ssh-agent bina
changequote(,)dnl
if test "x$GCC" = "xyes"; then
if grep -q platform:el8 /usr/lib/os-release; then
# /usr/lib/rpm/find-debuginfo.sh on RHEL 8 gets confused by
# -fdebug-prefix-map, so disable it if we're building there
strip_sourcefile_prefix="."
else
strip_sourcefile_prefix="$(realpath -s "${PWD}/${srcdir}")"
fi
CFLAGS="-Wall \
-Werror=strict-prototypes -Werror=missing-prototypes \
-Werror=implicit-function-declaration \
-Werror=pointer-arith -Werror=init-self \
-Werror=format=2 \
-Werror=return-type \
-Werror=missing-include-dirs $CFLAGS"
-Werror=missing-include-dirs \
-ffile-prefix-map=${strip_sourcefile_prefix}=. \
$CFLAGS"
fi
changequote([,])dnl