-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix build on FreeBSD #38335
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
Fix build on FreeBSD #38335
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -622,7 +622,7 @@ importer::getNormalInvocationArguments( | |
// using Glibc or a libc that respects that flag. This will cause some | ||
// source breakage however (specifically with strerror_r()) on Linux | ||
// without a workaround. | ||
if (triple.isOSFuchsia() || triple.isAndroid()) { | ||
if (triple.isOSFuchsia() || triple.isAndroid() || triple.isOSFreeBSD()) { | ||
// Many of the modern libc features are hidden behind feature macros like | ||
// _GNU_SOURCE or _XOPEN_SOURCE. | ||
invocationArgStrs.insert(invocationArgStrs.end(), { | ||
|
@@ -658,7 +658,7 @@ importer::getNormalInvocationArguments( | |
} | ||
} | ||
|
||
if (searchPathOpts.SDKPath.empty()) { | ||
if (searchPathOpts.SDKPath.empty() && !triple.isOSFreeBSD()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why special case this for FreeBSD, not working? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it excludes all system headers, causing e.g. the Glibc module to not work. I am unsure why this works on Linux, but not FreeBSD. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could try adding the ClangImporter flags |
||
invocationArgStrs.push_back("-Xclang"); | ||
invocationArgStrs.push_back("-nostdsysteminc"); | ||
} else { | ||
|
@@ -2069,6 +2069,10 @@ PlatformAvailability::PlatformAvailability(const LangOptions &langOpts) | |
deprecatedAsUnavailableMessage = ""; | ||
break; | ||
|
||
case PlatformKind::FreeBSD: | ||
deprecatedAsUnavailableMessage = ""; | ||
break; | ||
|
||
case PlatformKind::Windows: | ||
deprecatedAsUnavailableMessage = ""; | ||
break; | ||
|
@@ -2108,6 +2112,9 @@ bool PlatformAvailability::isPlatformRelevant(StringRef name) const { | |
case PlatformKind::OpenBSD: | ||
return name == "openbsd"; | ||
|
||
case PlatformKind::FreeBSD: | ||
return name == "freebsd"; | ||
|
||
case PlatformKind::Windows: | ||
return name == "windows"; | ||
|
||
|
@@ -2175,6 +2182,10 @@ bool PlatformAvailability::treatDeprecatedAsUnavailable( | |
// No deprecation filter on OpenBSD | ||
return false; | ||
|
||
case PlatformKind::FreeBSD: | ||
// No deprecation filter on FreeBSD | ||
return false; | ||
|
||
case PlatformKind::Windows: | ||
// No deprecation filter on Windows | ||
return false; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,8 @@ foreach(sdk ${SWIFT_SDKS}) | |
set(glibc_modulemap_source "bionic.modulemap.gyb") | ||
elseif(${sdk} STREQUAL OPENBSD) | ||
set(glibc_modulemap_source "libc-openbsd.modulemap.gyb") | ||
elseif(${sdk} STREQUAL FREEBSD) | ||
set(glibc_modulemap_source "libc-freebsd.modulemap.gyb") | ||
else() | ||
set(glibc_modulemap_source "glibc.modulemap.gyb") | ||
endif() | ||
|
@@ -119,12 +121,16 @@ foreach(sdk ${SWIFT_SDKS}) | |
list(APPEND glibc_modulemap_target_list ${copy_glibc_modulemap_static}) | ||
endif() | ||
|
||
set(glibc_header_out "${module_dir}/SwiftGlibc.h") | ||
handle_gyb_source_single(glibc_header_target | ||
SOURCE "SwiftGlibc.h.gyb" | ||
OUTPUT "${glibc_header_out}" | ||
FLAGS "-DCMAKE_SDK=${sdk}") | ||
list(APPEND glibc_modulemap_target_list ${glibc_header_target}) | ||
# FreeBSD uses a different module map that does not use this header, | ||
# so we don't generate it | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tried using this "Glibc" header instead on FreeBSD? I have it almost working for Android, #35707, so I think it should work for the BSDs too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried, but ran into a lot of missing functions. I did not have time to figure out what the problem is, yet, but I will take a look. Thanks for the link. I would like to land this first, though. |
||
if(NOT ${sdk} STREQUAL FREEBSD) | ||
drexin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
set(glibc_header_out "${module_dir}/SwiftGlibc.h") | ||
handle_gyb_source_single(glibc_header_target | ||
SOURCE "SwiftGlibc.h.gyb" | ||
OUTPUT "${glibc_header_out}" | ||
FLAGS "-DCMAKE_SDK=${sdk}") | ||
list(APPEND glibc_modulemap_target_list ${glibc_header_target}) | ||
endif() | ||
|
||
# If this SDK is a target for a non-native host, except if it's for Android | ||
# with its own native sysroot, create a native modulemap without a sysroot | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe, this is not FreeBSD specifics, but a libc++ one. Change the comment accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FreeBSD specifically disables the copy constructor by setting
_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
to preserve ABI. It is not a general limitation of libc++.