From: Vladimir Serbinenko Date: Fri, 22 Nov 2013 11:50:41 +0000 (+0100) Subject: * configure.ac: Compile with -fPIC when compiling with clang on X-Git-Tag: grub-2.02-beta1~239 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9cf12b20afdd2fb047d407346623c7ff649ffa5c;p=thirdparty%2Fgrub.git * configure.ac: Compile with -fPIC when compiling with clang on mips. --- diff --git a/ChangeLog b/ChangeLog index 8b21400fe..6faadecdb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-11-22 Vladimir Serbinenko + + * configure.ac: Compile with -fPIC when compiling with clang on + mips. + 2013-11-22 Vladimir Serbinenko * configure.ac: Add -no-integrated-as on mips(el) to TARGET_CCASFLAGS diff --git a/configure.ac b/configure.ac index 1df1e7ef4..8852a9899 100644 --- a/configure.ac +++ b/configure.ac @@ -767,10 +767,17 @@ CFLAGS="$TARGET_CFLAGS" # Position independent executable. grub_CHECK_PIC -[# Need that, because some distributions ship compilers that include -# `-fPIC' in the default specs. -if [ x"$pic_possible" = xyes ]; then - TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC" +[# On most platforms we don't want PIC as it only makes relocations harder +# and code less efficient. On mips we want to have one got table per module +# and reload $gp in every function. +# GCC implements it using symbol __gnu_local_gp in non-PIC as well. +# However with clang we need PIC for this reloading to happen. +# Since default varies across dictributions use either -fPIC or -fno-PIC +# explicitly. +if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel ) && test "x$grub_cv_cc_target_clang" = xyes ; then + TARGET_CFLAGS="$TARGET_CFLAGS -fPIC" +elif [ x"$pic_possible" = xyes ]; then + TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC" fi] CFLAGS="$TARGET_CFLAGS"