about summary refs log tree commit diff
path: root/src/bootstrap/native.rs
AgeCommit message (Collapse)AuthorLines
2023-01-11Change `src/test` to `tests` in source files, fix tidy and testsAlbert Larsan-3/+3
2023-01-06Auto merge of #106415 - Nilstrieb:where-is-my-master-branch, r=jyn514bors-1/+3
Handle non-existent upstream master branches in `x fmt` People who do have a remote for `rust-lang/rust` but don't have the master branch checked out there used to get this error when running `x fmt`: > fatal: ambiguous argument 'rust/master': unknown revision or path not in the working tree. > Use '--' to separate paths from revisions, like this: > 'git <command> [<revision>...] -- [<file>...]' > rust/master Which is not exactly helpful. Now, we fall back to `origin/master` (hoping that at least that remote exists) for that case. If there is still some error, we just fall back to `x fmt .` and print a warning. r? `@jyn514`
2023-01-05Add vendor to Fuchsia's target tripleDavid Koloski-2/+2
Historically, Rust's Fuchsia targets have been labeled x86_64-fuchsia and aarch64-fuchsia. However, they should technically contain vendor information. This CL changes Fuchsia's target triples to include the "unknown" vendor since Clang now does normalization and handles all triple spellings. This was previously attempted in #90510, which was closed due to inactivity.
2023-01-03turn a comment into an actual doc commentRémy Rakic-7/+7
2023-01-03slight cleanupRémy Rakic-2/+1
2023-01-03make the `native::LLD` step able to use an already built lldRémy Rakic-0/+14
Makes the lld step avoid building it from source when possible: when dist has packaged it along the other LLVM binaries for the rust-dev component.
2023-01-03Add `build_helper` crate to share code between tidy and bootstrapNilstrieb-1/+3
2022-12-31Revert "Auto merge of #105058 - ↵Joshua Nelson-3/+1
Nilstrieb:no-merge-commits-for-you-only-bors-is-allowed-to-do-that, r=jyn514" This reverts commit 4839886f0abe208ab8f2bb73a3076a59fe2ab60c, reversing changes made to ce85c98575e3016cf2007d90a85be321e592aa96.
2022-12-30Add `build_helper` crate to share code between tidy and bootstrapNilstrieb-1/+3
2022-12-22Auto merge of #106000 - nikic:lld-build, r=Mark-Simulacrumbors-63/+46
Make LLD build forward-compatible with LLVM 16 Switch to using the cmake module instead of llvm-config. I believe this also removes the need for llvm-config-wrapper.
2022-12-22Use LLVM_CMAKE_DIR for lld buildNikita Popov-59/+46
LLVM_CONFIG_PATH is no longer supported as of LLVM 16, switch to using the cmake module instead. We separately return the llvm-config and cmake directory paths, because llvm-config always refers to the host binary, while the cmake directory is for the target triple.
2022-12-21Don't explicitly set C++ standard for lldNikita Popov-4/+0
LLVM does this itself since 606cb8548a1b7763e0c8489c5efe66803a7ede72, and 14 is no longer the correct standard when building lld 16, causing build failures.
2022-12-19Fix arch flag on i686-apple-darwinMarcus Calhoun-Lopez-0/+3
i686-apple-darwin should use `-arch i386` instead of `-arch i686`
2022-11-13Make all download functions need only Config, not BuilderJoshua Nelson-79/+5
This also adds a new `mod download` instead of scattering the download code across `config.rs` and `native.rs`.
2022-11-12Distinguish `--dry-run` from the automatic dry run checkJoshua Nelson-10/+10
2022-11-03Fix artifact version/channel detection for stableMark Rousskov-2/+2
On stable, our artifacts are uploaded with the raw version number (e.g., 1.65.0), not the channel. This adjusts our detection logic to use the version number from src/version when we detect the stable channel.
2022-10-10Auto merge of #94381 - Kobzol:llvm-bolt, r=Mark-Simulacrumbors-0/+29
Use BOLT in CI to optimize LLVM This PR adds an optimization step in the Linux `dist` CI pipeline that uses [BOLT](https://github.com/llvm/llvm-project/tree/main/bolt) to optimize the `libLLVM.so` library built by boostrap. Steps: - [x] Use LLVM 15 as a bootstrap compiler and use it to build BOLT - [x] Compile LLVM with support for relocations (`-DCMAKE_SHARED_LINKER_FLAGS="-Wl,-q"`) - [x] Gather profile data using instrumented LLVM - [x] Apply profile to LLVM that has already been PGOfied - [x] Run with BOLT profiling on more benchmarks - [x] Decide on the order of optimization (PGO -> BOLT?) - [x] Decide how we should get `bolt` (currently we use the host `bolt`) - [x] Clean up The latest perf results can be found [here](https://github.com/rust-lang/rust/pull/94381#issuecomment-1258269440). The current CI build time with BOLT applied is around 1h 55 minutes.
2022-10-09Use BOLT in x64 dist CI to optimize LLVMJakub Beránek-0/+29
2022-10-07Don't run llvm-config in dry runsJosh Stone-5/+10
2022-10-07Let llvm-config tell us where to find its toolsJosh Stone-9/+4
2022-10-02Auto merge of #100557 - dawnofmidnight:tarball-commit-info, r=Mark-Simulacrumbors-22/+30
fix: use git-commit-info for version information Fixes #33286. Fixes #86587. This PR changes the current `git-commit-hash` file that `./x.py` dist puts in the `rustc-{version}-src.tar.{x,g}z` to contain the hash, the short hash, and the commit date from which the tarball was created, assuming git was available when it was. It uses this for reading the version so that rustc has all the appropriate metadata. # Testing Testing this is kind of a pain. I did it with something like ```sh ./x.py dist # ensure that `ignore-git` is `false` in config.toml cp ./build/dist/rustc-1.65.0-dev-src.tar.gz ../rustc-1.65.0-dev-src.tar.gz cd .. && tar -xzf rustc-1.65.0-dev-src && cd rustc-1.65.0-dev-src ./x.py build ``` Then, the output of `rustc -vV` with the stage1 compiler should have the `commit-hash` and `commit-date` fields filled, rather than be `unknown`. To be completely sure, you can use `rustc --sysroot` with the stdlib that the original `./x.py dist` made, which will require that the metadata matches.
2022-10-01fix: use git-commit-info for version informationdawnofmidnight-22/+30
This PR adds support for fetching version information from the `git-commit-info` file when building the compiler from a source tarball.
2022-09-16Remove the allow-list for dynamic linking of LLVM toolsChris Wailes-7/+2
This commit removes an allow-list for the dynamic linking of the LLVM tools and instead relies on the builder's linking preference only.
2022-09-01Auto merge of #100707 - dzvon:fix-typo, r=davidtwcobors-1/+1
Fix a bunch of typo This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-31Fix a bunch of typoDezhi Wu-1/+1
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-28add riscv64gc-unknown-openbsd support (target riscv64-unknown-openbsd on ↵Sébastien Marie-2/+3
OpenBSD) - add platform-support documentation - add riscv64gc-unknown-openbsd spec - do not try to link with -latomic on openbsd
2022-08-20Enable downloading prebuilt LLVM in test buildersMark Rousskov-1/+7
See comment added for details on the test builder restriction. This is primarily intended for macOS CI, but is likely to be a slight win on other builders too.
2022-08-19Refactor if-available setting to work in CIMark Rousskov-9/+74
This verifies if the HEAD sha matches with the detected LLVM SHA, and if not, permits usage of the detected LLVM. Otherwise, we fallback on regular non-downloaded LLVM (currently still cached with sccache, though that's still 10+ minutes on macOS).
2022-08-14Update the minimum external LLVM to 13Josh Stone-2/+2
2022-08-09Explicitly disable zstd supportNikita Popov-0/+3
Make sure we don't pick up a libzstd.so dependency if it happens to be installed on the system.
2022-08-03Set llvm configs when building lldtopjohnwu-19/+21
2022-07-30Discover channel for artifact downloadMark Rousskov-1/+2
When we're downloading based on a CI commit, that can still be -beta- or even -stable-, so we should lookup the channel it was built with.
2022-07-11Auto merge of #96978 - lqd:win_pgo2, r=Mark-Simulacrumbors-1/+17
Utilize PGO for windows x64 rustc dist builds This PR adds PGO support for the CI x64 windows dist builds. These are the results from running the rustc-perf benchmarks: ![image](https://user-images.githubusercontent.com/247183/177662869-683a8034-7c95-42bf-9900-9ffd66677fcf.png) Thanks to `@Kobzol,` `@michaelwoerister,` `@wesleywiser,` `@Mark-Simulacrum` for their precious help.
2022-07-11extend bootstrap for PGO on windowsRémy Rakic-1/+17
When building LLVM/LLD as part of a build that asks LLVM to generate profiles, e.g. when doing PGO, cmake or clang-cl don't automatically link clang's profiler runtime in, causing undefined reference errors at link-time. We do that manually, by adding clang's resource library folder to the library search path: - for LLVM itself, by extending the linker args that `rustc_llvm`'s build script uses, to avoid the linker errors when linking `rustc_driver`. - for LLD, by extending cmake's linker flags during the LLD build step.
2022-07-11Auto merge of #98526 - jyn514:download-llvm-outside-checkout, r=Mark-Simulacrumbors-1/+1
Allow using `download-ci-llvm = true` outside the git checkout `@bjorn3` noticed that this is already allowed today when download-llvm is disabled, but breaks with it enabled: ``` $ ./rust2/x.py build fatal: not a git repository (or any of the parent directories): .git thread 'main' panicked at 'command did not execute successfully: "git" "rev-list" "--author=bors@rust-lang.org" "-n1" "--first-parent" "HEAD" "--" "/home/jnelson/rust-lang/rust2/src/llvm-project" "/home/jnelson/rust-lang/rust2/src/bootstrap/download-ci-llvm-stamp" "/home/jnelson/rust-lang/rust2/src/version" expected success, got: exit status: 128', src/bootstrap/native.rs:134:20 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` Support it too for consistency. It's unclear to me when anyone would need to use this, but `@bjorn3` feels we should support it, and it's not much additional effort to get it working.
2022-07-11Fix `download-ci-llvm` NixOS patching for binariesoxalica-2/+2
LLVM tools should also be patched, since they are used in some tests, specially, - src/test/run-make-fulldeps/cross-lang-lto (llvm-ar) - src/test/run-make-fulldeps/cross-lang-lto-upstream-rlibs (llvm-ar) - src/test/run-make-fulldeps/issue-64153 (llvm-objdump) To be more future proof, we should patch all binaries in `bin`.
2022-07-10Allow using `download-ci-llvm = true` outside the git checkoutJoshua Nelson-1/+1
@bjorn3 noticed that this is already allowed today when download-llvm is disabled, but breaks with it enabled: ``` $ ./rust2/x.py build fatal: not a git repository (or any of the parent directories): .git thread 'main' panicked at 'command did not execute successfully: "git" "rev-list" "--author=bors@rust-lang.org" "-n1" "--first-parent" "HEAD" "--" "/home/jnelson/rust-lang/rust2/src/llvm-project" "/home/jnelson/rust-lang/rust2/src/bootstrap/download-ci-llvm-stamp" "/home/jnelson/rust-lang/rust2/src/version" expected success, got: exit status: 128', src/bootstrap/native.rs:134:20 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` Support it too for consistency. It's unclear to me when anyone would need to use this, but @bjorn3 feels we should support it, and it's not much additional effort to get it working. This also updates a bunch of other git commands that were similarly depending on the current directory.
2022-07-09Auto merge of #98328 - topjohnwu:fix_cross, r=jyn514bors-1/+22
Fix several issues during cross compiling - When cross compiling LLVM on an arm64 macOS machine to x86_64, CMake will produce universal binaries by default, causing link errors. Explicitly set `CMAKE_OSX_ARCHITECTURES` to the one single target architecture so that the executables and libraries will be single architecture. - When cross compiling rustc with `llvm.clang = true`, `CLANG_TABLEGEN` has to be set to the host `clang-tblgen` executable to build clang.
2022-07-04Proper macOS libLLVM symlink when cross compilingtopjohnwu-8/+6
When cross compiling on macOS with `llvm.link-shared` enabled, the symlink creation will fail after compiling LLVM for the target architecture, because it will attempt to create the symlink in the host LLVM directory, which was already created when being built. This commit changes the symlink path to the actual LLVM output.
2022-07-03Set CLANG_TABLEGEN when cross compiling clangtopjohnwu-0/+9
When cross compiling rustc with `llvm.clang = true`, CLANG_TABLEGEN has to be set to the host clang-tblgen executable to build clang.
2022-07-03Fix cross compiling on macOStopjohnwu-1/+13
When cross compiling LLVM on an arm64 machine to x86_64, CMake will produce universal binaries by default, causing link errors. Explicitly set CMAKE_OSX_ARCHITECTURES to the one single target architecture.
2022-07-01Rollup merge of #98418 - topjohnwu:macos-dylib, r=jyn514Guillaume Gomez-10/+31
Allow macOS to build LLVM as shared library Inspired by how [homebrew](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/llvm.rb) builds and distributes llvm, here we manually create a symlink with a versioned dylib path to make `llvm-config` work properly. Note, the resulting `rustc` executable and `librustc_driver-<hash>.dylib` still links to the un-versioned `libLLVM.dylib` as expected when distributed in the final output. I have confirmed this by checking `otool -L` on both binaries. After the change, enabling `llvm.link-shared` and `llvm.thin-lto` will be possible on macOS.
2022-06-26Fix builds on Windows (closes #98546)BlaCoiso-1/+1
2022-06-25Fix LLVM rebuild with download-ci-llvm.Eric Huss-0/+13
2022-06-24Allow dynamically linking against libLLVM on macOStopjohnwu-10/+31
Create symlinks to workaround file missing error in llvm-config
2022-06-18Rollup merge of #97828 - ferrocene:pa-config-artifacts, r=jyn514Yuki Okushi-6/+9
Allow configuring where artifacts are downloaded from Bootstrap has support for downloading prebuilt LLVM and rustc artifacts to speed up local builds, but that currently works only for users working on `rust-lang/rust`. Forks of the repository (for example Ferrocene) might have different URLs to download artifacts from, or might use a different email address on merge commits, breaking both LLVM and rustc artifact downloads. This PR refactors bootstrap to load the download URLs and other constants from `src/stage0.json`, allowing downstream forks to tweak those values. It also future-proofs the download code to easily allow forks to add their own custom protocols (like `s3://`). This PR is best reviewed commit-by-commit.
2022-06-13Do not try to statically link libstd++ on Solarisgco-1/+1
Fixes: Error on bootstrapping : Empty search path given via '-L' (solaris) #97260
2022-06-14Rollup merge of #95243 - vladimir-ea:compiler_watch_os, r=nagisaYuki Okushi-2/+5
Add Apple WatchOS compile targets Hello, I would like to add the following target triples for Apple WatchOS as Tier 3 platforms: armv7k-apple-watchos arm64_32-apple-watchos x86_64-apple-watchos-sim There are some pre-requisites Pull Requests: https://github.com/rust-lang/compiler-builtins/pull/456 (merged) https://github.com/alexcrichton/cc-rs/pull/662 (pending) https://github.com/rust-lang/libc/pull/2717 (merged) There will be a subsequent PR with standard library changes for WatchOS. Previous compiler and library changes were in a single PR (https://github.com/rust-lang/rust/pull/94736) which is now closed in favour of separate PRs. Many thanks! Vlad. ### Tier 3 Target Requirements Adds support for Apple WatchOS compile targets. Below are details on how this target meets the requirements for tier 3: > tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.) `@deg4uss3r` has volunteered to be the target maintainer. I am also happy to help if a second maintainer is required. > Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target. Uses the same naming as the LLVM target, and the same convention as other Apple targets. > Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it. I don't believe there is any ambiguity here. > Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users. I don't see any legal issues here. > The target must not introduce license incompatibilities. > Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0). > The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements. > If the target supports building host tools (such as rustc or cargo), those host tools must not depend on proprietary (non-FOSS) libraries, other than ordinary runtime libraries supplied by the platform and commonly used by other binaries built for the target. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3. > Targets should not require proprietary (non-FOSS) components to link a functional binary or library. > "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users. I see no issues with any of the above. > Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions. > This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements. Only relevant to those making approval decisions. > Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions. core and alloc can be used. std support will be added in a subsequent PR. > The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running tests (even if they do not pass), the documentation must explain how to run tests for the target, using emulation if possible or dedicated hardware if necessary. Use --target=<target> option to cross compile, just like any target. Tests can be run using the WatchOS simulator (see https://developer.apple.com/documentation/xcode/running-your-app-in-the-simulator-or-on-a-device). > Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages. > Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications. I don't foresee this being a problem. > Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target. > In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target. No other targets should be affected by the pull request.
2022-06-13Add Apple WatchOS compile targetsVladimir Michael Eatwell-2/+5
2022-06-13fix error message for download-ci-llvmPietro Albini-7/+7