Skip to content
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

Reland optimized-compiler-builtins config #102579

Closed
wants to merge 2 commits into from

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Oct 2, 2022

this is possible now that compiler-builtins contains the fix in rust-lang/compiler-builtins#532.

in particular, this makes the c feature for compiler-builtins an explicit opt-in, rather than silently detected by whether llvm-project is checked out on disk.
exposing this is necessary because the cc crate doesn't support cross-compiling to MSVC, and we want people to be able to run x check --target foo regardless of whether they have a c toolchain available.

this also uses the new option in CI, where we do want to optimize compiler_builtins.

the new option is off by default for the dev channel and on otherwise.

Fixes #102560. Fixes #101172. Helps with #105065 (although there's some weirdness there - it's still broken when optimized-compiler-builtins is set to true).

r? @tmandry cc @Mark-Simulacrum

@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Oct 2, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 2, 2022
@rust-log-analyzer

This comment has been minimized.

@jyn514 jyn514 force-pushed the fix-llvm-handling branch 2 times, most recently from fbb4c86 to 37c21a3 Compare October 2, 2022 13:50
fn is_rust_llvm(&self, target: TargetSelection) -> bool {
match self.config.target_config.get(&target) {
// We're using a pre-built version of LLVM, but the user has promised that pre-built version has our patches.
Copy link
Member

Choose a reason for hiding this comment

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

We may not be using a pre-built version of LLVM. Specifically the use case I want to support is cd into src/llvm-project, check out a vanilla commit, and set submodules = false, llvm-has-rust-patches = false in config.

Copy link
Member Author

Choose a reason for hiding this comment

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

That seems totally bizarre, though. Why would you want that?

Copy link
Member

Choose a reason for hiding this comment

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

To build against a more recent version of LLVM.

If you separately build and supply your own llvm-config, then you hit the other assumptions in here about not needing to distribute the LLVM libraries because it's probably system installed. So basically this was unsupported before.

Plus it's desirable to have bootstrap manage the configuration of LLVM if all you want to vary is the version.

@@ -313,12 +313,17 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
let compiler_builtins_c_feature = if builder.config.optimized_compiler_builtins {
if !builder.is_rust_llvm(target) {
Copy link
Member

Choose a reason for hiding this comment

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

You can use compiler-rt without Rust patches. I think the important thing is that compiler-rt is built from the same sources as LLVM. So.. either llvm-config is unset, or llvm_from_ci is active and we're managing submodules?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, as I wrote in #101833 (comment) enabling optimized_compiler_builtins is kinda required on some targets, and from my understanding the only requirement is that the sources of compiler-rt has to be the same as the custom LLVM's. We probably need a way to supply the custom sources in those cases.

@tmandry
Copy link
Member

tmandry commented Oct 18, 2022

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 18, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Oct 31, 2022
…iltins, r=jyn514

Revert "Make the `c` feature for `compiler-builtins` opt-in instead of inferred"

This reverts commit 3acb505 (PR rust-lang#101833).

The changes in this commit caused several bugs/incompatibilities (rust-lang#101833 (comment), rust-lang#102560). For now we're reverting this commit and will re-land it alongside fixes for those bugs.

Re-opens rust-lang#101172
cc rust-lang#102560
cc rust-lang#102579
@bors
Copy link
Contributor

bors commented Oct 31, 2022

☔ The latest upstream changes (presumably #103797) made this pull request unmergeable. Please resolve the merge conflicts.

@tmandry tmandry removed their assignment Nov 14, 2022
@jyn514
Copy link
Member Author

jyn514 commented Nov 25, 2022

@tmandry I am still very confused how llvm_has_rust_patches is meant to be used. The only place I see it used is in Build::is_rust_llvm, which is used in three places:

  1. rust/src/bootstrap/test.rs

    Lines 1553 to 1554 in c5f92ce

    if !builder.is_rust_llvm(target) {
    cmd.arg("--system-llvm");
  2. The new assert I just added. Let's ignore that for now.
  3. if builder.is_rust_llvm(target) {
    cargo.env("LLVM_RUSTLLVM", "1");

3 defines LLVM_RUSTLLVM, which is eventually used in

#ifdef LLVM_RUSTLLVM
/// getLongestEntryLength - Return the length of the longest entry in the table.
template<typename KV>
static size_t getLongestEntryLength(ArrayRef<KV> Table) {
; that bit looks correct. But 1. looks absolutely wrong even before this PR: it will pass --system-llvm for an in-tree commit with submodules = false and patches = false. How is llvm_has_rust_patches tested? how is it supposed to work? I ran llvm-config --ldflags --system-llvm locally and it didn't even exit successfully ...

@jyn514 jyn514 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 25, 2022
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Nov 25, 2022
@jyn514
Copy link
Member Author

jyn514 commented Nov 25, 2022

ugh I misread, it's a compiletest flag, not an llvm-config flag. so I think what was happening before is that some tests were silently being ignored, which we don't have any sort of checks for:

fn ignore_llvm(config: &Config, line: &str) -> bool {
if config.system_llvm && line.starts_with("no-system-llvm") {
return true;

I'll fix 1 at the same time as I address your and pietro's comments.

@rust-log-analyzer

This comment has been minimized.

@jyn514
Copy link
Member Author

jyn514 commented Nov 25, 2022

Ok, pushed a few changes. @pietroalbini @tmandry let me know if you think this will work better.

config.toml.example Outdated Show resolved Hide resolved
src/bootstrap/compile.rs Outdated Show resolved Hide resolved
src/ci/docker/host-x86_64/x86_64-gnu-llvm-13/Dockerfile Outdated Show resolved Hide resolved
@tmandry
Copy link
Member

tmandry commented Jan 25, 2023

@rustbot author (I think there are some outstanding concerns from Pietro to be addressed)

@jyn514 jyn514 removed the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Jul 8, 2023
Copy link
Member

@tmandry tmandry left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for checking! I left some nits, feel free to fix or ignore and r=me

src/bootstrap/lib.rs Outdated Show resolved Hide resolved
src/bootstrap/lib.rs Outdated Show resolved Hide resolved
src/bootstrap/lib.rs Outdated Show resolved Hide resolved
@Dylan-DPC Dylan-DPC added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 26, 2023
@bors
Copy link
Contributor

bors commented Jul 29, 2023

☔ The latest upstream changes (presumably #114148) made this pull request unmergeable. Please resolve the merge conflicts.

@jyn514
Copy link
Member Author

jyn514 commented Aug 21, 2023

rust-lang/team#1051

@jyn514 jyn514 closed this Aug 21, 2023
@jyn514 jyn514 reopened this Dec 25, 2023
@rustbot
Copy link
Collaborator

rustbot commented Dec 25, 2023

This PR modifies config.example.toml.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

@rust-log-analyzer

This comment has been minimized.

@jyn514
Copy link
Member Author

jyn514 commented Dec 25, 2023

i am going to remove the check that the in-tree llvm matches the llvm we're linking to, actually. i am not sure the difference matters, and it wasn't enforced before.

in particular, this makes the `c` feature for compiler-builtins an explicit opt-in, rather than silently detected by whether `llvm-project` is checked out on disk.
exposing this is necessary because the `cc` crate doesn't support cross-compiling to MSVC, and we want people to be able to run `x check --target foo` regardless of whether they have a c toolchain available.

this also uses the new option in CI, where we *do* want to optimize compiler_builtins.

the new option is off by default for the `dev` channel and on otherwise.
@jyn514
Copy link
Member Author

jyn514 commented Dec 25, 2023

r? bootstrap

@rustbot rustbot assigned onur-ozkan and unassigned tmandry Dec 25, 2023
@jyn514
Copy link
Member Author

jyn514 commented Dec 25, 2023

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 25, 2023
@bors
Copy link
Contributor

bors commented Dec 29, 2023

☔ The latest upstream changes (presumably #119373) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

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

No concerns on my side. Currently, Jyn isn't actively working on the project. I will close this PR; open another one to cherry-pick the commits, resolve conflicts, and then r+ it.

@onur-ozkan onur-ozkan closed this Jan 3, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 4, 2024
…tins, r=onur-ozkan

Reland optimized-compiler-builtins config

Copy of rust-lang#102579 PR.

From rust-lang#102579:

> No concerns on my side. Currently, Jyn isn't actively working on the project. I will close this PR; open another one to cherry-pick the commits, resolve conflicts, and then r+ it.

> Fixes rust-lang#102560. Fixes rust-lang#101172. Helps with rust-lang#105065 (although there's some weirdness there - it's still broken when optimized-compiler-builtins is set to true).

Fixes rust-lang#102560. Fixes rust-lang#101172. Helps with rust-lang#105065

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 7, 2024
…ns, r=onur-ozkan

Reland optimized-compiler-builtins config

Copy of rust-lang#102579 PR.

From rust-lang#102579:

> No concerns on my side. Currently, Jyn isn't actively working on the project. I will close this PR; open another one to cherry-pick the commits, resolve conflicts, and then r+ it.

> Fixes rust-lang#102560. Fixes rust-lang#101172. Helps with rust-lang#105065 (although there's some weirdness there - it's still broken when optimized-compiler-builtins is set to true).

Fixes rust-lang#102560. Fixes rust-lang#101172. Helps with rust-lang#105065

r? ghost
@jyn514 jyn514 deleted the fix-llvm-handling branch January 17, 2024 16:28
@onur-ozkan onur-ozkan removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
9 participants