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

Include a copy of compiler-rt source in the download-ci-llvm tarball #129116

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

Zalathar
Copy link
Contributor

This will make it possible to experiment with allowing download-ci-llvm builds to build library/profiler_builtins, without needing to check out the src/llvm-project submodule.

By itself, this PR just adds the files to the tarball, but doesn't actually do anything with them. The idea is that once this is merged, it will then be much easier to proceed with work on the necessary bootstrap changes (using the real downloaded tarball), without having to rig up weird hacks to simulate downloading a modified tarball.


Adding these files to the compressed tarballs appears to increase its size by a negligible amount (<1 MB out of 400/800+ MB).

The uncompressed size is about 14 MB (out of 2+ GB for the whole tarball).

(The excluded test files would have been another 35 MB.)

@rustbot
Copy link
Collaborator

rustbot commented Aug 15, 2024

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Aug 15, 2024
@Kobzol
Copy link
Contributor

Kobzol commented Aug 15, 2024

Can't we just precompile it and include the built artifacts in the archive? It seems a bit silly to download a subset of LLVM source code from CI just so that you don't have to checkout the submodule.

@Zalathar
Copy link
Contributor Author

For what it's worth, the tarball already contains thousands of LLVM header files, for building compiler/rustc_llvm, so there's some precedent for doing things this way.

And it seems like it would be a lot of extra work to include library/profiler_builtins artifacts in the tarball and then arrange to have it used, instead of just doing the regular build with a slightly different source directory.

@Kobzol
Copy link
Contributor

Kobzol commented Aug 15, 2024

We already build the profiler artifacts on the most common dist builders, so that's why I thought that we might as well just stuff them inside the CI archive.

I like distributing the artifacts more, because it provides a better value to contributors. If we already go through the trouble of storing something extra there, and modifying bootstrap, we might as well provide the artifacts directly. Now, this of course assumes that the implementation of using the CI artifacts is not much more difficult than using the CI sources. That's probably something that we'd have to try and see. But I don't think that using the sources will be much easier, you'll also need to check whether the submodule has been initialized and whether download-ci-llvm is enabled and react based on that.

Not sure if there is ever a need to compile the profiler builtins in some special way though.

@Zalathar
Copy link
Contributor Author

I like distributing the artifacts more, because it provides a better value to contributors.

I'm a bit confused by this, because the contributor is still building the rest of the compiler and library anyway, and building profiler_builtins takes less than a second (as long as the dozen or so source files are available in a known location).

Now, this of course assumes that the implementation of using the CI artifacts is not much more difficult than using the CI sources.

As far as I'm aware, using a prebuilt artifact would require an entirely new mechanism for using library artifacts from the unpacked ci-llvm directory.

Building from a different source directory would mostly come down to a few extra lines in profiler_builtins/build.rs, plus a few extra lines in the bootstrap code that already knows whether download-ci-llvm is active or not.

@Kobzol
Copy link
Contributor

Kobzol commented Aug 15, 2024

I'm a bit confused by this, because the contributor is still building the rest of the compiler and library anyway, and building profiler_builtins takes less than a second (as long as the dozen or so source files are available in a known location).

I was thinking that we could reduce the need to use a C++ compiler. Even though it's currently also needed to build rustc_llvm, if you only want to work with library, you could potentially do without a C++ compiler. But probably it is needed for a bunch of other stuff anyway..

As far as I'm aware, using a prebuilt artifact would require an entirely new mechanism for using library artifacts from the unpacked ci-llvm directory.

You're right. For some reason, I thought that profiler_builtins is a C++ thing that we compile with bootstrap, I didn't realize that it's a relatively normal Rust crate. That would probably be a bit more annoying to set up from the downloaded archive.

Nevermind then, I agree now that it's easier to distribute the sources than the artifacts. We should ideally include some detection that local sources will be used if they are checked out and modified, but I think that we already have that logic for download-ci-llvm.

@mohe2015
Copy link
Contributor

Isn't it nicer security wise to ship as few binaries as possible? Also that can create platform incompatibilities, e.g. on NixOS LD is not at the standard path etc

@Kobzol
Copy link
Contributor

Kobzol commented Aug 15, 2024

Well, download-ci-llvm and download-ci-rustc are designed specifically to help contributors get up to speed quickly by downloading prebuilt artifacts from CI, so it's kind of the point of it to distribute binaries :) But if including also sources there helps some contributors, then why not.

I don't understand why downloading a 90 MiB archive (which needs to be redownloaded each time you change to a fresh commit) is better than checking out a git submodule that changes maybe once a month though. Just out of curiosity, what's the reason you want to avoid checking out the LLVM submodule @Zalathar?

@mohe2015
Copy link
Contributor

Then disregard my comment I don't know if this specific case would be a problem then

@Zalathar
Copy link
Contributor Author

So, my underlying motivation looks something like this:

  • The coverage test suite is divided into two halves. One half runs by default (because it doesn't need the profiler runtime), and the other half only runs when the profiler runtime is specifically enabled in config.toml.
  • I would like to make it easier to enable the profiler runtime, and possibly enable it by default, so that contributors don't have to worry about this.
  • Currently that's impossible, because the profiler runtime requires (a tiny subset of) the src/llvm-project submodule. Thanks to the success of download-ci-llvm, the default config for compiler contributors usually doesn't need to check out the LLVM submodule.
  • Checking out and syncing the LLVM submodule is quite slow (since it's much larger than other submodules), so people would rightly complain if I made bootstrap check it out just for the profiler runtime.
  • In the case where src/llvm-project isn't available (because of download-ci-llvm), we know that bootstrap will have downloaded and extracted a copy of CI LLVM! In addition to LLVM libs/binaries, that tarball also contains LLVM header files for use by compiler/rustc_llvm, so it's only a small leap to also extend that same behaviour to the compiler-rt files needed by library/profiler_builtins.

@Kobzol
Copy link
Contributor

Kobzol commented Aug 16, 2024

Thank you for the context, now it makes more sense to me (especially given the Zulip thread). It's indeed not ideal that we don't run with profiler enabled in PR CI, that makes it more valuable to enable the profiler by default.

@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Aug 18, 2024

📌 Commit 320be47 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 18, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 19, 2024
Rollup of 7 pull requests

Successful merges:

 - rust-lang#127679 (Stabilize `raw_ref_op` (RFC 2582))
 - rust-lang#128084 (Suggest adding Result return type for associated method in E0277.)
 - rust-lang#128628 (When deduplicating unreachable blocks, erase the source information.)
 - rust-lang#128902 (doc: std::env::var: Returns None for names with '=' or NUL byte)
 - rust-lang#129048 (Update `crosstool-ng` for loongarch64)
 - rust-lang#129116 (Include a copy of `compiler-rt` source in the `download-ci-llvm` tarball)
 - rust-lang#129208 (Fix order of normalization and recursion in const folding.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f956bce into rust-lang:master Aug 19, 2024
6 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Aug 19, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 19, 2024
Rollup merge of rust-lang#129116 - Zalathar:compiler-rt, r=Mark-Simulacrum

Include a copy of `compiler-rt` source in the `download-ci-llvm` tarball

This will make it possible to experiment with allowing `download-ci-llvm` builds to build `library/profiler_builtins`, without needing to check out the `src/llvm-project` submodule.

By itself, this PR just adds the files to the tarball, but doesn't actually do anything with them. The idea is that once this is merged, it will then be much easier to proceed with work on the necessary bootstrap changes (using the real downloaded tarball), without having to rig up weird hacks to simulate downloading a modified tarball.

---

Adding these files to the compressed tarballs appears to increase its size by a negligible amount (<1 MB out of 400/800+ MB).

The uncompressed size is about 14 MB (out of 2+ GB for the whole tarball).

(The excluded test files would have been another 35 MB.)
@Zalathar Zalathar deleted the compiler-rt branch August 19, 2024 09:54
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Aug 23, 2024
Build `library/profiler_builtins` from `ci-llvm` if appropriate

Running all of `tests/coverage` requires the LLVM profiler runtime, which requires setting `build.profiler = true`.

Historically, doing that has required checking out the entire `src/llvm-project` submodule. For compiler contributors who otherwise don't need that submodule (thanks to `download-ci-vm`), that's quite inconvenient.

However, thanks to rust-lang#129116, the downloaded CI LLVM tarball now contains a copy of LLVM's `compiler-rt` directory, which includes all the files needed to build the profiler runtime. So with a little bit of extra logic in bootstrap, we can have `library/profiler_builtins` look for the `compiler-rt` files in `ci-llvm` instead of the `src/llvm-project` submodule.
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 24, 2024
Build `library/profiler_builtins` from `ci-llvm` if appropriate

Running all of `tests/coverage` requires the LLVM profiler runtime, which requires setting `build.profiler = true`.

Historically, doing that has required checking out the entire `src/llvm-project` submodule. For compiler contributors who otherwise don't need that submodule (thanks to `download-ci-vm`), that's quite inconvenient.

However, thanks to rust-lang#129116, the downloaded CI LLVM tarball now contains a copy of LLVM's `compiler-rt` directory, which includes all the files needed to build the profiler runtime. So with a little bit of extra logic in bootstrap, we can have `library/profiler_builtins` look for the `compiler-rt` files in `ci-llvm` instead of the `src/llvm-project` submodule.
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 25, 2024
Build `library/profiler_builtins` from `ci-llvm` if appropriate

Running all of `tests/coverage` requires the LLVM profiler runtime, which requires setting `build.profiler = true`.

Historically, doing that has required checking out the entire `src/llvm-project` submodule. For compiler contributors who otherwise don't need that submodule (thanks to `download-ci-vm`), that's quite inconvenient.

However, thanks to rust-lang#129116, the downloaded CI LLVM tarball now contains a copy of LLVM's `compiler-rt` directory, which includes all the files needed to build the profiler runtime. So with a little bit of extra logic in bootstrap, we can have `library/profiler_builtins` look for the `compiler-rt` files in `ci-llvm` instead of the `src/llvm-project` submodule.
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 25, 2024
Build `library/profiler_builtins` from `ci-llvm` if appropriate

Running all of `tests/coverage` requires the LLVM profiler runtime, which requires setting `build.profiler = true`.

Historically, doing that has required checking out the entire `src/llvm-project` submodule. For compiler contributors who otherwise don't need that submodule (thanks to `download-ci-vm`), that's quite inconvenient.

However, thanks to rust-lang#129116, the downloaded CI LLVM tarball now contains a copy of LLVM's `compiler-rt` directory, which includes all the files needed to build the profiler runtime. So with a little bit of extra logic in bootstrap, we can have `library/profiler_builtins` look for the `compiler-rt` files in `ci-llvm` instead of the `src/llvm-project` submodule.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants