Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compiler-rt] error: multiple definition of 'enum fsconfig_command' #56421

Closed
andreas-schwab opened this issue Jul 7, 2022 · 9 comments
Closed

Comments

@andreas-schwab
Copy link
Contributor

andreas-schwab commented Jul 7, 2022

libsanitizer fails to build with the very latest glibc:

In file included from /usr/include/linux/fs.h:19,
                 from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:76:
/usr/include/linux/mount.h:95:6: error: multiple definition of 'enum fsconfig_command'
   95 | enum fsconfig_command {
      |      ^~~~~~~~~~~~~~~~
In file included from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:63:
/usr/include/sys/mount.h:189:6: note: previous definition here
  189 | enum fsconfig_command
      |      ^~~~~~~~~~~~~~~~
/usr/include/linux/mount.h:129:8: error: redefinition of 'struct mount_attr'
  129 | struct mount_attr {
      |        ^~~~~~~~~~
/usr/include/sys/mount.h:161:8: note: previous definition of 'struct mount_attr'
  161 | struct mount_attr
      |        ^~~~~~~~~~
@MaskRay
Copy link
Member

MaskRay commented Jul 11, 2022

Can you share detailed reproduce instructions?

I have built latest glibc in /tmp/glibc/lld/ and latest kernel headers for userspace in /tmp/linux/x86_64 (make O=/tmp/linux/x86_64 -j60 headers_install).

With cmake -DLLVM_ENABLE_PROJECTS='clang;compiler-rt' -DLLVM_TARGETS_TO_BUILD='X86' -DCMAKE_{C,CXX}_FLAGS='-isystem/tmp/glibc/lld/include -isystem/tmp/linux/x86_64/usr/include', ninja asan reproduces the error.

The sanitizer_common/sanitizer_platform_limits_posix.cpp compile uses

. /tmp/glibc/lld/include/sys/mount.h
.. /tmp/linux/x86_64/usr/include/linux/mount.h

glibc 7eae6a91e9b1670330c9f15730082c91c0b1d570 triggered this.

@MaskRay
Copy link
Member

MaskRay commented Jul 11, 2022

Patch: https://reviews.llvm.org/D129471

@MaskRay MaskRay self-assigned this Jul 11, 2022
MaskRay added a commit that referenced this issue Jul 11, 2022
…mount_attr conflict with glibc 2.36

It is generally not a good idea to mix usage of glibc headers and Linux UAPI
headers (https://sourceware.org/glibc/wiki/Synchronizing_Headers). In glibc
since 7eae6a91e9b1670330c9f15730082c91c0b1d570 (milestone: 2.36), sys/mount.h
defines `fsconfig_command` which conflicts with linux/mount.h:

    .../usr/include/linux/mount.h:95:6: error: redeclaration of ‘enum fsconfig_command’

Remove #include <linux/fs.h> which pulls in linux/mount.h. Expand its 4 macros manually.
Android sys/mount.h doesn't define BLKBSZGET and it still needs linux/fs.h.
In the long term we should move Linux specific definitions to sanitizer_platform_limits_linux.cpp
but this commit is easy to cherry pick into older compiler-rt releases.

Fix #56421

Reviewed By: #sanitizers, vitalybuka, zatrazz

Differential Revision: https://reviews.llvm.org/D129471
@MaskRay
Copy link
Member

MaskRay commented Jul 11, 2022

9cf1306 is the commit to cherry pick into older compiler-rt if you want to build those packages on glibc 2.36 (will be released soon in 2022-08).

kraj pushed a commit to kraj/llvm-project that referenced this issue Jul 29, 2022
…mount_attr conflict with glibc 2.36

It is generally not a good idea to mix usage of glibc headers and Linux UAPI
headers (https://sourceware.org/glibc/wiki/Synchronizing_Headers). In glibc
since 7eae6a91e9b1670330c9f15730082c91c0b1d570 (milestone: 2.36), sys/mount.h
defines `fsconfig_command` which conflicts with linux/mount.h:

    .../usr/include/linux/mount.h:95:6: error: redeclaration of ‘enum fsconfig_command’

Remove #include <linux/fs.h> which pulls in linux/mount.h. Expand its 4 macros manually.
Android sys/mount.h doesn't define BLKBSZGET and it still needs linux/fs.h.
In the long term we should move Linux specific definitions to sanitizer_platform_limits_linux.cpp
but this commit is easy to cherry pick into older compiler-rt releases.

Fix llvm#56421

Reviewed By: #sanitizers, vitalybuka, zatrazz

Differential Revision: https://reviews.llvm.org/D129471

Signed-off-by: Khem Raj <raj.khem@gmail.com>
@marxin
Copy link
Contributor

marxin commented Aug 8, 2022

Can you please cherry-pick the commit for LLVM 14 branch?

@EugeneZelenko
Copy link
Contributor

@marxin: 14 branch is not longer supported.

@marxin
Copy link
Contributor

marxin commented Aug 8, 2022

Hm, but version 15 hasn't been released yet, right?

@EugeneZelenko
Copy link
Contributor

Fixes are backported to 15.

@marxin
Copy link
Contributor

marxin commented Aug 8, 2022

Fixes are backported to 15.

But why don't you have an overlap in between supported branches? Note that right now, there is no stable LLVM release that would contain this change and so that can co-exist with glibc 2.39. Sigh.

@AaronBallman
Copy link
Collaborator

CC @tstellar for questions about release branch processes.

mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
…mount_attr conflict with glibc 2.36

It is generally not a good idea to mix usage of glibc headers and Linux UAPI
headers (https://sourceware.org/glibc/wiki/Synchronizing_Headers). In glibc
since 7eae6a91e9b1670330c9f15730082c91c0b1d570 (milestone: 2.36), sys/mount.h
defines `fsconfig_command` which conflicts with linux/mount.h:

    .../usr/include/linux/mount.h:95:6: error: redeclaration of ‘enum fsconfig_command’

Remove #include <linux/fs.h> which pulls in linux/mount.h. Expand its 4 macros manually.

Fix llvm/llvm-project#56421

Reviewed By: #sanitizers, vitalybuka, zatrazz

Differential Revision: https://reviews.llvm.org/D129471
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
…mount_attr conflict with glibc 2.36

It is generally not a good idea to mix usage of glibc headers and Linux UAPI
headers (https://sourceware.org/glibc/wiki/Synchronizing_Headers). In glibc
since 7eae6a91e9b1670330c9f15730082c91c0b1d570 (milestone: 2.36), sys/mount.h
defines `fsconfig_command` which conflicts with linux/mount.h:

    .../usr/include/linux/mount.h:95:6: error: redeclaration of ‘enum fsconfig_command’

Remove #include <linux/fs.h> which pulls in linux/mount.h. Expand its 4 macros manually.
Android sys/mount.h doesn't define BLKBSZGET and it still needs linux/fs.h.
In the long term we should move Linux specific definitions to sanitizer_platform_limits_linux.cpp
but this commit is easy to cherry pick into older compiler-rt releases.

Fix llvm/llvm-project#56421

Reviewed By: #sanitizers, vitalybuka, zatrazz

Differential Revision: https://reviews.llvm.org/D129471
arichardson pushed a commit to CTSRD-CHERI/compiler-rt that referenced this issue Sep 12, 2023
…mount_attr conflict with glibc 2.36

It is generally not a good idea to mix usage of glibc headers and Linux UAPI
headers (https://sourceware.org/glibc/wiki/Synchronizing_Headers). In glibc
since 7eae6a91e9b1670330c9f15730082c91c0b1d570 (milestone: 2.36), sys/mount.h
defines `fsconfig_command` which conflicts with linux/mount.h:

    .../usr/include/linux/mount.h:95:6: error: redeclaration of ‘enum fsconfig_command’

Remove #include <linux/fs.h> which pulls in linux/mount.h. Expand its 4 macros manually.

Fix llvm/llvm-project#56421

Reviewed By: #sanitizers, vitalybuka, zatrazz

Differential Revision: https://reviews.llvm.org/D129471
arichardson pushed a commit to CTSRD-CHERI/compiler-rt that referenced this issue Sep 12, 2023
…mount_attr conflict with glibc 2.36

It is generally not a good idea to mix usage of glibc headers and Linux UAPI
headers (https://sourceware.org/glibc/wiki/Synchronizing_Headers). In glibc
since 7eae6a91e9b1670330c9f15730082c91c0b1d570 (milestone: 2.36), sys/mount.h
defines `fsconfig_command` which conflicts with linux/mount.h:

    .../usr/include/linux/mount.h:95:6: error: redeclaration of ‘enum fsconfig_command’

Remove #include <linux/fs.h> which pulls in linux/mount.h. Expand its 4 macros manually.
Android sys/mount.h doesn't define BLKBSZGET and it still needs linux/fs.h.
In the long term we should move Linux specific definitions to sanitizer_platform_limits_linux.cpp
but this commit is easy to cherry pick into older compiler-rt releases.

Fix llvm/llvm-project#56421

Reviewed By: #sanitizers, vitalybuka, zatrazz

Differential Revision: https://reviews.llvm.org/D129471
NexediGitlab pushed a commit to SlapOS/slapos that referenced this issue May 15, 2024
When compiling older GCC versions in newer machines, libsanitizer
does not compile, showing a error: `multiple definition of
'enum fsconfig_command'` (e.g.
llvm/llvm-project#56421).
This is because starting from Glibc 2.36, it is not possible to include
both "linux/fs.h" and "sys/mount.h".

We can apply a patch, similar to the one in
https://reviews.llvm.org/D129471 , but with the extension and lines
changed to match the file. This is also similar to the upstream fix.
NexediGitlab pushed a commit to SlapOS/slapos that referenced this issue May 16, 2024
When compiling older GCC versions in newer machines, libsanitizer
does not compile, showing a error: `multiple definition of
'enum fsconfig_command'` (e.g.
llvm/llvm-project#56421).
This is because starting from Glibc 2.36, it is not possible to include
both "linux/fs.h" and "sys/mount.h".

We can apply a patch, similar to the one in
https://reviews.llvm.org/D129471 , but with the extension and lines
changed to match the file. This is also similar to the upstream fix.

See merge request nexedi/slapos!1579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants