[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Gnulib's tempname.c does not compile with TCC: max_align_t undefined
From: |
Bruno Haible |
Subject: |
Re: Gnulib's tempname.c does not compile with TCC: max_align_t undefined |
Date: |
Wed, 03 Mar 2021 04:09:24 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-203-generic; KDE/5.18.0; x86_64; ; ) |
Luca Saiu wrote:
> It is the version packaged by debian:
>
> [luca@moore ~]$ tcc --version
> tcc version 0.9.27 (x86_64 Linux)
OK.
I can see that the max_align_t problem is the only compilation error in
all of gnulib (excluding C++ sources).
The max_align_t problem comes from two causes:
1) tcc's <stddef.h> does not define max_align_t. Gnulib's autoconfiguration
notices it and sets HAVE_MAX_ALIGN_T=0 and activates the <stddef.h>
replacement.
2) When tcc processes this source file
#include <config.h>
#include <sys/types.h>
#ifdef __need_size_t
bbb
#endif
#include <stddef.h>
the preprocessed output contains the token 'bbb'. This means that tcc's
<stddef.h> does not obey the special invocation convention that some
glibc header files assume. For example, glibc's <time.h> does
/* Get size_t and NULL from <stddef.h>. */
# define __need_size_t
# define __need_NULL
# include <stddef.h>
The expectation is that once the include of <stddef.h> is terminated,
the symbols __need_size_t, __need_NULL are not defined any more. So
that when other code does
#include <stddef.h>
the entire <stddef.h> contents will be included.
I'm committing this workaround. I wouldn't be surprised if the same
problem would also occur for
fcntl.h
signal.h
stdio.h
stdlib.h
sys/types.h
time.h
wchar.h
2021-03-02 Bruno Haible <bruno@clisp.org>
stddef: Work around an interoperability problem of tcc with glibc.
Reported by Luca Saiu <positron@gnu.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-03/msg00011.html>.
* lib/stddef.in.h [__TINYC__]: In case of the special invocation
convention, undefine the macros that TinyCC's <stddef.h> should undefine
but doesn't.
* doc/posix-headers/stddef.texi: Mention the TinyCC bug.
diff --git a/doc/posix-headers/stddef.texi b/doc/posix-headers/stddef.texi
index dbc0103..ba27fa8 100644
--- a/doc/posix-headers/stddef.texi
+++ b/doc/posix-headers/stddef.texi
@@ -27,6 +27,10 @@ NetBSD 5.0
Some platforms provide a @code{NULL} macro whose value does not have the size
of a pointer:
AIX 7.2 with xlc in 64-bit mode.
+
+@item
+When this header file is provided by TinyCC 0.9.27 on glibc systems, it does
+not fulfil the expectations of other glibc header files.
@end itemize
Portability problems not fixed by Gnulib:
diff --git a/lib/stddef.in.h b/lib/stddef.in.h
index ba6f903..590e12c 100644
--- a/lib/stddef.in.h
+++ b/lib/stddef.in.h
@@ -42,6 +42,15 @@
# define _GL_STDDEF_WINT_T
# endif
# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
+ /* On TinyCC, make sure that the macros that indicate the special invocation
+ convention get undefined. */
+# ifdef __TINYC__
+# undef __need_wchar_t
+# undef __need_size_t
+# undef __need_ptrdiff_t
+# undef __need_NULL
+# undef __need_wint_t
+# endif
# endif
#else