summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2019-12-06 17:20:00 +0100
committerMark Wielaard <mark@klomp.org>2019-12-11 14:22:15 +0100
commitcf1b5fe170fa24f32871ef284ff2968c73816f98 (patch)
tree49e8a3f259de927d6c3772ee2b2e044259736b9f
parenteaffa79d52da7454044be53d28b525cebdb0093b (diff)
Make sure to always build with build-ids.
We really need build-ids for various things. If the system compiler doesn't generate build-ids warn and generate them anyway for both the binaries and the tests. Signed-off-by: Mark Wielaard <mark@klomp.org>
-rw-r--r--ChangeLog4
-rw-r--r--configure.ac9
-rw-r--r--tests/ChangeLog4
-rwxr-xr-xtests/run-debuginfod-find.sh4
4 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 0e229622..ed5f5866 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2019-12-06 Mark Wielaard <mark@klomp.org>
+
+ * configure.ac: Add ac_cv_buildid check.
+
2019-11-26 Mark Wielaard <mark@klomp.org>
* configure.ac: Set version to 0.178.
diff --git a/configure.ac b/configure.ac
index 5a2dc373..36a6b6c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -197,6 +197,15 @@ if test "$ac_cv_zdefs" = "yes"; then
dso_LDFLAGS="$dso_LDFLAGS $ZDEFS_LDFLAGS"
fi
+# We really want build-ids. Warn and force generating them if gcc was
+# configure without --enable-linker-build-id
+AC_CACHE_CHECK([whether the compiler generates build-ids], ac_cv_buildid, [dnl
+AC_LINK_IFELSE([AC_LANG_PROGRAM()],[ac_cv_buildid=yes; readelf -n conftest$EXEEXT | grep -q NT_GNU_BUILD_ID || ac_cv_buildid=no],AC_MSG_FAILURE([unexpected compile failure]))])
+if test "$ac_cv_buildid" = "no"; then
+ AC_MSG_WARN([compiler doesn't generate build-id by default])
+ LDFLAGS="$LDFLAGS -Wl,--build-id"
+fi
+
ZRELRO_LDFLAGS="-Wl,-z,relro"
AC_CACHE_CHECK([whether gcc supports $ZRELRO_LDFLAGS], ac_cv_zrelro, [dnl
save_LDFLAGS="$LDFLAGS"
diff --git a/tests/ChangeLog b/tests/ChangeLog
index ffa4ef51..ce67ce55 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2019-12-06 Mark Wielaard <mark@klomp.org>
+
+ * run-debuginfod-find.sh: Force -Wl,--build-id.
+
2019-12-05 Mark Wielaard <mark@klomp.org>
* run-findinfod-find.sh: Run strip under testrun.
diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh
index 6f92fbf1..6533996a 100755
--- a/tests/run-debuginfod-find.sh
+++ b/tests/run-debuginfod-find.sh
@@ -101,7 +101,7 @@ export DEBUGINFOD_TIMEOUT=10
# cannot find it without debuginfod.
echo "int main() { return 0; }" > ${PWD}/prog.c
tempfiles prog.c
-gcc -g -o prog ${PWD}/prog.c
+gcc -Wl,--build-id -g -o prog ${PWD}/prog.c
testrun ${abs_top_builddir}/src/strip -g -f prog.debug ${PWD}/prog
BUILDID=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
-a prog | grep 'Build ID' | cut -d ' ' -f 7`
@@ -138,7 +138,7 @@ cmp $filename ${PWD}/prog.c
# Build another, non-stripped binary
echo "int main() { return 0; }" > ${PWD}/prog2.c
tempfiles prog2.c
-gcc -g -o prog2 ${PWD}/prog2.c
+gcc -Wl,--build-id -g -o prog2 ${PWD}/prog2.c
BUILDID2=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
-a prog2 | grep 'Build ID' | cut -d ' ' -f 7`