Skip to content

Commit 0895ff6

Browse files
committed
FreeBSD/OpenBSD: Gate GNU-only API
FreeBSD and OpenBSD currently use the Glibc modulemap to import the C runtimes so `canImport(Glibc)` returns true. These systems are not actually glibc though and do not have the `gnu_get_libc_version` extension, resulting in build failures. Gating the use of the API on more than glibc to allow these platforms to compile.
1 parent 3278217 commit 0895ff6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Sources/Testing/ExitTests/SpawnProcess.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func spawnExecutable(
136136
// standardized in POSIX.1-2024 (see https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn_file_actions_adddup2.html
137137
// and https://www.austingroupbugs.net/view.php?id=411).
138138
_ = posix_spawn_file_actions_adddup2(fileActions, fd, fd)
139-
#if canImport(Glibc)
139+
#if canImport(Glibc) && !os(FreeBSD) && !os(OpenBSD)
140140
if _slowPath(glibcVersion.major < 2 || (glibcVersion.major == 2 && glibcVersion.minor < 29)) {
141141
// This system is using an older version of glibc that does not
142142
// implement FD_CLOEXEC clearing in posix_spawn_file_actions_adddup2(),

Sources/Testing/Support/Versions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ let swiftStandardLibraryVersion: String = {
153153
return "unknown"
154154
}()
155155

156-
#if canImport(Glibc)
156+
#if canImport(Glibc) && !os(FreeBSD) && !os(OpenBSD)
157157
/// The (runtime, not compile-time) version of glibc in use on this system.
158158
///
159159
/// This value is not part of the public interface of the testing library.

0 commit comments

Comments
 (0)