]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Discover partial linking arguments dynamically.
authorVladimir Serbinenko <phcoder@gmail.com>
Mon, 23 Jan 2017 17:17:41 +0000 (20:17 +0300)
committerVladimir Serbinenko <phcoder@gmail.com>
Fri, 27 Jan 2017 20:12:00 +0000 (20:12 +0000)
clang for android doesn't work with -Wl,-r,-d without -static.

conf/Makefile.common
configure.ac
grub-core/Makefile.core.def
grub-core/genmod.sh.in
grub-core/modinfo.sh.in

index 11296b550a7cd40ded498613620f556d78c67d84..90e0c4c2f44dd6e56fcb780ff871718c494dcf60 100644 (file)
@@ -41,7 +41,7 @@ CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
 STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx
 
 CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding
-LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
+LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_INCREMENTAL_LINK)
 CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
 CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
 
index da40cd97d4e84f452141e23e108fbe05e48eb0c1..d694c6c8b9ac8b6df9127697fc86df9cadb4bf69 100644 (file)
@@ -900,6 +900,25 @@ if test x"$target_cpu" = xsparc64 ; then
   TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax"
 fi
 
+AC_CACHE_CHECK([for incremental link options], grub_cv_target_cc_incremental_link, [
+  grub_cv_target_cc_incremental_link=no
+  for cand in "-Wl,-r,-d" "-static -Wl,-r,-d"; do
+    #AC_LINK_IFELSE doesn't handle non-executable output correctly
+    echo > conftest_inclink.c
+    if $TARGET_CC -o /dev/null $TARGET_CFLAGS $TARGET_CPPFLAGS $TARGET_LDFLAGS -nostdlib -Werror $cand conftest_inclink.c >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
+      grub_cv_target_cc_incremental_link="$cand"
+      break
+    fi
+  done
+])
+
+if test x"$grub_cv_target_cc_incremental_link" = xno ; then
+  AC_MSG_ERROR([could not find incremental link options])
+fi
+
+TARGET_INCREMENTAL_LINK="$grub_cv_target_cc_incremental_link"
+AC_SUBST(TARGET_INCREMENTAL_LINK)
+
 # By default, GCC 4.4 generates .eh_frame sections containing unwind
 # information in some cases where it previously did not. GRUB doesn't need
 # these and they just use up vital space. Restore the old compiler
index 2dfa22a9271bd6624fad9b91ce051ac12202dfbd..1c8bc9ffcacd3d891dd34b1ff0af32c7875f31a1 100644 (file)
@@ -49,20 +49,20 @@ kernel = {
 
   nostrip = emu;
 
-  emu_ldflags              = '-Wl,-r,-d';
-  i386_efi_ldflags         = '-Wl,-r,-d';
+  emu_ldflags              = '$(TARGET_INCREMENTAL_LINK)';
+  i386_efi_ldflags         = '$(TARGET_INCREMENTAL_LINK)';
   i386_efi_stripflags      = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
-  x86_64_efi_ldflags       = '-Wl,-r,-d';
+  x86_64_efi_ldflags       = '$(TARGET_INCREMENTAL_LINK)';
   x86_64_efi_stripflags    = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
 
   ia64_efi_cflags = '-fno-builtin -fpic -minline-int-divide-max-throughput';
-  ia64_efi_ldflags = '-Wl,-r,-d';
+  ia64_efi_ldflags = '$(TARGET_INCREMENTAL_LINK)';
   ia64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
 
-  arm_efi_ldflags          = '-Wl,-r,-d';
+  arm_efi_ldflags          = '$(TARGET_INCREMENTAL_LINK)';
   arm_efi_stripflags       = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
 
-  arm64_efi_ldflags          = '-Wl,-r,-d';
+  arm64_efi_ldflags          = '$(TARGET_INCREMENTAL_LINK)';
   arm64_efi_stripflags       = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame';
 
   i386_pc_ldflags          = '$(TARGET_IMG_LDFLAGS)';
@@ -90,7 +90,7 @@ kernel = {
   i386_qemu_cppflags     = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
   emu_cflags = '$(CFLAGS_GNULIB)';
   emu_cppflags = '$(CPPFLAGS_GNULIB)';
-  arm_uboot_ldflags       = '-Wl,-r,-d';
+  arm_uboot_ldflags       = '$(TARGET_INCREMENTAL_LINK)';
   arm_uboot_stripflags    = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
 
   i386_pc_startup = kern/i386/pc/startup.S;
index 45d85931eef49b0f49cc69fbcec333587e76651b..165bfb01682917765fcdbd84d6e8d0f4bdb1d9e5 100644 (file)
@@ -79,9 +79,9 @@ else
     for dep in $deps; do echo "char moddep_$dep[] __attribute__ ((section(\"_moddeps, _moddeps\"))) = \"$dep\";" >>$t2; done
 
     if test -n "$deps"; then
-       @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 $t2 $tmpfile -Wl,-r,-d
+       @TARGET_CC@ @TARGET_LDFLAGS@ @TARGET_INCREMENTAL_LINK@ -ffreestanding -nostdlib -o $tmpfile2 $t1 $t2 $tmpfile
     else
-       @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 $tmpfile -Wl,-r,-d
+       @TARGET_CC@ @TARGET_LDFLAGS@ @TARGET_INCREMENTAL_LINK@ -ffreestanding -nostdlib -o $tmpfile2 $t1 $tmpfile
     fi
     rm -f $t1 $t2 $tmpfile
     mv $tmpfile2 $tmpfile
index f6cd657ce0f8307547fc5d011efa35622c318e63..a3aaa819f50eae8fdced6816d46434244028de0e 100644 (file)
@@ -19,6 +19,7 @@ grub_target_cflags='@TARGET_CFLAGS@'
 grub_target_cppflags='@TARGET_CPPFLAGS@'
 grub_target_ccasflags='@TARGET_CCASFLAGS@'
 grub_target_ldflags='@TARGET_LDFLAGS@'
+grub_target_incremental_ldflags='@TARGET_INCREMENTAL_LINK@'
 grub_cflags='@CFLAGS@'
 grub_cppflags='@CPPFLAGS@'
 grub_ccasflags='@CCASFLAGS@'