Skip to content

Fix -fmodule-map-file pointing to non-existent path #3247

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
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
10 changes: 9 additions & 1 deletion Sources/XCBuildSupport/PIFBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
let generatedModuleMapDir = "$(OBJROOT)/GeneratedModuleMaps/$(PLATFORM_NAME)"
let moduleMapFile = "\(generatedModuleMapDir)/\(target.name).modulemap"
let moduleMapFileContents: String?
let shouldImpartModuleMap: Bool

if let clangTarget = target.underlyingTarget as? ClangTarget {
// Let the target itself find its own headers.
Expand All @@ -583,8 +584,11 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
export *
}
"""

shouldImpartModuleMap = true
} else {
moduleMapFileContents = nil
shouldImpartModuleMap = false
}
} else if let swiftTarget = target.underlyingTarget as? SwiftTarget {
settings[.SWIFT_VERSION] = swiftTarget.swiftVersion.description
Expand All @@ -598,6 +602,8 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
export *
}
"""

shouldImpartModuleMap = true
} else {
throw InternalError("unexpected target")
}
Expand All @@ -608,7 +614,9 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
}

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

if target.underlyingTarget.isCxx {
Expand Down