From: Sebastian Pop Date: Wed, 16 Jan 2019 16:24:37 +0000 (-0600) Subject: This patch fixes a problem with detecting the target that gcc compiles for when X-Git-Tag: 1.9.9-b1~543 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5508065092c7a22b1b0f8739c915e9d2b37c79b3;p=thirdparty%2Fzlib-ng.git This patch fixes a problem with detecting the target that gcc compiles for when using -m32. The error is in the way we detect GCC_ARCH in configure: GCC_ARCH=`$CC $CFLAGS -dumpmachine | sed 's/-.*//g'` Here is the output of gcc and clang: $ gcc -m32 -std=c99 -dumpmachine x86_64-linux-gnu $ clang -m32 -std=c99 -dumpmachine i386-pc-linux-gnu It looks like it is a known problem: https://gcc.gnu.org/ml/gcc-help/2018-05/msg00053.html This patch checks whether the compiler has the flag -print-multiarch in which case it uses it instead of -dumpmachine to print the compiler target: $ gcc -print-multiarch x86_64-linux-gnu $ gcc -print-multiarch -m32 i386-linux-gnu $ clang -print-multiarch clang: error: unknown argument: '-print-multiarch' There were a few places that used an explicit test for i686 that are now also checking for i386 as this is the value set in ARCH for gcc and clang when configuring zlib-ng with --32. --- diff --git a/configure b/configure index 24cfa987..fc761122 100755 --- a/configure +++ b/configure @@ -266,20 +266,25 @@ if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then echo ... using gcc >> configure.log CC="$cc" CFLAGS="${CFLAGS} -std=c99" - # Re-check arch if gcc is a cross-compiler - GCC_ARCH=`$CC $CFLAGS -dumpmachine | sed 's/-.*//g'` - case $GCC_ARCH in + + # Re-check ARCH if the compiler is a cross-compiler. + if $CC -print-multiarch 1> /dev/null 2>&1; then + CC_ARCH=`$CC $CFLAGS -print-multiarch | sed 's/-.*//g'` + else + CC_ARCH=`$CC $CFLAGS -dumpmachine | sed 's/-.*//g'` + fi + case $CC_ARCH in i386 | i486 | i586 | i686) # Honor user choice if gcc is multilib and 64-bit is requested if test $build64 -eq 1; then ARCH=x86_64 else - ARCH=$GCC_ARCH + ARCH=$CC_ARCH fi ;; x86_64) # Honor user choice if gcc is multilib and 32-bit is requested if test $build32 -ne 1; then - ARCH=$GCC_ARCH + ARCH=$CC_ARCH fi ;; arm | armeb) if test $native -eq 0; then @@ -859,7 +864,7 @@ else fi # Check for SSE2 intrinsics -if test "${ARCH}" = "i686"; then +if test "${ARCH}" = "i386" -o "${ARCH}" = "i686"; then cat > $test.c << EOF #include int main(void) { @@ -879,7 +884,7 @@ fi fi # Check for SSE4.2 CRC intrinsics -if test "${ARCH}" = "i686" || test "${ARCH}" = "x86_64"; then +if test "${ARCH}" = "i386" -o "${ARCH}" = "i686" -o "${ARCH}" = "x86_64"; then cat > $test.c << EOF int main(void) { unsigned crc = 0; @@ -900,7 +905,7 @@ fi fi # Check for PCLMULQDQ intrinsics -if test "${ARCH}" = "i686" || test "${ARCH}" = "x86_64"; then +if test "${ARCH}" = "i386" -o "${ARCH}" = "i686" -o "${ARCH}" = "x86_64"; then cat > $test.c << EOF #include #include