TinyCC is an ISO C99 compliant C compiler. [1]

On an x86_64 glibc system, when using this compiler (configured to produce
x86 code: './configure --cpu=x86 --triplet=i386-linux-gnu'), all GNU package
configure scripts guess the $host wrongly:

checking whether make sets $(MAKE)... (cached) yes
checking build system type... x86_64-pc-linux-gnux32
checking host system type... x86_64-pc-linux-gnux32
checking for stdio.h... yes

This compiler produces object files and executables with the same
format as 'gcc -m32', the config.guess result should be the same:
x86_64-pc-linux-gnu. not x86_64-pc-linux-gnux32.

(Note: It can be debated whether the result should not be
i686-pc-linux-gnu instead of x86_64-pc-linux-gnu, but this is
not what I'm asking for here.)

The reason for the mis-diagnostic is that TinyCC, when generating code
for 32-bit CPUs, defines __ILP32__. This is not wrong by any standards,
because ILP32 simply means that the 'int' type, the 'long' type, and
the 'void *' type are all 32 bits wide. But it is different from what
GCC defines:

"gcc -m64"  defines __x64_64__, __LP64__
"gcc -mx32" defines __x64_64__, __ILP32__
"gcc -m32"  defines __i386__
"tcc"       defines __i386__, __ILP32__

Therefore IMO config.guess needs to be fixed.

Find attached a patch that achieves the effect:

checking whether make sets $(MAKE)... (cached) yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for stdio.h... yes

Bruno

[1] https://en.wikipedia.org/wiki/Tiny_C_Compiler
--- build-aux/config.guess.bak	2021-01-30 14:52:55.173812459 +0100
+++ build-aux/config.guess	2021-03-04 01:34:25.961195128 +0100
@@ -1111,7 +1111,7 @@
 	set_cc_for_build
 	LIBCABI=$LIBC
 	if test "$CC_FOR_BUILD" != no_compiler_found; then
-	    if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
+	    if (echo '#if defined __ILP32__ && !defined __i386__'; echo IS_X32; echo '#endif') | \
 		(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
 		grep IS_X32 >/dev/null
 	    then

Reply via email to