Skip to content

Commit 2af57b4

Browse files
committed
Revert "Infer [system] based on install path when generating clang modulemaps"
This reverts commit 0a658dd.
1 parent 95575f4 commit 2af57b4

File tree

4 files changed

+10
-76
lines changed

4 files changed

+10
-76
lines changed

Sources/SWBCore/Settings/BuiltinMacros.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,6 @@ public final class BuiltinMacros {
852852
public static let MODULEMAP_FILE_CONTENTS = BuiltinMacros.declareStringMacro("MODULEMAP_FILE_CONTENTS")
853853
public static let MODULEMAP_PATH = BuiltinMacros.declareStringMacro("MODULEMAP_PATH")
854854
public static let MODULEMAP_PRIVATE_FILE = BuiltinMacros.declareStringMacro("MODULEMAP_PRIVATE_FILE")
855-
public static let GENERATED_MODULEMAPS_USE_SYSTEM = BuiltinMacros.declareBooleanMacro("GENERATED_MODULEMAPS_USE_SYSTEM")
856855
public static let MODULES_FOLDER_PATH = BuiltinMacros.declarePathMacro("MODULES_FOLDER_PATH")
857856
public static let MODULE_VERIFIER_KIND = BuiltinMacros.declareEnumMacro("MODULE_VERIFIER_KIND") as EnumMacroDeclaration<ModuleVerifierKind>
858857
public static let MODULE_VERIFIER_LSV = BuiltinMacros.declareBooleanMacro("MODULE_VERIFIER_LSV")
@@ -1920,7 +1919,6 @@ public final class BuiltinMacros {
19201919
MODULEMAP_FILE_CONTENTS,
19211920
MODULEMAP_PATH,
19221921
MODULEMAP_PRIVATE_FILE,
1923-
GENERATED_MODULEMAPS_USE_SYSTEM,
19241922
MODULES_FOLDER_PATH,
19251923
MODULE_CACHE_DIR,
19261924
MODULE_NAME,

Sources/SWBCore/Settings/Settings.swift

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,18 +2048,17 @@ private class SettingsBuilder {
20482048
// FIXME: Arguably we should emit a warning if the optimization settings are out of sync, as the user may be getting weird results. It's not clear if there are lots of old projects which might spuriously get such a warning, and this isn't a new state of affairs.
20492049
table.push(BuiltinMacros.IS_UNOPTIMIZED_BUILD, literal: (scope.evaluate(BuiltinMacros.GCC_OPTIMIZATION_LEVEL) == "0" || scope.evaluate(BuiltinMacros.SWIFT_OPTIMIZATION_LEVEL) == "-Onone"))
20502050

2051-
let privateInstallPaths = scope.evaluate(BuiltinMacros.__KNOWN_SPI_INSTALL_PATHS).map { Path($0) }
2052-
let publicInstallPaths = [
2053-
Path("/System/Library/Frameworks"),
2054-
Path("/System/Library/SubFrameworks"),
2055-
Path("/usr/lib"),
2056-
Path("/System/iOSSupport/System/Library/Frameworks"),
2057-
Path("/System/iOSSupport/System/Library/SubFrameworks"),
2058-
Path("/System/iOSSupport/usr/lib"),]
2059-
20602051
// If unset, infer the default SWIFT_LIBRARY_LEVEL from the INSTALL_PATH.
20612052
if scope.evaluateAsString(BuiltinMacros.SWIFT_LIBRARY_LEVEL).isEmpty &&
20622053
scope.evaluate(BuiltinMacros.MACH_O_TYPE) == "mh_dylib" {
2054+
let privateInstallPaths = scope.evaluate(BuiltinMacros.__KNOWN_SPI_INSTALL_PATHS).map { Path($0) }
2055+
let publicInstallPaths = [
2056+
Path("/System/Library/Frameworks"),
2057+
Path("/System/Library/SubFrameworks"),
2058+
Path("/usr/lib"),
2059+
Path("/System/iOSSupport/System/Library/Frameworks"),
2060+
Path("/System/iOSSupport/System/Library/SubFrameworks"),
2061+
Path("/System/iOSSupport/usr/lib"),]
20632062
let installPath = scope.evaluate(BuiltinMacros.INSTALL_PATH)
20642063

20652064
if table.contains(BuiltinMacros.SKIP_INSTALL) {
@@ -2074,16 +2073,6 @@ private class SettingsBuilder {
20742073
// Else, leave it to the compiler's default.
20752074
}
20762075

2077-
// If unset, infer the default SWIFT_LIBRARY_LEVEL from the INSTALL_PATH.
2078-
if scope.evaluateAsString(BuiltinMacros.GENERATED_MODULEMAPS_USE_SYSTEM).isEmpty {
2079-
let systemInstallPaths = publicInstallPaths + privateInstallPaths
2080-
let installPath = scope.evaluate(BuiltinMacros.INSTALL_PATH)
2081-
2082-
if systemInstallPaths.contains(where: { $0.isAncestorOrEqual(of: installPath) }) {
2083-
table.push(BuiltinMacros.GENERATED_MODULEMAPS_USE_SYSTEM, literal: true)
2084-
}
2085-
}
2086-
20872076
// Overrides specific to building for Mac Catalyst.
20882077
if platform?.familyName == "macOS", let sdkVariant, sdkVariant.isMacCatalyst {
20892078
// macCatalyst does not support ODR, but Foundation supports ODR APIs in Mac Catalyst loading the resources from the app bundle itself. Therefore, we simply disable ODR for Mac Catalyst.

Sources/SWBTaskConstruction/TaskProducers/OtherTaskProducers/ModuleMapTaskProducer.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,9 @@ final class ModuleMapTaskProducer: PhasedTaskProducer, TaskProducer {
370370
//
371371
// NOTE: This is unrelated to the "MODULE_NAME" build setting, which is much older and used by kexts.
372372
let moduleName = scope.evaluate(BuiltinMacros.PRODUCT_MODULE_NAME)
373-
let isSystem = scope.evaluate(BuiltinMacros.GENERATED_MODULEMAPS_USE_SYSTEM)
374373

375374
// Create the trivial synthesized module map.
376-
outputStream <<< "framework module \(try moduleName.asModuleIdentifierString()) \(isSystem ? "[system] " : ""){\n"
375+
outputStream <<< "framework module \(try moduleName.asModuleIdentifierString()) {\n"
377376
outputStream <<< " umbrella header \"\(umbrellaHeaderName.asCStringLiteralContent)\"\n"
378377
outputStream <<< " export *\n"
379378
outputStream <<< "\n"
@@ -394,13 +393,12 @@ final class ModuleMapTaskProducer: PhasedTaskProducer, TaskProducer {
394393

395394
let interfaceHeaderName = scope.evaluate(BuiltinMacros.SWIFT_OBJC_INTERFACE_HEADER_NAME)
396395
assert(!interfaceHeaderName.isEmpty) // implied by exportsSwiftObjCAPI
397-
let isSystem = scope.evaluate(BuiltinMacros.GENERATED_MODULEMAPS_USE_SYSTEM)
398396

399397
// Swift only module map contents is a top level framework module. Swift contents
400398
// for a mixed module map is a submodule of the top level framework module (whose
401399
// name had better be PRODUCT_MODULE_NAME or things are going to get weird).
402400
if moduleInfo.forSwiftOnly {
403-
outputStream <<< "framework module \(try moduleName.asModuleIdentifierString()) \(isSystem ? "[system] " : ""){\n"
401+
outputStream <<< "framework module \(try moduleName.asModuleIdentifierString()) {\n"
404402
} else {
405403
outputStream <<< "\n"
406404
outputStream <<< "module \(try moduleName.asModuleIdentifierString()).Swift {\n"

Tests/SWBTaskConstructionTests/ModuleMapTaskConstructionTests.swift

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -696,57 +696,6 @@ fileprivate struct ModuleMapTaskConstructionTests: CoreBasedTests {
696696
}
697697
}
698698

699-
@Test(.requireSDKs(.macOS))
700-
func moduleMapGenerationSystemInference() async throws {
701-
let testProject = TestProject(
702-
"Project",
703-
groupTree: TestGroup(
704-
"Group",
705-
children: [
706-
TestFile("CookieCutter.h"),
707-
TestFile("CSource.c"),
708-
]),
709-
buildConfigurations: [
710-
TestBuildConfiguration("Debug", buildSettings: [
711-
"DEFINES_MODULE": "YES",
712-
"PRODUCT_NAME": "$(TARGET_NAME)",
713-
"GENERATE_INFOPLIST_FILE": "YES",
714-
"INSTALL_PATH": "/System/Library/Frameworks",
715-
])
716-
],
717-
targets: [
718-
TestStandardTarget(
719-
"CookieCutter",
720-
type: .framework,
721-
buildPhases: [
722-
TestHeadersBuildPhase([
723-
TestBuildFile("CookieCutter.h", headerVisibility: .public),
724-
]),
725-
TestSourcesBuildPhase([
726-
"CSource.c",
727-
]),
728-
]
729-
),
730-
])
731-
let tester = try await TaskConstructionTester(getCore(), testProject)
732-
let SRCROOT = tester.workspace.projects[0].sourceRoot.str
733-
734-
await tester.checkBuild() { results in
735-
results.checkTarget("CookieCutter") { target in
736-
results.checkWriteAuxiliaryFileTask(.matchTarget(target), .matchRule(["WriteAuxiliaryFile", "\(SRCROOT)/build/Project.build/Debug/CookieCutter.build/module.modulemap"])) { task, contents in
737-
#expect(contents == (OutputByteStream()
738-
<<< "framework module CookieCutter [system] {\n"
739-
<<< " umbrella header \"CookieCutter.h\"\n"
740-
<<< " export *\n"
741-
<<< "\n"
742-
<<< " module * { export * }\n"
743-
<<< "}\n").bytes)
744-
}
745-
}
746-
results.checkNoDiagnostics()
747-
}
748-
}
749-
750699
@Test(.requireSDKs(.macOS))
751700
func staticModuleMapContents() async throws {
752701
let testProject = try await TestProject(

0 commit comments

Comments
 (0)