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