Skip to content

Linux packages fail to build with LLVM 18 and Apple 2023 versions of clang #7241

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

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,15 @@ public final class ClangTargetBuildDescription {
}

// Enable Clang module flags, if appropriate.
let enableModules: Bool
let triple = self.buildParameters.triple
if toolsVersion < .v5_8 {
// For version < 5.8, we enable them except in these cases:
// 1. on Darwin when compiling for C++, because C++ modules are disabled on Apple-built Clang releases
// 2. on Windows when compiling for any language, because of issues with the Windows SDK
// 3. on Android when compiling for any language, because of issues with the Android SDK
enableModules = !(triple.isDarwin() && isCXX) && !triple.isWindows() && !triple.isAndroid()
} else {
// For version >= 5.8, we disable them when compiling for C++ regardless of platforms, see:
// https://github.com/llvm/llvm-project/issues/55980 for clang frontend crash when module
// enabled for C++ on c++17 standard and above.
enableModules = !isCXX && !triple.isWindows() && !triple.isAndroid()
}

// Swift is able to use modules on non-Darwin platforms because it injects its own module maps
// via vfs. However, nothing does that for C based compilation, and so non-Darwin platforms can't
// support clang modules.
// Note that if modules get enabled for other platforms later, we'll need to verify that
// https://github.com/llvm/llvm-project/issues/55980 (crash on C++17 and later) is fixed, or don't
// enable modules in the affected modes.
let enableModules = triple.isDarwin()
if enableModules {
// Using modules currently conflicts with the Windows and Android SDKs.
args += ["-fmodules", "-fmodule-name=" + target.c99name]
}

Expand Down
21 changes: 10 additions & 11 deletions Tests/BuildTests/BuildPlanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1353,11 +1353,11 @@ final class BuildPlanTests: XCTestCase {
args += ["-target", defaultTargetTriple]
args += ["-O0", "-DSWIFT_PACKAGE=1", "-DDEBUG=1"]
args += ["-fblocks"]
#if !os(Windows) // FIXME(5473) - modules flags on Windows dropped
#if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
args += ["-fmodules", "-fmodule-name=extlib"]
#endif
args += ["-I", ExtPkg.appending(components: "Sources", "extlib", "include").pathString]
#if !os(Windows) // FIXME(5473) - modules flags on Windows dropped
#if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
args += ["-fmodules-cache-path=\(buildPath.appending(components: "ModuleCache"))"]
#endif

Expand All @@ -1382,7 +1382,7 @@ final class BuildPlanTests: XCTestCase {

args += ["-O0", "-DSWIFT_PACKAGE=1", "-DDEBUG=1"]
args += ["-fblocks"]
#if !os(Windows) // FIXME(5473) - modules flags on Windows dropped
#if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
args += ["-fmodules", "-fmodule-name=exe"]
#endif
args += [
Expand All @@ -1392,7 +1392,7 @@ final class BuildPlanTests: XCTestCase {
"-I", ExtPkg.appending(components: "Sources", "extlib", "include").pathString,
"-fmodule-map-file=\(buildPath.appending(components: "extlib.build", "module.modulemap"))",
]
#if !os(Windows) // FIXME(5473) - modules flags on Windows dropped
#if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
args += ["-fmodules-cache-path=\(buildPath.appending(components: "ModuleCache"))"]
#endif
args += [hostTriple.isWindows() ? "-gdwarf" : "-g"]
Expand Down Expand Up @@ -1710,11 +1710,11 @@ final class BuildPlanTests: XCTestCase {

args += ["-O0", "-DSWIFT_PACKAGE=1", "-DDEBUG=1"]
args += ["-fblocks"]
#if !os(Windows) // FIXME(5473) - modules flags on Windows dropped
#if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
args += ["-fmodules", "-fmodule-name=lib"]
#endif
args += ["-I", Pkg.appending(components: "Sources", "lib", "include").pathString]
#if !os(Windows) // FIXME(5473) - modules flags on Windows dropped
#if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
args += ["-fmodules-cache-path=\(buildPath.appending(components: "ModuleCache"))"]
#endif
args += [hostTriple.isWindows() ? "-gdwarf" : "-g"]
Expand Down Expand Up @@ -2866,11 +2866,11 @@ final class BuildPlanTests: XCTestCase {
var expectedExeBasicArgs = triple.isDarwin() ? ["-fobjc-arc"] : []
expectedExeBasicArgs += ["-target", defaultTargetTriple]
expectedExeBasicArgs += ["-O0", "-DSWIFT_PACKAGE=1", "-DDEBUG=1", "-fblocks"]
#if !os(Windows) // FIXME(5473) - modules flags on Windows dropped
#if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
expectedExeBasicArgs += ["-fmodules", "-fmodule-name=exe"]
#endif
expectedExeBasicArgs += ["-I", Pkg.appending(components: "Sources", "exe", "include").pathString]
#if !os(Windows) // FIXME(5473) - modules flags on Windows dropped
#if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
expectedExeBasicArgs += ["-fmodules-cache-path=\(buildPath.appending(components: "ModuleCache"))"]
#endif

Expand All @@ -2889,7 +2889,7 @@ final class BuildPlanTests: XCTestCase {
var expectedLibBasicArgs = triple.isDarwin() ? ["-fobjc-arc"] : []
expectedLibBasicArgs += ["-target", defaultTargetTriple]
expectedLibBasicArgs += ["-O0", "-DSWIFT_PACKAGE=1", "-DDEBUG=1", "-fblocks"]
let shouldHaveModules = !(triple.isDarwin() || triple.isWindows() || triple.isAndroid())
let shouldHaveModules = triple.isDarwin()
if shouldHaveModules {
expectedLibBasicArgs += ["-fmodules", "-fmodule-name=lib"]
}
Expand Down Expand Up @@ -3455,9 +3455,8 @@ final class BuildPlanTests: XCTestCase {
let args = [
"-target", "wasm32-unknown-wasi",
"-O0", "-DSWIFT_PACKAGE=1", "-DDEBUG=1",
"-fblocks", "-fmodules", "-fmodule-name=lib",
"-fblocks",
"-I", Pkg.appending(components: "Sources", "lib", "include").pathString,
"-fmodules-cache-path=\(buildPath.appending(components: "ModuleCache"))",
"-g",
]
XCTAssertEqual(try lib.basicArguments(isCXX: false), args)
Expand Down