Skip to content

Commit 24bfdd1

Browse files
Some C++ packages fail to build on Apple platforms (#7267)
Disable clang modules for C++ compilation on Apple platforms ### Motivation: I didn't realize that there were some circumstances where passing `-fmodules` would enable clang modules for C++ on Apple platforms. ### Modifications: Go back to not passing `-fmodules` for Apple platforms. ### Result: C++ packages should be able to build properly again.
1 parent 191c4df commit 24bfdd1

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Sources/Build/BuildDescription/ClangTargetBuildDescription.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,10 @@ public final class ClangTargetBuildDescription {
243243
// Swift is able to use modules on non-Darwin platforms because it injects its own module maps
244244
// via vfs. However, nothing does that for C based compilation, and so non-Darwin platforms can't
245245
// support clang modules.
246-
// Note that if modules get enabled for other platforms later, we'll need to verify that
247-
// https://github.com/llvm/llvm-project/issues/55980 (crash on C++17 and later) is fixed, or don't
248-
// enable modules in the affected modes.
249-
let enableModules = triple.isDarwin()
246+
// Note that if modules get enabled for other platforms later, they can't be used with C++ until
247+
// https://github.com/llvm/llvm-project/issues/55980 (crash on C++17 and later) is fixed.
248+
// clang modules aren't fully supported in C++ mode in the current Darwin SDKs.
249+
let enableModules = triple.isDarwin() && !isCXX
250250
if enableModules {
251251
args += ["-fmodules", "-fmodule-name=" + target.c99name]
252252
}

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2889,14 +2889,14 @@ final class BuildPlanTests: XCTestCase {
28892889
var expectedLibBasicArgs = triple.isDarwin() ? ["-fobjc-arc"] : []
28902890
expectedLibBasicArgs += ["-target", defaultTargetTriple]
28912891
expectedLibBasicArgs += ["-O0", "-DSWIFT_PACKAGE=1", "-DDEBUG=1", "-fblocks"]
2892-
let shouldHaveModules = triple.isDarwin()
2893-
if shouldHaveModules {
2894-
expectedLibBasicArgs += ["-fmodules", "-fmodule-name=lib"]
2895-
}
2892+
// let shouldHaveModules = false // FIXME(5473) - support modules on non-Apple platforms, and also for C++ on any platform
2893+
// if shouldHaveModules {
2894+
// expectedLibBasicArgs += ["-fmodules", "-fmodule-name=lib"]
2895+
// }
28962896
expectedLibBasicArgs += ["-I", Pkg.appending(components: "Sources", "lib", "include").pathString]
2897-
if shouldHaveModules {
2898-
expectedLibBasicArgs += ["-fmodules-cache-path=\(buildPath.appending(components: "ModuleCache"))"]
2899-
}
2897+
// if shouldHaveModules {
2898+
// expectedLibBasicArgs += ["-fmodules-cache-path=\(buildPath.appending(components: "ModuleCache"))"]
2899+
// }
29002900
expectedLibBasicArgs += [
29012901
triple.isWindows() ? "-gdwarf" : "-g",
29022902
triple.isWindows() ? "-gdwarf" : "-g",

0 commit comments

Comments
 (0)