]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Fix -nopie/-nopie check.
authorVladimir Serbinenko <phcoder@gmail.com>
Mon, 30 Jan 2017 13:38:50 +0000 (14:38 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Mon, 30 Jan 2017 13:38:50 +0000 (14:38 +0100)
We don't use lgcc_s but missing lgcc_s or another library cause test to fail.
So use -nostdlib.
Clang uses -nopie rather than -no-pie. Check both and use whichever one works.

acinclude.m4
configure.ac

index 7884c1bb51b304aa5cd23c5ba242ee6bb0bbc014..e1116d9ba6678a6c2436b2cdae076dbc77b84c03 100644 (file)
@@ -395,7 +395,7 @@ AC_DEFUN([grub_CHECK_NO_PIE],
 [AC_MSG_CHECKING([whether linker accepts -no-pie])
 AC_CACHE_VAL(grub_cv_cc_ld_no_pie,
 [save_LDFLAGS="$LDFLAGS"
-LDFLAGS="$LDFLAGS -no-pie"
+LDFLAGS="$LDFLAGS -no-pie -nostdlib"
 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
               [grub_cv_cc_ld_no_pie=yes],
               [grub_cv_cc_ld_no_pie=no])
@@ -408,6 +408,23 @@ if test "x$grub_cv_cc_ld_no_pie" = xyes ; then
 fi
 ])
 
+AC_DEFUN([grub_CHECK_NO_PIE_ONEWORD],
+[AC_MSG_CHECKING([whether linker accepts -nopie])
+AC_CACHE_VAL(grub_cv_cc_ld_no_pie_oneword,
+[save_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS -nopie -nostdlib"
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+              [grub_cv_cc_ld_no_pie_oneword=yes],
+              [grub_cv_cc_ld_no_pie_oneword=no])
+LDFLAGS="$save_LDFLAGS"
+])
+AC_MSG_RESULT([$grub_cv_cc_ld_no_pie_oneword])
+nopie_oneword_possible=no
+if test "x$grub_cv_cc_ld_no_pie_oneword" = xyes ; then
+  nopie_oneword_possible=yes
+fi
+])
+
 dnl Check if the C compiler supports `-fPIC'.
 AC_DEFUN([grub_CHECK_PIC],[
 [# Position independent executable.
index 33146b41adff58fdb67e8a4056341dd7d0d305b6..f1a4d39b34d08b1b185f776dbe2e1f5e9d10a16b 100644 (file)
@@ -1202,6 +1202,7 @@ CFLAGS="$TARGET_CFLAGS"
 # Position independent executable.
 grub_CHECK_PIE
 grub_CHECK_NO_PIE
+grub_CHECK_NO_PIE_ONEWORD
 [# Need that, because some distributions ship compilers that include
 # `-fPIE' or '-fpie' and '-pie' in the default specs.
 if [ x"$pie_possible" = xyes ]; then
@@ -1209,6 +1210,9 @@ if [ x"$pie_possible" = xyes ]; then
 fi
 if [ x"$nopie_possible" = xyes ] &&  [ x"$pie_possible" = xyes ]; then
   TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie"
+fi
+if [ x"$nopie_oneword_possible" = xyes ] &&  [ x"$pie_possible" = xyes ]; then
+  TARGET_LDFLAGS="$TARGET_LDFLAGS -nopie"
 fi]
 
 CFLAGS="$TARGET_CFLAGS"