Skip to content

Add -Zsplit-thin-lto-unit flag to enable ThinLTO unit splitting#111155

Closed
danakj wants to merge 1 commit intorust-lang:masterfrom
danakj:split-units
Closed

Add -Zsplit-thin-lto-unit flag to enable ThinLTO unit splitting#111155
danakj wants to merge 1 commit intorust-lang:masterfrom
danakj:split-units

Conversation

@danakj
Copy link
Contributor

@danakj danakj commented May 3, 2023

Clang enables the EnableSplitLTOUnit LLVM module flag when compiling for ThinLTO when:

  • -fsplit-lto-unit is specified, or
  • -fsanitize=cfi is specified, or
  • -fwhole-program-vtables.

When linking Rust and C++ together and using ThinLTO, the setting for the LLVM module flag "EnableSplitLTOUnit" must match or linking simply fails.

The ability to enable this LLVM module flag is then required in order to link Rust objects with C++ objects with ThinLTO for any project that uses the above flags (like Chromium does).

A change proposal is made for the command line flag here: rust-lang/compiler-team#626

@rustbot
Copy link
Collaborator

rustbot commented May 3, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 3, 2023
@rustbot
Copy link
Collaborator

rustbot commented May 3, 2023

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo

@rust-log-analyzer

This comment has been minimized.

Clang enables the EnableSplitLTOUnit LLVM module flag when compiling
for ThinLTO when:
* -fsplit-lto-unit is specified, or
* -fsanitize=cfi is specified, or
* -fwhole-program-vtables.

When linking Rust and C++ together and using ThinLTO, the setting
for the LLVM module flag "EnableSplitLTOUnit" must match or linking
simply fails.

The ability to enable this LLVM module flag is then required in
order to link Rust objects with C++ objects with ThinLTO for any
project that uses the above flags (like Chromium does).
@danakj
Copy link
Contributor Author

danakj commented May 3, 2023

This is covered by #105452 already which will land soon.

@danakj danakj closed this May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants