diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc index 97c38b8d95..30e2188111 100755 --- a/util/crossgcc/buildgcc +++ b/util/crossgcc/buildgcc @@ -515,6 +515,13 @@ set_hostcflags_from_gmp() { } build_GMP() { + # Check if GCC enables `-pie` by default (possible since GCC 6). + # We need PIC in all static libraries then. + if "${CC}" -dumpspecs 2>/dev/null | grep -q '[{;][[:space:]]*:-pie\>' + then + OPTIONS="$OPTIONS --with-pic" + fi + CC="$CC" ../${GMP_DIR}/configure --disable-shared --enable-fat \ --prefix=$TARGETDIR $OPTIONS \ || touch .failed