[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
config.guess returns bogus triple on Linux/x86_64 bi-arch system
From: |
Bruno Haible |
Subject: |
config.guess returns bogus triple on Linux/x86_64 bi-arch system |
Date: |
Sun, 08 May 2022 19:25:34 +0200 |
On Linux/x86_64, there are three ABIs that the kernel understands directly
(without qemu user):
- 64-bit, as produced by "gcc -m64",
- 32-bit (i686 code), as produced by "gcc -m32",
- 64-bit instructions with 32-bit pointers, as produced by "gcc -mx32".
The patch from 2020-06-15 "* config.guess (x86_64:Linux:*:*): Detect x32 ABI."
<https://lists.gnu.org/archive/html/config-patches/2020-06/msg00005.html>
added support for recognizing the third case (x32 ABI).
But it broke the second case (32-bit ABI), when a GCC version 9 or higher is
used.
$ CC="gcc-version 8.5.0 -m32" ./config.guess
x86_64-pc-linux-gnu
$ CC="gcc-version 9.4.0 -m32" ./config.guess
x86_64-pc-linux-gnux32
$ CC="gcc-version 10.3.0 -m32" ./config.guess
x86_64-pc-linux-gnux32
$ CC="gcc-version 11.3.0 -m32" ./config.guess
x86_64-pc-linux-gnux32
$ CC="gcc-version 12.1.0 -m32" ./config.guess
x86_64-pc-linux-gnux32
The reason is that the code tests for the __ILP32__ preprocessor symbol,
and this preprocessor symbol is defined also in the 32-bit ABI for GCC ≥ 9.
See:
$ : | gcc-version 8.5.0 -m64 -E -dM - | grep '\(LP\|__.*86.* 1\)'
#define __x86_64 1
#define __LP64__ 1
#define __x86_64__ 1
#define _LP64 1
$ : | gcc-version 9.4.0 -m64 -E -dM - | grep '\(LP\|__.*86.* 1\)'
#define __x86_64 1
#define __LP64__ 1
#define __x86_64__ 1
#define _LP64 1
$ : | gcc-version 8.5.0 -m32 -E -dM - | grep '\(LP\|__.*86.* 1\)'
#define __i386 1
#define __i386__ 1
$ : | gcc-version 9.4.0 -m32 -E -dM - | grep '\(LP\|__.*86.* 1\)'
#define __i386 1
#define __i386__ 1
#define __ILP32__ 1
#define _ILP32 1
$ : | gcc-version 8.5.0 -mx32 -E -dM - | grep '\(LP\|__.*86.* 1\)'
#define __x86_64 1
#define __x86_64__ 1
#define __ILP32__ 1
#define _ILP32 1
$ : | gcc-version 9.4.0 -mx32 -E -dM - | grep '\(LP\|__.*86.* 1\)'
#define __x86_64 1
#define __x86_64__ 1
#define __ILP32__ 1
#define _ILP32 1
The config.guess of GCC 12.1.0 includes this change, and as a
consequence, I can no longer build 32-bit binaries of GCC without
specifying --build and --host options — something that worked in
the past.
Find here a patch that changes the output in the 32-bit ABI case
from
$ CC="gcc-version 8.5.0 -m32" ./config.guess
x86_64-pc-linux-gnu
$ CC="gcc-version 9.4.0 -m32" ./config.guess
x86_64-pc-linux-gnux32
to
$ CC="gcc-version 8.5.0 -m32" ./config.guess
i686-pc-linux-gnu
$ CC="gcc-version 9.4.0 -m32" ./config.guess
i686-pc-linux-gnu
This is similar to what config.guess already does for Linux/mips and Darwin.
It also fixes the problem I reported for CC="tcc" in
<https://lists.gnu.org/archive/html/config-patches/2021-03/msg00000.html>.
0001-config.guess-x86_64-Linux-Detect-32-bit-ABI.patch
Description: Text Data
- config.guess returns bogus triple on Linux/x86_64 bi-arch system,
Bruno Haible <=