Skip to content

BuildDescription: Set output path for bc files #6611

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
May 26, 2023
Merged

BuildDescription: Set output path for bc files #6611

merged 1 commit into from
May 26, 2023

Conversation

rauhul
Copy link
Member

@rauhul rauhul commented May 24, 2023

  • Updates swift build with an -experimental-lto-mode option which can
    be set to either "full" or "thin" enabling the use of llvm LTO for
    both swift and c targets. Updates BuildParameters with a matching
    linkTimeOptimizationMode and updates SwiftTargetBuildDescription to
    use the proper file extension for bitcode objects as well as place
    them in the proper output location.

@rauhul
Copy link
Member Author

rauhul commented May 24, 2023

@swift-ci please smoke test

@rauhul
Copy link
Member Author

rauhul commented May 24, 2023

@swift-ci please smoke test windows

@neonichu
Copy link
Contributor

So I'm assuming this is always a strict either/or? Or is there a situation where the compiler would try to emit both and fail because we're using the same path?

@MaxDesiatov MaxDesiatov changed the title Set output path for bc files BuildDescription: Set output path for bc files May 24, 2023
@MaxDesiatov
Copy link
Contributor

+1 to that question, it's unclear what happens when both of these paths are used at once by different tools.

@rauhul
Copy link
Member Author

rauhul commented May 24, 2023

You both are right, I'm talking to artem about this now and will hopefully find a better solution...

@rauhul
Copy link
Member Author

rauhul commented May 24, 2023

The only time an issue can arise is if you pass -emit-bitcode to swiftc which will result in an assertion like:

SwiftDriverExecution/MultiJobExecutor.swift:207: Fatal error: multiple producers for output /<redacted>/.build/arm64-apple-macosx/release/Minified.build/Minified.swift.o: Embedding bitcode for Minified Minified.swift.o & Compiling Minified Minified.swift
[1]    70503 trace trap   --driver-mode=swiftc -module-name Minified -incremental -emit-dependencies

@MaxDesiatov
Copy link
Contributor

The only time an issue can arise is if you pass -emit-bitcode to swiftc

I'm not sure if the assertion error message is helpful enough. In what cases can that happen? Would it make sense to just write to a file with a different extension?

Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

Can this new behavior be tested?

@rauhul
Copy link
Member Author

rauhul commented May 24, 2023

@swift-ci please smoke test

@rauhul
Copy link
Member Author

rauhul commented May 24, 2023

@swift-ci please smoke test windows

@rauhul rauhul enabled auto-merge (squash) May 24, 2023 23:14
- Updates spm to pass the object file path as the output path for
  bitcode files for use when building with lto. A more ideal solution
  may be to use a different path for bitcode files, however using the
  `.o` extension is also a common pattern and requires a significantly
  less invasive diff.
@rauhul
Copy link
Member Author

rauhul commented May 25, 2023

@swift-ci please smoke test

@rauhul
Copy link
Member Author

rauhul commented May 25, 2023

@swift-ci please smoke test windows

1 similar comment
@rauhul
Copy link
Member Author

rauhul commented May 25, 2023

@swift-ci please smoke test windows

name: .customLong("experimental-lto-mode"),
help: .hidden
)
public var linkTimeOptimizationMode: LinkTimeOptimizationMode?
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this use that enum directly instead of creating a proxy enum, as they seem identical to each other?

Suggested change
public var linkTimeOptimizationMode: LinkTimeOptimizationMode?
public var linkTimeOptimizationMode: BuildParameters.LinkTimeOptimizationMode?

Copy link
Member Author

Choose a reason for hiding this comment

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

@neonichu suggested discrete enums, I'm happy to go either way.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think they should be separate because one is for argument parsing and one is for the build. They just happen to be the same right now, but that's coincidental not inherent.

@neonichu
Copy link
Contributor

@swift-ci please smoke test windows

@rauhul
Copy link
Member Author

rauhul commented May 25, 2023

@swift-ci please smoke test windows

@rauhul rauhul merged commit 743d441 into main May 26, 2023
@rauhul rauhul deleted the bc-as-obj branch May 26, 2023 00:46
@MaxDesiatov
Copy link
Contributor

MaxDesiatov commented May 26, 2023

@tomerd I wonder if we need to mention this in CHANGELOG.md, or do we avoid mentioning experimental options and features there?

@tomerd
Copy link
Contributor

tomerd commented May 26, 2023

good point, we can add and make sure its mentioned as experimental

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants