about summary refs log tree commit diff
path: root/src/bootstrap/compile.rs
AgeCommit message (Collapse)AuthorLines
2022-05-25Simplify implementation of `-Z gcc-ld`Vadim Petrochenkov-8/+5
- The logic is now unified for all targets (wasm targets should also be supported now) - Additional "symlink" files like `ld64` are eliminated - lld-wrapper is used for propagating the correct lld flavor - Cleanup "unwrap or exit" logic in lld-wrapper
2022-05-24Make llvm-libunwind a per-target optionTyler Mandry-1/+1
2022-05-13Add LLVM based mingw-w64 targetsMateusz Mikuła-2/+3
2022-04-27Auto merge of #95170 - jyn514:ci-llvm, r=Mark-Simulacrumbors-1/+1
Move `download-ci-llvm` out of bootstrap.py This is ready for review. It has been tested on Windows, Linux, and NixOS. The second commit ports the changes from https://github.com/rust-lang/rust/pull/95234 to Rust; I can remove it if desired. Helps with https://github.com/rust-lang/rust/issues/94829. As a follow-up, this makes it possible to avoid downloading llvm until it's needed for building `rustc_llvm`; it would be nice to do that, but it shouldn't go in the first draft. It might also be possible to avoid requiring python until tests run (currently there's a check in `sanity.rs`), but I haven't looked too much into that. `@rustbot` label +A-rustbuild
2022-04-24Move download-ci-llvm to rustbuildJoshua Nelson-1/+1
This attempts to keep the logic as close to the original python as possible. `probably_large` has been removed, since it was always `True`, and UTF-8 paths are no longer supported when patching files for NixOS. I can readd UTF-8 support if desired. Note that this required making `llvm_link_shared` computed on-demand, since we don't know whether it will be static or dynamic until we download LLVM from CI.
2022-04-24Rollup merge of #95504 - jyn514:library-alias, r=Mark-SimulacrumMatthias Krüger-2/+2
Add `x {check,build,doc} {compiler,library}` aliases. While working on https://github.com/rust-lang/rust/pull/95503, I realized that it will interfere with existing command lines: Currently people run `x build library/std` expecting it to "add all library crates to the sysroot", but after that change, it will *only* build `libstd` and its dependencies (and add them to the sysroot), not libtest or libproc_macro. That will work for local testing in most cases, but could be confusing. Even if not, though, I think `x build library` is more clear about what actually happens than the current `x build library/std`. The intended end goal is something like: - For check/build/doc, we have library + compiler aliases, which correspond to basically "most possible" for that piece. This is the intended path of entry (rather than library/test or similar as today) for when you just want the thing to work -- for example, getting a compiler that is "crates.io-compatible" would be roughly `x.py build library`). #95504 - Specific crate invocations build up to that crate, which means that if you don't care about tests you probably want x.py build library/proc_macro or library/std for faster build times. #95503 Note that this is already implemented today for the `doc` command and seems to work pretty well in practice. I plan to change the dev-guide and various instructions in the README to `build library` once this is merged. `@rustbot` label +A-rustbuild
2022-04-10Add `build compiler/rustc_codegen_gcc` as an alias for `CodegenBackend`Joshua Nelson-1/+1
These paths (`_cranelift` and `_gcc`) are somewhat misleading, since they actually tell bootstrap to build *all* codegen backends. But this seems like a useful improvement in the meantime.
2022-03-30Add `x {check,build,doc} {compiler/library}` aliases.Joshua Nelson-2/+2
While working on https://github.com/rust-lang/rust/pull/95503, I realized that this will interfere with existing command lines: Currently people run `x build library/std` expecting it to be added to the sysroot, but after that change, it will *only* build `libstd` without making it available for the toolchain. It's debatable whether that's a breaking change that will be accepted; if so, this PR is absolutely necessary to make sure there's a command for "build the standard library and add it to the sysroot". Even if not, though, I think `x build library` is more clear about what actually happens than the current `x build library/std`. For consistency, also add support for `compiler` and all other command variants. Note that `doc compiler` was already supported, so in a sense this is just fixing an existing inconsistency. I plan to change the dev-guide and various instructions in the README to `build library` once this is merged.
2022-03-30Rollup merge of #95461 - nyurik:spelling, r=lcnrDylan DPC-1/+1
Spellchecking some comments This PR attempts to clean up some minor spelling mistakes in comments
2022-03-30Spellchecking some commentsYuri Astrakhan-1/+1
This PR attempts to clean up some minor spelling mistakes in comments
2022-03-28Propagate `parallel_compiler` feature through rustc crates. Turned off ↵klensy-0/+2
feature gives change of builded crates: 238 -> 224.
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-1/+1
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-05Merge build_helper into utilbjorn3-2/+1
2022-03-05Remove build_helperbjorn3-1/+1
The majority of the code is only used by either rustbuild or rustc_llvm's build script. Rust_build is compiled once for rustbuild and once for every stage. This means that the majority of the code in this crate is needlessly compiled multiple times. By moving only the code actually used by the respective crates to rustbuild and rustc_llvm's build script, this needless duplicate compilation is avoided.
2022-03-03bootstrap: correct reading of flags for llvmJon Gjengset-4/+11
First, this reverts the `CFLAGS`/`CXXFLAGS` of #93918. Those flags are already read by `cc` and populated into `Build` earlier on in the process. We shouldn't be overriding that based on `CFLAGS`, since `cc` also respects overrides like `CFLAGS_{TARGET}` and `HOST_CFLAGS`, which we want to take into account. Second, this adds the same capability to specify target-specific versions of `LDFLAGS` as we have through `cc` for the `C*` flags: https://github.com/alexcrichton/cc-rs#external-configuration-via-environment-variables Note that this also necessitated an update to compiletest to treat CXXFLAGS separately from CFLAGS.
2022-02-27Rollup merge of #94415 - bjorn3:cfg_default_backend, r=Mark-SimulacrumMatthias Krüger-0/+4
Use the first codegen backend in the config.toml as default It is currently hard coded to llvm if enabled and cranelift otherwise. This made some sense when cranelift was the only alternative codegen backend. Since the introduction of the gcc backend this doesn't make much sense anymore. Before this PR bootstrapping rustc using a backend other than llvm or cranelift required changing the source of rustc_interface. With this PR it becomes a matter of putting the right backend as first enabled backend in config.toml. cc ```@antoyo```
2022-02-27Use the first codegen backend in the config.toml as defaultbjorn3-0/+4
It is currently hard coded to llvm if enabled and cranelift otherwise. This made some sense when cranelift was the only alternative codegen backend. Since the introduction of the gcc backend this doesn't make much sense anymore. Before this PR bootstrapping rustc using a backend other than llvm or cranelift required changing the source of rustc_interface. With this PR it becomes a matter of putting the right backend as first enabled backend in config.toml.
2022-02-23Always check cg_llvm with ./x.py checkbjorn3-1/+1
Previously it would be skipped if codegen-backends doesn't contain llvm.
2022-02-20Use Metadata::modified instead of FileTime::from_last_modification_time in ↵bjorn3-3/+3
run_cargo Metadata::modified works in all platforms supported by the filetime crate. This changes brings rustbuild a tiny bit closer towards dropping the filetime dependency.
2022-01-15Exclude llvm-libunwind from the self-contained set on s390x-musl targets.Ariadne Conill-2/+4
llvm-libunwind does not support s390x targets at present, so we cannot build it for s390x targets. Accordingly, remove it from the self-contained set.
2022-01-06Revert "bootstrap: copy `llvm-dwp` to sysroot"David Wood-7/+0
This reverts commit 241160de72b5b55187ca54243e2a6e82e336d07c.
2021-12-31rustbuild: Add support for a per-target default-linker option.Maxim Cournoyer-2/+9
2021-12-09Don't copy llvm tools to sysroot when using download-ci-llvmAaron Hill-1/+6
Fixes #91710
2021-12-08Install llvm tools to sysroot when assembling local toolchainAaron Hill-0/+11
Some projects (e.g. the `bootimage` crate) may require the user to install the `llvm-tools-preview` rustup component. However, this cannot be easily done with a locally built toolchain. To allow a local toolchain to be used a drop-in replacement for a normal rustup toolchain in more cases, this PR copies the built LLVM tools to the sysoot. From the perspective a tool looking at the sysroot, this is equivalent to installing `llvm-tools-preview`.
2021-11-03Provide standalone libc.a in self-contained for musl and wasi12101111-3/+3
2021-10-13Rollup merge of #89759 - jyn514:x-build-assemble, r=Mark-SimulacrumMatthias Krüger-2/+9
Assemble the compiler when running `x.py build` Previously, there was no way to actually get binaries in `build/$TARGET/stage1/bin` without building the standard library. This makes it possible to build just the compiler. This can be useful when the standard library isn't actually necessary for trying out your tests (e.g. a bug that can be reproduced with only a `no_core` crate). Closes https://github.com/rust-lang/rust/issues/73519.
2021-10-13Assemble the compiler when running `x.py build`Joshua Nelson-2/+9
Previously, there was no way to actually get binaries in `build/$TARGET/stage1/bin` without building the standard library. This makes it possible to build just the compiler. This can be useful when the standard library isn't actually necessary for trying out your tests (e.g. a bug that can be reproduced with only a `no_core` crate).
2021-10-07Add wrapper for -Z gcc-ld=lld to invoke rust-lld with the correct flavorHans Kratz-8/+8
The wrapper is installed as `ld` and `ld64` in the `lib\rustlib\<host_target>\bin\gcc-ld` directory and its sole purpose is to invoke `rust-lld` in the parent directory with the correct flavor.
2021-09-20Adjust to SourceType::InTree in several placesMark Rousskov-2/+1
These were left over in migrations to subtrees, which should generally be treated as-if it was local. Also fixes a warning caused by this change.
2021-08-30Fix LLVM libunwind build for non-musl targetsJethro Beekman-12/+20
Broken in #85600
2021-08-29Auto merge of #88250 - rusticstuff:macos-lld, r=nagisabors-0/+4
Make `-Z gcc-ld=lld` work for Apple targets `-Z gcc-ld=lld` was introduced in #85961. It does not work on Macos because lld needs be either named `ld64` or passed `-flavor darwin` as the first two arguments in order to select the Mach-O flavor. Rust invokes cc (=clang) on Macos for linking which calls `ld` as linker binary and not `ld64`, so just creating an `ld64` binary and modifying the search path with `-B` does not work. In order to solve this patch does: * Set the `lld_flavor` for all Apple-derived targets to `LldFlavor::Ld64`. As far as I can see this actually works towards fixing `-Xlinker=rust-lld` as all those targets use the Mach-O object format. * Copy/hardlink rust-lld to the gcc-ld subdirectory as ld64 next to ld. * If `-Z gcc-ld=lld` is used and the target lld flavor is Ld64 add `-fuse-ld=/path/to/ld64` to the linker invocation. Fixes #86945.
2021-08-28build llvm libunwind.a in rustbuild12101111-1/+13
2021-08-23Include ld64 nexte to ld for use with -Z gcc-ldHans Kratz-0/+4
2021-08-13Fix compiling other codegen backends when llvm is enabledbjorn3-0/+4
2021-07-23Add missing articler00ster-1/+1
2021-07-21Rollup merge of #87301 - chinmaydd:chinmaydd-patch-1-1, r=jyn514Guillaume Gomez-1/+1
Fix typo in compile.rs
2021-07-20Update all submodules that rustbuild doesn't depend on lazilyJoshua Nelson-0/+2
This only updates the submodules the first time they're needed, instead of unconditionally the first time you run x.py. Ideally, this would move *all* submodules and not exclude some tools and backtrace. Unfortunately, cargo requires all `Cargo.toml` files in the whole workspace to be present to build any crate. On my machine, this takes the time for an initial submodule clone (for `x.py --help`) from 55.70 to 15.87 seconds. This uses exactly the same logic as the LLVM update used, modulo some minor cleanups: - Use a local variable for `src.join(relative_path)` - Remove unnecessary arrays for `book!` macro and make the macro simpler to use - Add more comments
2021-07-19Fix typo in compile.rsChinmay Deshpande-1/+1
2021-07-03Make x.py less verbose on failuresJoshua Nelson-1/+1
- Don't print the exact command run by rustbuild unless `--verbose` is set. This is almost always unhelpful, since it's just cargo with a lot of arguments. - Don't print "Build completed unsuccessfully" unless --verbose is set. You can already tell the build failed by the errors above, and the time isn't particularly helpful. - Don't print the full path to bootstrap. This is useless to everyone, even including when working on x.py itself. You can still opt-in to this being shown with `--verbose`, since it will throw an exception. Before: ``` error[E0432]: unresolved import `x` --> library/std/src/lib.rs:343:5 | 343 | use x; | ^ no external crate `x` error: aborting due to previous error For more information about this error, try `rustc --explain E0432`. error: could not compile `std` To learn more, run the command again with --verbose. command did not execute successfully: "/home/joshua/rustc4/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "check" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "8" "--release" "--features" "panic-unwind backtrace" "--manifest-path" "/home/joshua/rustc4/library/test/Cargo.toml" "--message-format" "json-render-diagnostics" expected success, got: exit status: 101 failed to run: /home/joshua/rustc4/build/bootstrap/debug/bootstrap check Build completed unsuccessfully in 0:00:13 ``` After: ``` error[E0432]: unresolved import `x` --> library/std/src/lib.rs:343:5 | 343 | use x; | ^ no external crate `x` error: aborting due to previous error For more information about this error, try `rustc --explain E0432`. error: could not compile `std` To learn more, run the command again with --verbose. ```
2021-06-10gcc-lld mvp1000teslas-0/+7
ignore test if rust-lld not found create ld -> rust-lld symlink at build time instead of run time for testing in ci copy instead of symlinking remove linux check test for linker, suggestions from bjorn3 fix overly restrictive lld matcher use -Zgcc-ld flag instead of -Clinker-flavor refactor code adding lld to gcc path revert ci changes suggestions from petrochenkov rename gcc_ld to gcc-ld in dirs
2021-06-07Rollup merge of #86025 - bjorn3:no_rpath_cfg_prefix, r=jackh726Yuki Okushi-2/+1
Remove the install prefix from the rpath set when using -Crpath It was broken anyway for rustup installs and nobody seems to have noticed. Fixes https://github.com/rust-lang/rust/issues/82392
2021-06-06Auto merge of #79608 - alessandrod:bpf, r=nagisabors-1/+3
BPF target support This adds `bpfel-unknown-none` and `bpfeb-unknown-none`, two new no_std targets that generate little and big endian BPF. The approach taken is very similar to the cuda target, where `TargetOptions::obj_is_bitcode` is enabled and code generation is done by the linker. I added the targets to `dist-various-2`. There are [some tests](https://github.com/alessandrod/bpf-linker/tree/main/tests/assembly) in bpf-linker and I'm planning to add more. Those are currently not ran as part of rust CI.
2021-06-05Use sysroot instead of CFG_PREFIX for the rpathbjorn3-2/+1
CFG_PREFIX is incorrect for rustup installed rustc versions. It also causes unnecessary recompilation when changing the install prefix.
2021-06-04rustdoc: link to stable/beta docs consistently in documentationJoshua Nelson-0/+5
## User-facing changes - Intra-doc links to primitives that currently go to rust-lang.org/nightly/std/primitive.x.html will start going to channel that rustdoc was built with. Nightly will continue going to /nightly; Beta will link to /beta; stable compilers will link to /1.52.1 (or whatever version they were built as). - Cross-crate links from std to core currently go to /nightly unconditionally. They will start going to /1.52.0 on stable channels (but remain the same on nightly channels). - Intra-crate links from std to std (or core to core) currently go to the same URL they are hosted at; they will continue to do so. Notably, this is different from everything else because it can preserve the distinction between /stable and /1.52.0 by using relative links. Note that "links" includes both intra-doc links and rustdoc's own automatically generated hyperlinks. ## Implementation changes - Update the testsuite to allow linking to /beta and /1.52.1 in docs - Use an html_root_url for the standard library that's dependent on the channel This avoids linking to nightly docs on stable. - Update rustdoc to use channel-dependent links for primitives from an unknown crate - Set DOC_RUST_LANG_ORG_CHANNEL from bootstrap to ensure it's in sync - Include doc.rust-lang.org in the channel
2021-05-31Build crtbengin.o/crtend.o from source code12101111-1/+2
2021-05-23Add BPF targetAlessandro Decina-1/+3
This change adds the bpfel-unknown-none and bpfeb-unknown-none targets which can be used to generate little endian and big endian BPF
2021-05-01Apply `--cfg parallel_compiler` when documentingJoshua Nelson-0/+1
This also reverts commit 9823c2cc700fea541bf2670fcee93af662b63022 working around the bug.
2021-04-11bootstrap: check local_rebuild before adding --cfg=bootstrap, closes #84057Ximin Luo-4/+6
2021-04-04Use the beta compiler for building bootstrap tools when `download-rustc` is setJoshua Nelson-5/+10
## Motivation This avoids having to rebuild bootstrap and tidy each time you rebase over master. In particular, it makes rebasing and running `x.py fmt` on each commit in a branch significantly faster. It also avoids having to rebuild bootstrap after setting `download-rustc = true`. ## Implementation Instead of extracting the CI artifacts directly to `stage0/`, extract them to `ci-rustc/` instead. Continue to copy them to the proper sysroots as necessary for all stages except stage 0. This also requires `bootstrap.py` to download both stage0 and CI artifacts and distinguish between the two when checking stamp files. Note that since tools have to be built by the same compiler that built `rustc-dev` and the standard library, the downloaded artifacts can't be reused when building with the beta compiler. To make sure this is still a good user experience, warn when building with the beta compiler, and default to building with stage 2.
2021-03-08WASI: Switch to crt1-command.o to enable support for new-style commandsDan Gohman-1/+1
This switches Rust's WASI target to use crt1-command.o instead of crt1.o, which enables support for new-style commands. By default, new-style commands work the same way as old-style commands, so nothing immediately changes here, but this will be needed by later changes to enable support for typed arguments. See here for more information on new-style commands: - https://github.com/WebAssembly/wasi-libc/pull/203 - https://reviews.llvm.org/D81689