Repository navigation
Tolerate spurious emit-module in singleFileCompile on all non-Darwin hosts - #1849
Merged
jakepetroules merged 1 commit intoOct 7, 2026
Conversation
…hosts The C file compile depends on the target's Swift generated headers, so the Swift driver is re-planned and decides whether emit-module is up to date by checking that every source is strictly older than every emit-module output. swift-driver truncates modification times to whole seconds on non-Darwin platforms, so when SwiftFile.swift and the module outputs from the first build are written within the same second, emit-module is re-run. The existing workaround only applied to Linux, so the test was still flaky on FreeBSD. Apply it to every non-macOS host, and document the root cause in place of the FIXME. The underlying driver fix is swiftlang/swift-driver#2228.
jakepetroules
requested review from
cmcgee1024,
daveinglis,
mhrawdon,
owenv,
rconnell9 and
rjmansfield
as code owners
October 7, 2026 18:09
Collaborator
Author
|
@swift-ci test |
jakepetroules
enabled auto-merge (rebase)
October 7, 2026 18:17
mhrawdon
approved these changes
Oct 7, 2026
Contributor
|
@swift-ci test macOS |
1 similar comment
Collaborator
Author
|
@swift-ci test macOS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BuildCommandTests.singleFileCompilehas been nondeterministically failing on non-Darwin hosts with:Root cause
CFile.olegitimately depends on the target'sswift-generated-headersgate, because a C file may includeaLibrary-Swift.h. So the Swift driver is re-planned and decides whether the emit-module job is up to date.FirstWaveComputer.computeCanSkipEmitModuleTasks).SwiftFile.swiftand the first build's module outputs are written in the same second (they're about 120ms apart in this test), they compare equal, so emit-module is re-run.I confirmed this on Linux by instrumenting the driver: the test failed in exactly the runs where the source and outputs shared a whole-second timestamp, and passed when they straddled a second boundary. macOS keeps nanosecond precision and never hits it.
Change
The existing workaround only checked
runDestination == .linux, so the test was still flaky on FreeBSD (e.g. in CI for #638). This applies it to every non-macOS host and replaces the "needs to be investigated" FIXME with the explanation.The underlying fix is swiftlang/swift-driver#2228. With that change, this test passed 15/15 runs on Linux with the workaround disabled, versus failing roughly two thirds of the time before. The workaround can be removed once CI picks up a driver with that fix.