This is currently only supported when CC_FOR_BUILD is available, as that ultimately governs what the native ABI is. Ideally we would always have a compiler present, and there's very little use for config.guess without one, but this at least avoids breaking existing setups. A fallback using
objdump -f `command -v uname` | grep -q elf32-x86-64 could be used even in the absence of a compiler, though a perfectly valid environment could still have that as an amd64 binary, if unlikely. We shouldn't check /bin/sh, however, as klibc builds that as an amd64 binary even for x32 (see [0]). [0] https://lists.gnu.org/archive/html/config-patches/2018-03/msg00002.html --- config.guess | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/config.guess b/config.guess index 11fda52..92bfc33 100755 --- a/config.guess +++ b/config.guess @@ -1095,7 +1095,17 @@ EOF echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) - echo "$UNAME_MACHINE"-pc-linux-"$LIBC" + set_cc_for_build + LIBCABI=$LIBC + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_X32 >/dev/null + then + LIBCABI="$LIBC"x32 + fi + fi + echo "$UNAME_MACHINE"-pc-linux-"$LIBCABI" exit ;; xtensa*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -- 2.20.1