Skip to content

fix cross-module-optimization builds and add the option -disable-cmo #1019

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
merged 1 commit into from
Feb 24, 2022

Conversation

eeckstein
Copy link
Contributor

The driver splits the compile job into two jobs: one for creating the object file, one for emitting the swiftmodule.
For the swiftmodule-job the driver adds -experimental-skip-non-inlinable-function-bodies-without-types.
This breaks CMO, because in CMO, the inlinable-decision is not derived from the AST but done in the optimizer.

As a quick hack we could disable -experimental-skip-non-inlinable-function-bodies-without-types.
But for CMO, the two-job approach is highly problematic, because it risks the two compile jobs to get out of sync, e.g. by different command line options, indeterministic behavior, etc. This can result in unresolved symbol errors, which are very hard to debug.

This change also adds a new option -disable-cmo to disable cross-module-optimization. It can be used to go back to the old behavior.

rdar://89223981

@eeckstein eeckstein requested a review from artemcm February 21, 2022 14:16
@eeckstein
Copy link
Contributor Author

@swift-ci test

The driver splits the compile job into two jobs: one for creating the object file, one for emitting the swiftmodule.
For the swiftmodule-job the driver adds -experimental-skip-non-inlinable-function-bodies-without-types.
This breaks CMO, because in CMO, the inlinable-decision is not derived from the AST but done in the optimizer.

As a quick hack we could disable -experimental-skip-non-inlinable-function-bodies-without-types.
But for CMO, the two-job approach is highly problematic, because it risks the two compile jobs to get out of sync, e.g. by different command line options, indeterministic behavior, etc. This can result in unresolved symbol errors, which are very hard to debug.

This change also adds a new option `-disable-cmo` to disable cross-module-optimization. It can be used to go back to the old behavior.

rdar://89223981
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein requested review from xymus and nkcsgexi February 22, 2022 07:10
@@ -61,6 +61,7 @@ extension Option {
public static let continueBuildingAfterErrors: Option = Option("-continue-building-after-errors", .flag, attributes: [.frontend, .doesNotAffectIncrementalBuild], helpText: "Continue building, even after errors are encountered")
public static let coveragePrefixMap: Option = Option("-coverage-prefix-map", .separate, attributes: [.frontend], metaVar: "<prefix=replacement>", helpText: "Remap source paths in coverage info")
public static let CrossModuleOptimization: Option = Option("-cross-module-optimization", .flag, attributes: [.helpHidden, .frontend], helpText: "Perform cross-module optimization")
public static let disableCrossModuleOptimization: Option = Option("-disable-cmo", .flag, attributes: [.helpHidden, .frontend], helpText: "Disable cross-module optimization")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update Options.swift according to the procedure described in:
https://github.com/apple/swift-driver#rebuilding-optionsswift

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I'll do this in a separate PR

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.

3 participants