Skip to content

Commit 9a2fdbc

Browse files
committed
Fix -fmodule-map-file pointing to non-existent path
We were passing this unconditionally which would break in the case where we weren't generated a module map because an explicit one exists. rdar://74115399
1 parent 543f9b0 commit 9a2fdbc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Sources/XCBuildSupport/PIFBuilder.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
563563
let generatedModuleMapDir = "$(OBJROOT)/GeneratedModuleMaps/$(PLATFORM_NAME)"
564564
let moduleMapFile = "\(generatedModuleMapDir)/\(target.name).modulemap"
565565
let moduleMapFileContents: String?
566+
let shouldImpartModuleMap: Bool
566567

567568
if let clangTarget = target.underlyingTarget as? ClangTarget {
568569
// Let the target itself find its own headers.
@@ -583,8 +584,11 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
583584
export *
584585
}
585586
"""
587+
588+
shouldImpartModuleMap = true
586589
} else {
587590
moduleMapFileContents = nil
591+
shouldImpartModuleMap = false
588592
}
589593
} else if let swiftTarget = target.underlyingTarget as? SwiftTarget {
590594
settings[.SWIFT_VERSION] = swiftTarget.swiftVersion.description
@@ -598,6 +602,8 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
598602
export *
599603
}
600604
"""
605+
606+
shouldImpartModuleMap = true
601607
} else {
602608
throw InternalError("unexpected target")
603609
}
@@ -608,7 +614,9 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
608614
}
609615

610616
// Pass the path of the module map up to all direct and indirect clients.
611-
impartedSettings[.OTHER_CFLAGS, default: ["$(inherited)"]].append("-fmodule-map-file=\(moduleMapFile)")
617+
if shouldImpartModuleMap {
618+
impartedSettings[.OTHER_CFLAGS, default: ["$(inherited)"]].append("-fmodule-map-file=\(moduleMapFile)")
619+
}
612620
impartedSettings[.OTHER_LDRFLAGS] = []
613621

614622
if target.underlyingTarget.isCxx {

0 commit comments

Comments
 (0)