2.02_beta3-gcc6-ld-no-pie.patch 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 2016-05-21 Magnus Granberg <zorry@gentoo.org>
  2. #583042 sys-boot/grub-2.02_beta3-r1: building w/gcc-6[pie]: error:
  3. x86_64-pc-linux-gnu/bin/ld: -r and -shared may not be used together
  4. * acinclude.m4: Add -no-pie check.
  5. * configure.ac: Add -no-pie to TARGET_LDFLAGS if needed.
  6. --- a/acinclude.m4 2015-11-11 20:56:52.000000000 +0100
  7. +++ b/acinclude.m4 2016-05-17 00:08:22.000000000 +0200
  8. @@ -390,6 +390,24 @@ else
  9. [fi]
  10. ])
  11. +dnl Check if the Linker supports `-no-pie'.
  12. +AC_DEFUN([grub_CHECK_NO_PIE],
  13. +[AC_MSG_CHECKING([whether linker accepts -no-pie])
  14. +AC_CACHE_VAL(grub_cv_cc_ld_nopie,
  15. +[save_LDFLAGS="$LDFLAGS"
  16. +LDFLAGS="$LDFLAGS -no-pie"
  17. +AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  18. + [grub_cv_cc_ld_no_pie=yes],
  19. + [grub_cv_cc_ld_no_pie=no])
  20. +LDFLAGS="$save_LDFLAGS"
  21. +])
  22. +AC_MSG_RESULT([$grub_cv_cc_ld_no_pie])
  23. +nopie_possible=no
  24. +if test "x$grub_cv_cc_ld_no_pie" = xyes ; then
  25. + nopie_possible=yes
  26. +fi
  27. +])
  28. +
  29. dnl Check if the C compiler supports `-fPIC'.
  30. AC_DEFUN([grub_CHECK_PIC],[
  31. [# Position independent executable.
  32. --- a/configure.ac 2016-02-27 13:40:56.000000000 +0100
  33. +++ b/configure.ac 2016-05-17 00:57:29.471000000 +0200
  34. @@ -1184,13 +1184,18 @@ CFLAGS="$TARGET_CFLAGS"
  35. # Position independent executable.
  36. grub_CHECK_PIE
  37. +grub_CHECK_NO_PIE
  38. [# Need that, because some distributions ship compilers that include
  39. -# `-fPIE' in the default specs.
  40. +# `-fPIE' and '-pie' in the default specs.
  41. if [ x"$pie_possible" = xyes ]; then
  42. TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
  43. +fi
  44. +if [ x"$nopie_possible" = xyes ] && [ x"$pie_possible" = xyes ]; then
  45. + TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie"
  46. fi]
  47. CFLAGS="$TARGET_CFLAGS"
  48. +LDFLAGS="$TARGET_LDFLAGS"
  49. # Position independent executable.
  50. grub_CHECK_PIC