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