Skip to content

Fix PIF MODULEMAP_PATH when a package has a hand-authored module map#10065

Merged
owenv merged 1 commit into
swiftlang:release/6.4.xfrom
owenv:owenv/modulemappath
May 18, 2026
Merged

Fix PIF MODULEMAP_PATH when a package has a hand-authored module map#10065
owenv merged 1 commit into
swiftlang:release/6.4.xfrom
owenv:owenv/modulemappath

Conversation

@owenv
Copy link
Copy Markdown
Contributor

@owenv owenv commented May 15, 2026

When a target had a hand-authored module map, the PIF was correctly imparting the custom path to clients via OTHER_CFLAGS, but was incorrectly setting MODULEMAP_PATH to the path which would have been used if the build system had generated one. This doesn't impact compilation, but when symbol graph extraction was enabled it caused clang -extractapi to try to load the module map from the wrong path, failing the build.

This PR refactors the modulemap path computation so that it is explicitly assigned once along every path, fixing the original issue and hopefully making the code a bit clearer so it's easier to understand going forward.

rdar://173020089

@owenv
Copy link
Copy Markdown
Contributor Author

owenv commented May 15, 2026

@swift-ci test

@pmattos pmattos self-requested a review May 15, 2026 02:24
@pmattos
Copy link
Copy Markdown
Contributor

pmattos commented May 15, 2026

For reference: follow-up to our previous fix in PackagePIFProjectBuilder+Modules.swift (#9295).

@plemarquand
Copy link
Copy Markdown
Contributor

Windows failure looks legitimate:

00:44:07  × Test moduleMapPathAndContents() recorded an issue at PIFBuilderTests.swift:740:17: Expectation failed: (contents → "module UmbrellaHeader {
00:44:07  umbrella header "C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\ModuleMapGenerationCases.VCmNaF\\ModuleMapGenerationCases\\Sources\\UmbrellaHeader\\include\\UmbrellaHeader\\UmbrellaHeader.h"
00:44:07  export *
00:44:07  }").contains(RelativePath("UmbrellaHeader")
00:44:07                      .appending(components: ["include", "UmbrellaHeader", "UmbrellaHeader.h"]).pathString → "UmbrellaHeader\include\UmbrellaHeader\UmbrellaHeader.h")
00:44:07  × Test moduleMapPathAndContents() recorded an issue at PIFBuilderTests.swift:759:17: Expectation failed: (contents → "module UmbrellaDirectoryInclude {
00:44:07  umbrella "C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\ModuleMapGenerationCases.VCmNaF\\ModuleMapGenerationCases\\Sources\\UmbrellaDirectoryInclude\\include"
00:44:07  export *
00:44:07  }").contains(RelativePath("UmbrellaDirectoryInclude")
00:44:07                      .appending(component: "include").pathString → "UmbrellaDirectoryInclude\include")
00:44:07  × Test moduleMapPathAndContents() failed after 1757.776 seconds with 2 issues.

@bkhouri
Copy link
Copy Markdown
Contributor

bkhouri commented May 15, 2026

Windows failure looks legitimate:

00:44:07  × Test moduleMapPathAndContents() recorded an issue at PIFBuilderTests.swift:740:17: Expectation failed: (contents → "module UmbrellaHeader {
00:44:07  umbrella header "C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\ModuleMapGenerationCases.VCmNaF\\ModuleMapGenerationCases\\Sources\\UmbrellaHeader\\include\\UmbrellaHeader\\UmbrellaHeader.h"
00:44:07  export *
00:44:07  }").contains(RelativePath("UmbrellaHeader")
00:44:07                      .appending(components: ["include", "UmbrellaHeader", "UmbrellaHeader.h"]).pathString → "UmbrellaHeader\include\UmbrellaHeader\UmbrellaHeader.h")
00:44:07  × Test moduleMapPathAndContents() recorded an issue at PIFBuilderTests.swift:759:17: Expectation failed: (contents → "module UmbrellaDirectoryInclude {
00:44:07  umbrella "C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\ModuleMapGenerationCases.VCmNaF\\ModuleMapGenerationCases\\Sources\\UmbrellaDirectoryInclude\\include"
00:44:07  export *
00:44:07  }").contains(RelativePath("UmbrellaDirectoryInclude")
00:44:07                      .appending(component: "include").pathString → "UmbrellaDirectoryInclude\include")
00:44:07  × Test moduleMapPathAndContents() failed after 1757.776 seconds with 2 issues.

This looks more like a path separator issue with the test.

The actual is

00:44:07  × Test moduleMapPathAndContents() recorded an issue at PIFBuilderTests.swift:740:17: Expectation failed: (contents → "module UmbrellaHeader {
00:44:07  umbrella header "C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\ModuleMapGenerationCases.VCmNaF\\ModuleMapGenerationCases\\Sources\\UmbrellaHeader\\include\\UmbrellaHeader\\UmbrellaHeader.h"
00:44:07  export *
00:44:07  }").contains(RelativePath("UmbrellaHeader")
00:44:07                      .appending(components: ["include", "UmbrellaHeader", "UmbrellaHeader.h"]).pathString → "UmbrellaHeader\include\UmbrellaHeader\UmbrellaHeader.h")

The expected has a single \ while the actual has double (\\).

it's the same with the second expectation failure.

@owenv owenv force-pushed the owenv/modulemappath branch from 98d8360 to 64dcc84 Compare May 15, 2026 16:46
@owenv
Copy link
Copy Markdown
Contributor Author

owenv commented May 15, 2026

@swift-ci test

@owenv
Copy link
Copy Markdown
Contributor Author

owenv commented May 15, 2026

@swift-ci test windows

@owenv
Copy link
Copy Markdown
Contributor Author

owenv commented May 15, 2026

@swift-ci test macOS

@owenv owenv merged commit 3950848 into swiftlang:release/6.4.x May 18, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants