Skip to contentSkip to conversation

Supply --build-id=none to ld if building modules

PATCH New Pavel Roskin 1 participant 1 message Jul 2, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Supply --build-id=none to ld if building modules

This doesn't make any difference to the compiled files, but suppresses linker warnings on systems where build ID is enabled by default, such as Fedora 9.

ChangeLog:

* Makefile.in (MODULE_LDFLAGS): New variable.
* aclocal.m4 (grub_PROG_LD_BUILD_ID_NONE): New macro. Check if the linker accepts --build-id=none.
* configure.ac: Call grub_PROG_LD_BUILD_ID_NONE. Substitute MODULE_LDFLAGS.
* genmk.rb: Use MODULE_LDFLAGS when linking modules.
---

 Makefile.in  |    1 +
 aclocal.m4   |   20 ++++++++++++++++++++
 configure.ac |    2 ++
 genmk.rb     |    2 +-
 4 files changed, 24 insertions(+), 1 deletions(-)
Makefile.in +1 -0
index c29c5fd..c255203 100644
@@ -68,6 +68,7 @@ TARGET_CFLAGS = @TARGET_CFLAGS@
 TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I. -Iinclude -I$(srcdir)/include \
 	-Wall -W
 TARGET_LDFLAGS = @TARGET_LDFLAGS@
+MODULE_LDFLAGS = @MODULE_LDFLAGS@
 OBJCOPY = @OBJCOPY@
 STRIP = @STRIP@
 NM = @NM@
aclocal.m4 +20 -0
index fc67066..a673263 100644
@@ -81,6 +81,26 @@ fi
 ])
 
 
+dnl Supply --build-id=none to ld if building modules.
+dnl This suppresses warnings from ld on some systems
+AC_DEFUN(grub_PROG_LD_BUILD_ID_NONE,
+[AC_MSG_CHECKING([whether linker accepts --build-id=none])
+AC_CACHE_VAL(grub_cv_prog_ld_build_id_none,
+[save_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS -Wl,--build-id=none"
+AC_TRY_LINK([], [],
+   grub_cv_prog_ld_build_id_none=yes,
+   grub_cv_prog_ld_build_id_none=no)
+LDFLAGS="$save_LDFLAGS"
+])
+AC_MSG_RESULT([$grub_cv_prog_ld_build_id_none])
+
+if test "x$grub_cv_prog_ld_build_id_none" = xyes; then
+  MODULE_LDFLAGS="$MODULE_LDFLAGS -Wl,--build-id=none"
+fi
+])
+
+
 dnl Mass confusion!
 dnl Older versions of GAS interpret `.code16' to mean ``generate 32-bit
 dnl instructions, but implicitly insert addr32 and data32 bytes so
configure.ac +2 -0
index 5ec7a47..18049db 100644
@@ -253,6 +253,7 @@ fi
 AC_SUBST(TARGET_CFLAGS)
 AC_SUBST(TARGET_CPPFLAGS)
 AC_SUBST(TARGET_LDFLAGS)
+AC_SUBST(MODULE_LDFLAGS)
 
 # Set them to their new values for the tests below.
 CC="$TARGET_CC"
@@ -262,6 +263,7 @@ LDFLAGS="$TARGET_LDFLAGS"
 
 # Defined in aclocal.m4.
 grub_PROG_OBJCOPY_ABSOLUTE
+grub_PROG_LD_BUILD_ID_NONE
 grub_ASM_USCORE
 if test "x$target_cpu" = xi386; then
   grub_CHECK_START_SYMBOL
genmk.rb +1 -1
index a2179fa..56dee5c 100644
@@ -114,7 +114,7 @@ UNDSYMFILES += #{undsym}
 
 #{@name}: #{pre_obj} #{mod_obj}
 	-rm -f $@
-	$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
+	$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) $(MODULE_LDFLAGS) -Wl,-r,-d -o $@ $^
 	$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
 
 #{pre_obj}: $(#{prefix}_DEPENDENCIES) #{objs_str}