@ljs redefinition of struck flock in /usr/include/asm-generic/fcntl.h originally declared at /usr/include/bits/fcntl.h
@ljs this one fails on redef of structs f_owned_ex, flock, and flock64
(both on x86_64 Arch)
@ljs nope:
$ cat > test.c
#include <fcntl.h>
#include <linux/pidfd.h>
int main(void) {}
^C
$ gcc test.c
In file included from /usr/include/x86_64-linux-gnu/asm/fcntl.h:1,
from /usr/include/linux/fcntl.h:5,
from /usr/include/linux/pidfd.h:7,
from test.c:2:
/usr/include/asm-generic/fcntl.h:193:8: error: redefinition of ‘struct flock’
193 | struct flock {
| ^~~~~
In file included from /usr/include/fcntl.h:35,
from test.c:1:
/usr/include/x86_64-linux-gnu/bits/fcntl.h:35:8: note: originally defined here
35 | struct flock
| ^~~~~
$ gcc test.c -D_GNU_SOURCE
In file included from /usr/include/x86_64-linux-gnu/asm/fcntl.h:1,
from /usr/include/linux/fcntl.h:5,
from /usr/include/linux/pidfd.h:7,
from test.c:2:
/usr/include/asm-generic/fcntl.h:153:8: error: redefinition of ‘struct f_owner_ex’
153 | struct f_owner_ex {
| ^~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/fcntl.h:61,
from /usr/include/fcntl.h:35,
from test.c:1:
/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h:274:8: note: originally defined here
274 | struct f_owner_ex
| ^~~~~~~~~~
/usr/include/asm-generic/fcntl.h:193:8: error: redefinition of ‘struct flock’
193 | struct flock {
| ^~~~~
/usr/include/x86_64-linux-gnu/bits/fcntl.h:35:8: note: originally defined here
35 | struct flock
| ^~~~~
/usr/include/asm-generic/fcntl.h:207:8: error: redefinition of ‘struct flock64’
207 | struct flock64 {
| ^~~~~~~
/usr/include/x86_64-linux-gnu/bits/fcntl.h:50:8: note: originally defined here
50 | struct flock64
| ^~~~~~~
@ljs neither with or without works on Debian 12 6.1.112-1 nor on nixpkgs 24.11pre684864.189e5f171b16
@ljs both tried the errors do not differ from below. Only thing I can add is the result that I expected, i.e. compiles if only either is included, with or without _GNU_SOURCE. Right, and my distribution is Fedora 40.
Environment (sorry I just respond like this was every other LKML mail):
❯ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-14.2.1-20240912/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none,amdgcn-amdhsa --enable-offload-defaulted --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.1 20240912 (Red Hat 14.2.1-3) (GCC)
❯ uname -a
Linux suppilovahvero 6.11.3-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Oct 10 22:31:19 UTC 2024 x86_64 GNU/Linux
❯ rpm -qi kernel-headers-6.11.3-200.fc40.x86_64
Name : kernel-headers
Version : 6.11.3
Release : 200.fc40
Architecture: x86_64
Install Date: Tue 15 Oct 2024 05:47:24 PM EEST
Group : Unspecified
Size : 6709143
License : ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-2-Clause) AND ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) AND ((GPL-2.0-only WITH Linux-syscall-note) OR CDDL-1.0) AND ((GPL-2.0-only WITH Linux-syscall-note) OR Linux-OpenIB) AND ((GPL-2.0-only WITH Linux-syscall-note) OR MIT) AND ((GPL-2.0-or-later WITH Linux-syscall-note) OR BSD-3-Clause) AND ((GPL-2.0-or-later WITH Linux-syscall-note) OR MIT) AND BSD-3-Clause AND (GPL-1.0-or-later WITH Linux-syscall-note) AND GPL-2.0-only AND (GPL-2.0-only WITH Linux-syscall-note) AND (GPL-2.0-or-later WITH Linux-syscall-note) AND (LGPL-2.0-or-later WITH Linux-syscall-note) AND (LGPL-2.1-only WITH Linux-syscall-note) AND (LGPL-2.1-or-later WITH Linux-syscall-note) AND MIT
Signature : RSA/SHA256, Fri 11 Oct 2024 03:04:41 AM EEST, Key ID 0727707ea15b79cc
Source RPM : kernel-headers-6.11.3-200.fc40.src.rpm
Build Date : Thu 10 Oct 2024 10:39:31 PM EEST
Build Host : bkernel02.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : http://www.kernel.org/
Bug URL : https://bugz.fedoraproject.org/kernel-headers
Summary : Header files for the Linux kernel for use by glibc
Description :
Kernel-headers includes the C header files that specify the interface
between the Linux kernel and userspace libraries and programs. The
header files define structures and constants that are needed for
building most standard programs and are also needed for rebuilding the
glibc package.
I.e. almost as fresh as it gets ATM.