dev-lang/swift: fix building when dev-libs/libdispatch is present

Swift currently fails to build if `dev-libs/libdispatch` is installed
because it globally installs private `libdispatch` headers which get
unexpectedly picked up during the Swift build. Since the headers are not
expected to be present when building Swift on non-Darwin platforms, the
check for the header can be patched out.

Signed-off-by: Itai Ferber <itai@itaiferber.net>
This commit is contained in:
Itai Ferber
2026-04-19 20:31:06 -04:00
parent 4f760635c2
commit 712f2b61ba
8 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
# `DispatchGlobalExecutor` checks for the presence of `dispatch/private.h` for
# certain low-level libdispatch functionality, and because the header is
# normally only available on Darwin platforms (it is never installed as part of
# a normal Swift build on any platform), makes certain assumptions about
# symbols available there. However, `dev-libs/libdispatch` explicitly installs
# private headers system-wide for `gnustep-base/libobjc2`, and those get picked
# up during the Swift build. Because of the structure of the header on Linux,
# anyone who has `dev-libs/libdispatch` installed will fail to build.
--- a/swift/stdlib/public/Concurrency/DispatchGlobalExecutor.inc
+++ b/swift/stdlib/public/Concurrency/DispatchGlobalExecutor.inc
@@ -33,11 +33,6 @@
#endif
#endif
-#if __has_include(<dispatch/private.h>)
-#include <dispatch/private.h>
-#define SWIFT_CONCURRENCY_HAS_DISPATCH_PRIVATE 1
-#endif
-
// Ensure that Job's layout is compatible with what Dispatch expects.
// Note: MinimalDispatchObjectHeader just has the fields we care about, it is
// not complete and should not be used for anything other than these asserts.

View File

@@ -0,0 +1,23 @@
# `DispatchGlobalExecutor` checks for the presence of `dispatch/private.h` for
# certain low-level libdispatch functionality, and because the header is
# normally only available on Darwin platforms (it is never installed as part of
# a normal Swift build on any platform), makes certain assumptions about
# symbols available there. However, `dev-libs/libdispatch` explicitly installs
# private headers system-wide for `gnustep-base/libobjc2`, and those get picked
# up during the Swift build. Because of the structure of the header on Linux,
# anyone who has `dev-libs/libdispatch` installed will fail to build.
--- a/swift/stdlib/public/Concurrency/DispatchGlobalExecutor.cpp
+++ b/swift/stdlib/public/Concurrency/DispatchGlobalExecutor.cpp
@@ -45,11 +45,6 @@
#endif
#endif
-#if __has_include(<dispatch/private.h>)
-#include <dispatch/private.h>
-#define SWIFT_CONCURRENCY_HAS_DISPATCH_PRIVATE 1
-#endif
-
#include "Error.h"
#include "ExecutorImpl.h"
#include "TaskPrivate.h"

View File

@@ -0,0 +1,23 @@
# `DispatchGlobalExecutor` checks for the presence of `dispatch/private.h` for
# certain low-level libdispatch functionality, and because the header is
# normally only available on Darwin platforms (it is never installed as part of
# a normal Swift build on any platform), makes certain assumptions about
# symbols available there. However, `dev-libs/libdispatch` explicitly installs
# private headers system-wide for `gnustep-base/libobjc2`, and those get picked
# up during the Swift build. Because of the structure of the header on Linux,
# anyone who has `dev-libs/libdispatch` installed will fail to build.
--- a/swift/stdlib/public/Concurrency/DispatchGlobalExecutor.cpp
+++ b/swift/stdlib/public/Concurrency/DispatchGlobalExecutor.cpp
@@ -46,11 +46,6 @@
#endif
#endif
-#if __has_include(<dispatch/private.h>)
-#include <dispatch/private.h>
-#define SWIFT_CONCURRENCY_HAS_DISPATCH_PRIVATE 1
-#endif
-
#include "Error.h"
#include "ExecutorImpl.h"
#include "TaskPrivate.h"

View File

@@ -0,0 +1 @@
../swift-6.2.4/disable-libdispatch-private-header-check.patch

View File

@@ -53,6 +53,7 @@ SRC_URI="
PATCHES=(
"${FILESDIR}/${PF}/backtracing-noexecstack.patch"
"${FILESDIR}/${PF}/disable-libdispatch-private-header-check.patch"
"${FILESDIR}/${PF}/disable-libdispatch-werror.patch"
"${FILESDIR}/${PF}/indexstoredb-constant.patch"
"${FILESDIR}/${PF}/link-ncurses-tinfo.patch"

View File

@@ -55,6 +55,7 @@ SRC_URI="
PATCHES=(
"${FILESDIR}/${PF}/backtracing-noexecstack.patch"
"${FILESDIR}/${PF}/disable-libdispatch-private-header-check.patch"
"${FILESDIR}/${PF}/disable-libdispatch-werror.patch"
"${FILESDIR}/${PF}/fix-issues-caused-by-build-system-updates.patch"
"${FILESDIR}/${PF}/link-ncurses-tinfo.patch"

View File

@@ -56,6 +56,7 @@ SRC_URI="
PATCHES=(
"${FILESDIR}/${PF}/backtracing-noexecstack.patch"
"${FILESDIR}/${PF}/disable-libdispatch-private-header-check.patch"
"${FILESDIR}/${PF}/disable-libdispatch-werror.patch"
"${FILESDIR}/${PF}/fix-issues-caused-by-build-system-updates.patch"
"${FILESDIR}/${PF}/link-ncurses-tinfo.patch"

View File

@@ -58,6 +58,7 @@ SRC_URI="
PATCHES=(
"${FILESDIR}/${PF}/backtracing-noexecstack.patch"
"${FILESDIR}/${PF}/disable-libdispatch-private-header-check.patch"
"${FILESDIR}/${PF}/disable-libdispatch-werror.patch"
"${FILESDIR}/${PF}/fix-issues-caused-by-build-system-updates.patch"
"${FILESDIR}/${PF}/link-ncurses-tinfo.patch"