commit 7a074e9 includes <linux/signal.h> in <linux/aio_abi.h> which is causing the following compilation errors. $ cat test.c #include <signal.h> #include <linux/aio_abi.h> int main() { return 0; } $ gcc -Wall test.c In file included from /usr/include/asm/signal.h:7, from /usr/include/linux/signal.h:5, from /usr/include/linux/aio_abi.h:32, from test.c:2: /usr/include/linux/time.h:10:8: error: redefinition of 'struct timespec' struct timespec { ^~~~~~~~ In file included from /usr/include/signal.h:53, from test.c:1: /usr/include/bits/types/struct_timespec.h:8:8: note: originally defined here struct timespec ^~~~~~~~ In file included from /usr/include/linux/signal.h:5, from /usr/include/linux/aio_abi.h:32, from test.c:2: /usr/include/asm/signal.h:16:23: error: conflicting types for 'sigset_t' typedef unsigned long sigset_t; ^~~~~~~~ In file included from /usr/include/signal.h:35, from test.c:1: /usr/include/bits/types/sigset_t.h:7:20: note: previous declaration of 'sigset_t' was here typedef __sigset_t sigset_t; ^~~~~~~~ In file included from /usr/include/linux/signal.h:5, from /usr/include/linux/aio_abi.h:32, from test.c:2: /usr/include/asm/signal.h:115:8: error: redefinition of 'struct sigaction' struct sigaction { ^~~~~~~~~ In file included from /usr/include/signal.h:226, from test.c:1: /usr/include/bits/sigaction.h:27:8: note: originally defined here struct sigaction ^~~~~~~~~ /usr/include/asm/signal.h:116:17: error: expected ':', ',', ';', '}' or '__attribute__' before '.' token __sighandler_t sa_handler; ^~~~~~~~~~ In file included from /usr/include/linux/signal.h:5, from /usr/include/linux/aio_abi.h:32, from test.c:2: /usr/include/asm/signal.h:128:3: error: conflicting types for 'stack_t' } stack_t; ^~~~~~~ In file included from /usr/include/signal.h:303, from test.c:1: /usr/include/bits/types/stack_t.h:31:5: note: previous declaration of 'stack_t' was here } stack_t; ^~~~~~~ In file included from /usr/include/asm/siginfo.h:15, from /usr/include/linux/signal.h:6, from /usr/include/linux/aio_abi.h:32, from test.c:2: /usr/include/asm-generic/siginfo.h:8:15: error: redefinition of 'union sigval' typedef union sigval { ^~~~~~ In file included from /usr/include/bits/types/siginfo_t.h:6, from /usr/include/signal.h:57, from test.c:1: /usr/include/bits/types/__sigval_t.h:24:7: note: originally defined here union sigval ^~~~~~ In file included from /usr/include/asm/siginfo.h:15, from /usr/include/linux/signal.h:6, from /usr/include/linux/aio_abi.h:32, from test.c:2: /usr/include/asm-generic/siginfo.h:11:3: error: conflicting types for 'sigval_t' } sigval_t; ^~~~~~~~ In file included from /usr/include/signal.h:62, from test.c:1: /usr/include/bits/types/sigval_t.h:16:20: note: previous declaration of 'sigval_t' was here typedef __sigval_t sigval_t; ^~~~~~~~ In file included from /usr/include/asm/siginfo.h:15, from /usr/include/linux/signal.h:6, from /usr/include/linux/aio_abi.h:32, from test.c:2: /usr/include/asm-generic/siginfo.h:133:24: error: conflicting types for 'siginfo_t' } __ARCH_SI_ATTRIBUTES siginfo_t; ^~~~~~~~~ In file included from /usr/include/signal.h:57, from test.c:1: /usr/include/bits/types/siginfo_t.h:124:5: note: previous declaration of 'siginfo_t' was here } siginfo_t __SI_ALIGNMENT; ^~~~~~~~~ In file included from /usr/include/asm/siginfo.h:15, from /usr/include/linux/signal.h:6, from /usr/include/linux/aio_abi.h:32, from test.c:2: /usr/include/asm-generic/siginfo.h:313:16: error: redefinition of 'struct sigevent' typedef struct sigevent { ^~~~~~~~ In file included from /usr/include/signal.h:66, from test.c:1: /usr/include/bits/types/sigevent_t.h:22:16: note: originally defined here typedef struct sigevent ^~~~~~~~ In file included from /usr/include/asm/siginfo.h:15, from /usr/include/linux/signal.h:6, from /usr/include/linux/aio_abi.h:32, from test.c:2: /usr/include/asm-generic/siginfo.h:326:3: error: conflicting types for 'sigevent_t' } sigevent_t; ^~~~~~~~~~ In file included from /usr/include/signal.h:66, from test.c:1: /usr/include/bits/types/sigevent_t.h:42:5: note: previous declaration of 'sigevent_t' was here } sigevent_t; ^~~~~~~~~~ $ cat /etc/redhat-release Fedora release 29 (Rawhide)
The changes of the above mentioned commit are: https://github.com/torvalds/linux/commit/7a074e96dee62586c935c80cecd931431bfdd0be#diff-590a640c13a8f3a134e57b84f5c4fb79
In addition, gcc-8.1 is unable to build against 4.18-rc1 after commit 7a074e96dee62586c935c80cecd931431bfdd0be Building gcc-8.1.0 for an x86_64 toolchain fails to build against the 4.18-rc1 kernel due to the following error: ``` In file included from /home/neil/projects/scratch/alternates/LibreELEC.tv/build.LibreELEC-Generic.x86_64-9.0-devel-next/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/asm/signal.h:7, from /home/neil/projects/scratch/alternates/LibreELEC.tv/build.LibreELEC-Generic.x86_64-9.0-devel-next/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/linux/signal.h:5, from /home/neil/projects/scratch/alternates/LibreELEC.tv/build.LibreELEC-Generic.x86_64-9.0-devel-next/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/linux/aio_abi.h:32, from /home/neil/projects/scratch/alternates/LibreELEC.tv/build.LibreELEC-Generic.x86_64-9.0-devel-next/gcc-8.1.0/libsanitizer/include/system/linux/aio_abi.h:2, from /home/neil/projects/scratch/alternates/LibreELEC.tv/build.LibreELEC-Generic.x86_64-9.0-devel-next/gcc-8.1.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:50: /home/neil/projects/scratch/alternates/LibreELEC.tv/build.LibreELEC-Generic.x86_64-9.0-devel-next/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/linux/time.h:10:8: error: redefinition of 'struct timespec' struct timespec { ^~~~~~~~ In file included from /home/neil/projects/scratch/alternates/LibreELEC.tv/build.LibreELEC-Generic.x86_64-9.0-devel-next/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/sys/stat.h:30, from /home/neil/projects/scratch/alternates/LibreELEC.tv/build.LibreELEC-Generic.x86_64-9.0-devel-next/gcc-8.1.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:31: /home/neil/projects/scratch/alternates/LibreELEC.tv/build.LibreELEC-Generic.x86_64-9.0-devel-next/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/bits/types/struct_timespec.h:8:8: note: previous definition of 'struct timespec' struct timespec ^~~~~~~~ make[5]: *** [Makefile:539: sanitizer_platform_limits_linux.lo] Error 1 make[5]: *** Waiting for unfinished jobs.... ``` End of build log: https://pastebin.com/raw/jbbA7CrE I bisected the 4.18-rc1 kernel (v4.17 being "good") and this commit is identified as the bad commit - presumably this is a kernel issue rather than a gcc issue? Just looking for pointers on who to bother at this stage... :)
Seeing this when trying to include linux/signal.h as well. I.e. just: ``` #include <stdlib.h> #include <linux/signal.h> ``` Gives approximately same errors about timespec redefinition. Happening in glibc and musl. I am also seeing this failing even inside docker for centos 7 where kernel headers are quite old: kernel-headers-3.10.0-1160.15.2.el7.x86_64 ``` [root@1b336f6ef5a5 ~]# gcc -o test.o -x c - #include <stdlib.h> #include <linux/signal.h> In file included from /usr/include/asm/signal.h:6:0, from /usr/include/linux/signal.h:4, from <stdin>:2: /usr/include/linux/time.h:9:8: error: redefinition of 'struct timespec' struct timespec { ^ In file included from /usr/include/sys/select.h:43:0, from /usr/include/sys/types.h:219, from /usr/include/stdlib.h:314, from <stdin>:1: /usr/include/time.h:120:8: note: originally defined here struct timespec ^ In file included from /usr/include/asm/signal.h:6:0, from /usr/include/linux/signal.h:4, from <stdin>:2: /usr/include/linux/time.h:15:8: error: redefinition of 'struct timeval' struct timeval { ^ In file included from /usr/include/sys/select.h:45:0, from /usr/include/sys/types.h:219, from /usr/include/stdlib.h:314, from <stdin>:1: /usr/include/bits/time.h:30:8: note: originally defined here struct timeval ^ In file included from /usr/include/linux/signal.h:4:0, from <stdin>:2: /usr/include/asm/signal.h:15:23: error: conflicting types for 'sigset_t' typedef unsigned long sigset_t; ^ In file included from /usr/include/sys/types.h:219:0, from /usr/include/stdlib.h:314, from <stdin>:1: /usr/include/sys/select.h:37:20: note: previous declaration of 'sigset_t' was here typedef __sigset_t sigset_t; ^ ``` As part of https://github.com/gperftools/gperftools/pull/1250 we're trying to fetch define for sigev_notify_thread_id. So this looks like some bug in kernel headers, and not recent it seems.