171351
From 5334ed8ae9c8f15928139be986a1e877e9837630 Mon Sep 17 00:00:00 2001
f4c76c
From: Peter Jones <pjones@redhat.com>
f4c76c
Date: Thu, 25 Jun 2015 15:41:06 -0400
31cddd
Subject: [PATCH] Make it possible to enabled --build-id=sha1
f4c76c
f4c76c
Signed-off-by: Peter Jones <pjones@redhat.com>
f4c76c
---
f4c76c
 acinclude.m4 | 19 +++++++++++++++++++
f4c76c
 configure.ac |  8 ++++++++
f4c76c
 2 files changed, 27 insertions(+)
f4c76c
f4c76c
diff --git a/acinclude.m4 b/acinclude.m4
171351
index 526f97a..48ccecc 100644
f4c76c
--- a/acinclude.m4
f4c76c
+++ b/acinclude.m4
f4c76c
@@ -136,6 +136,25 @@ if test "x$grub_cv_prog_ld_build_id_none" = xyes; then
f4c76c
 fi
f4c76c
 ])
f4c76c
 
f4c76c
+dnl Supply --build-id=sha1 to ld if building modules.
f4c76c
+dnl This suppresses warnings from ld on some systems
f4c76c
+AC_DEFUN([grub_PROG_LD_BUILD_ID_SHA1],
f4c76c
+[AC_MSG_CHECKING([whether linker accepts --build-id=sha1])
f4c76c
+AC_CACHE_VAL(grub_cv_prog_ld_build_id_sha1,
f4c76c
+[save_LDFLAGS="$LDFLAGS"
f4c76c
+LDFLAGS="$LDFLAGS -Wl,--build-id=sha1"
f4c76c
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
f4c76c
+	       [grub_cv_prog_ld_build_id_sha1=yes],
f4c76c
+	       [grub_cv_prog_ld_build_id_sha1=no])
f4c76c
+LDFLAGS="$save_LDFLAGS"
f4c76c
+])
f4c76c
+AC_MSG_RESULT([$grub_cv_prog_ld_build_id_sha1])
f4c76c
+
f4c76c
+if test "x$grub_cv_prog_ld_build_id_sha1" = xyes; then
f4c76c
+  TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,--build-id=sha1"
f4c76c
+fi
f4c76c
+])
f4c76c
+
f4c76c
 dnl Check nm
f4c76c
 AC_DEFUN([grub_PROG_NM_WORKS],
f4c76c
 [AC_MSG_CHECKING([whether nm works])
f4c76c
diff --git a/configure.ac b/configure.ac
171351
index d6ef6c3..3e897bd 100644
f4c76c
--- a/configure.ac
f4c76c
+++ b/configure.ac
171351
@@ -1323,7 +1323,15 @@ grub_PROG_TARGET_CC
f4c76c
 if test "x$TARGET_APPLE_LINKER" != x1 ; then
f4c76c
 grub_PROG_OBJCOPY_ABSOLUTE
f4c76c
 fi
f4c76c
+
f4c76c
+AC_ARG_ENABLE([build-id],
f4c76c
+	      [AS_HELP_STRING([--enable-build-id],
f4c76c
+                             [ask the linker to supply build-id notes (default=no)])])
f4c76c
+if test x$enable_build_id = xyes; then
f4c76c
+grub_PROG_LD_BUILD_ID_SHA1
f4c76c
+else
f4c76c
 grub_PROG_LD_BUILD_ID_NONE
f4c76c
+fi
f4c76c
 if test "x$target_cpu" = xi386; then
f4c76c
   if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
f4c76c
     if test ! -z "$TARGET_IMG_LDSCRIPT"; then
f4c76c