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

[SR-10086] Swift build fails on Linux with current glibc due to duplicate statx definition #3516

Closed
swift-ci opened this issue Mar 12, 2019 · 5 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-10086
Radar None
Original Reporter ryanw (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee ryanw (JIRA)
Priority Medium

md5: b9f52877148d2ec829f9562908820c4e

Issue Description:

Glibc now defines the statx function so CoreFoundation compilation under Linux (Fedora 30 dev) fails due to duplicate definition.

Removing the kernel header includes allows compiation to succeed:

index 88ebf4cd..22e6ea15 100644 --- a/CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h +++ b/CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h @@ -53,16 +53,6 @@
 #include <malloc/malloc.h>
 #endif
-#if TARGET_OS_LINUX 
-// required for statx() system call 
-#include <sys/syscall.h> 
-#include <sys/types.h> 
-#include <sys/stat.h> 
-#include <linux/stat.h> 
-#define AT_STATX_SYNC_AS_STAT 0x0000 /* 
- Do whatever stat() does */ 
-#endif 
-
- 
_CF_EXPORT_SCOPE_BEGIN CF_CROSS_PLATFORM_EXPORT Boolean _CFCalendarGetNextWeekend(CFCalendarRef calendar, _CFCalendarWeekendRange *range);
@belkadan
Copy link

Presumably we'll have to conditionalize this on the version of glibc (or the presence of a macro or something) rather than remove it. We're not going to stop supporting the existing versions of Ubuntu just yet.

@spevans
Copy link
Collaborator

spevans commented Mar 15, 2019

It looks like it was added in v2.28 according to https://www.sourceware.org/ml/libc-alpha/2018-08/msg00003.html

so it should be possible to wrap it in :

#include <features.h>

#if __GLIBC_PREREQ(2, 28)
    [statx is included]
#else
    [fallback to manually defining it]
#endif

 

@belkadan
Copy link

cc @millenomi

@swift-ci
Copy link
Contributor Author

Comment by Ryan (JIRA)

Pull request added.

@swift-ci
Copy link
Contributor Author

Comment by Ryan (JIRA)

Closed by #2124 Thanks @belkadan, @spevans and @millenomi!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
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

3 participants