Skip to content

Make Explicitly-Built Modules default for non-immediate compilation - #2134

Draft
artemcm wants to merge 12 commits into
mainfrom
DefaultEBM
Draft

artemcm wants to merge 12 commits into
mainfrom
DefaultEBM

Conversation

@artemcm

@artemcm artemcm commented May 8, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@artemcm

artemcm commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

1 similar comment
@artemcm

artemcm commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@artemcm
artemcm force-pushed the DefaultEBM branch 2 times, most recently from b6dd80a to 94e5658 Compare September 28, 2026 16:57
@artemcm

artemcm commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@artemcm

artemcm commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@artemcm

artemcm commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@artemcm

artemcm commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test Windows platform

@artemcm

artemcm commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@artemcm

artemcm commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test Windows

@artemcm
artemcm force-pushed the DefaultEBM branch 3 times, most recently from c7caa6d to 675532a Compare October 1, 2026 15:42
@artemcm

artemcm commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@artemcm

artemcm commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test Windows

3 similar comments
@artemcm

artemcm commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test Windows

@artemcm

artemcm commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test Windows

@artemcm

artemcm commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test Windows

@artemcm

artemcm commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@artemcm

artemcm commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test Windows

@artemcm

artemcm commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@artemcm

artemcm commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test Windows

@artemcm

artemcm commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@artemcm

artemcm commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test Windows

1 similar comment
@artemcm

artemcm commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test Windows

@artemcm
artemcm force-pushed the DefaultEBM branch 2 times, most recently from 2957657 to 5741544 Compare October 8, 2026 09:54
@artemcm

artemcm commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@artemcm

artemcm commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test Windows

1 similar comment
@artemcm

artemcm commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test Windows

@artemcm

artemcm commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

#2134
@swift-ci test

Replace each `parsedOptions.contains(.driverExplicitModuleBuild)` check with a single computed property, so the mode has one definition.
`-print-explicit-dependency-graph` and `-explicit-auto-linking` need an explicit module build, not necessarily the `-explicit-module-build` spelling. Report that the build has it disabled rather than naming a flag the user may already be implying some other way.
A single frontend invocation cannot carry the additional jobs an explicit module build needs. Pass `-no-explicit-module-build` so this stays true once the mode becomes the default.
`swiftc` invocations now build module dependencies explicitly. `-no-explicit-module-build` to opt out, and other driver kinds still need `-explicit-module-build`.

If libSwiftScan is unavailable then the default is dropped with a warning, except under `-nonlib-dependency-scanner`, which scans out of process.
Scanning for a parse-only, `-emit-imported-modules` or `-scan-dependencies` action is wasted work, and turns an unresolvable import into an error the action should not encounter. Mirrors `FrontendOptions::shouldActionOnlyParse`.
With explicit module builds on by default, planBuild() runs a dependency scan. That scan fails for tests that pass made-up input files, and it adds precompile jobs to tests that expect a single compile job.

Add TestHarnessInterModuleDependencyOracle (test-only SPI). It answers scans with a graph that holds only the main module, while still loading the real libSwiftScan. Test Driver uses it unless the caller passes an oracle or the test runs under the new `.realDependencyScan` trait.

Mark the suites that build or inspect real module dependencies with .realDependencyScan, and give IncrementalTestFramework a real oracle.

Update the remaining tests for the explicit-build default: match the explicit-build job shape, create input files the real scanner reads, and pass -no-explicit-module-build where a test covers non-explicit behavior, including the incremental harness's implicit config.
An implicit build passes -pch-output-dir to the frontend, which creates the directory. An explicit build names the PCH itself and passes it with -o, and the frontend opens that path without creating its directory, so a build whose -pch-output-dir does not exist yet failed to emit the bridging PCH.

Create the directory just before the jobs run, so planning alone still leaves the file system untouched.
The scanner reads only Swift source files, so an invocation without any, such as compiling SIL or building or dumping a Clang module, has nothing to scan, and the explicit-build default is not meaningful.

Decide the mode after collecting the inputs so it can look at them.
An explicit build imports each SDK interface's Clang dependencies with this compilation's API notes version. Swift 4 API notes rename APIs that interfaces written for later language modes use, so those interfaces fail to build under `-swift-version 4`. Keep the default off there. `-explicit-module-build` still turns it on.
The dependency scanner rejects `-dump-ast-format`, so with explicit module builds on by default, `-dump-ast -dump-ast-format json` failed in the scan. Only the job that dumps the AST takes the flag.
With `-o -` the compile job writes its product to standard output. A lone job runs in place of the driver and writes there directly, but the module jobs of an explicit build make the compile a child of the driver, which sent its output to standard error, and dropped it when it was not valid UTF-8. Pass the product's bytes through to standard output unchanged.
The in-process scanner finds tools and libraries relative to the
compiler executable, such as the Clang driver's install directory,
which decides where it finds GCC and the C++ standard library. The
driver did not tell it which executable that is, so the scan assumed
one without a directory. The explicit module build jobs run the
toolchain's swift-frontend instead, and on merged-/usr Linux the two
found libstdc++ at different paths. The job then could not read the
module map at the path the scan reported.

Pass the resolved Swift compiler path to the scanner for dependency
scans and import pre-scans. It is the executable that runs the jobs,
and the same path the target info query already passes. The new
swiftscan_scan_invocation_set_main_executable_path is loaded as an
optional symbol, so an older libSwiftScan ignores the path and behaves
as it did.

The oracle's getDependencies and getImports, and SwiftScan's
scanDependencies and preScanImports, gain an optional
compilerExecutablePath. Callers that do not pass it are unchanged.
@artemcm

artemcm commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci test

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.

1 participant