Commit Graph

80 Commits

Author SHA1 Message Date
Eric Huss 888100352a Move ProcessBuilder to cargo-util. 2021-03-20 15:19:03 -07:00
Eric Huss 83487e41a9 Detect changes for JSON spec targets. 2021-03-01 12:19:14 -08:00
Eric Huss e58c544f37 Some minor code cleanup. 2021-02-28 19:03:06 -08:00
bors 8fa0827d27 Auto merge of #8640 - CPerezz:doc_versioning, r=ehuss
Implement Rustdoc versioning checks

Before compiling, we need to make sure that if there were any previous docs already compiled, they were compiled with the same Rustc version that we're currently using. Otherways we must remove the `doc/` folder and compile again.

This is important because as stated in #8461 the .js/.html&.css files that are generated by Rustc don't have any versioning. Therefore, we can fall in weird bugs and behaviours if we mix different compiler versions of these js/.html&.css files.

Closes #8461
2021-02-13 21:57:02 +00:00
Carlos Pérez 61c233209a
Update src/cargo/core/compiler/build_context/target_info.rs
Co-authored-by: Eric Huss <eric@huss.org>
2021-02-13 21:40:09 +01:00
CPerezz 4afa58511f
Improve RustDocFingerprint::remove_doc_dirs
We were not filtering the cases where the doc folder
paths did not exist.
Also, we were overrwriting the error when it doesn't
make sense. We now return the first one by folding the
results of the doc_dirs removal resolutions.
2021-02-04 01:03:04 +01:00
CPerezz e78f91c04e
Refactor doc_dirs obtention
We should try to avoid dealing with paths ourseleves. Now the
access/parsing and construction is handled via `Layout`.
2021-02-04 00:09:36 +01:00
CPerezz 7bfb3d0982
Fix spelling 2021-02-03 23:50:59 +01:00
Alex Crichton ed4568e108 Add split-debuginfo profile option
This commit adds a new `split-debuginfo` option to Cargo compilation
profiles which gets forwarded to the `-Csplit-debuginfo` codegen option
in rustc. This commit also sets the default, only on macOS, to be
`-Csplit-debuginfo=unpacked`. The purpose of this change is to leverage
rust-lang/rust#79570 to avoid running `dsymutil` on incremental builds
while also preserving a pleasant debugging experience by default. This
should lead to much faster incremental build times on macOS since
`dsymutil` isn't exactly the speediest tool in the world.

This is technically a breaking change in Cargo because we're no longer
by-default producing the `*.dSYM` folders on macOS. If those are still
desired, however, authors can always run `dsymutil` themselves or
otherwise configure `split-debuginfo = 'packed'` in their
manifest/profile configuration.
2021-02-01 09:21:36 -08:00
CPerezz cb21e6424b
Improve & fix doc dir removal process 2021-02-01 01:54:13 +01:00
CPerezz 7c45021328
Check target-dependant doc folders
When checking the fingerprint for rustdoc and applying
the corresponding logic, we don't only need to consider
the `target/doc` folder (Host target) but also triple targets.

So now the actual compilation targets are checked during the
rustdoc_fingerprint processing and they're treated as the Host/doc
folder.
2021-01-31 23:43:27 +01:00
CPerezz d2572a2800
Address latest reivew suggestions
- Instead of `fs` we use the `utils::paths` functions
to interact with the filesystem.
- The doc fingerprint is now stored under `target/` instead
of `target/doc/`.
- The code in `compile` has been reduced to a single function call.
2021-01-27 01:14:31 +01:00
Carlos Pérez 47e19f057e
Merge branch 'master' into doc_versioning 2021-01-26 00:54:30 +01:00
CPerezz 94519f2649
Create dirs if needed before f_p write call
Once `RustDocFingerprint::check_rustdoc_fingerprint()` is
executed it might happen that the `doc/` dir is removed.

This means that when we call `fingerprint.write()` we need
to create the `doc` directory again.
2021-01-26 00:54:41 +01:00
Matthias Krüger c4e5670bdb Fix more clippy warnings;
clippy::comparison_to_empty
clippy::needless_question_mark
clippy::needless_borrow
clippy::match_like_matches_macro
clippy::vec_init_then_push
clippy::redundant_clone
clippy::nonminimal_bool
clippy::ptr_arg
2021-01-06 15:15:22 +01:00
CPerezz 994ccec136
Address @ehuss suggestions/nits 2020-12-17 02:05:25 +01:00
Carlos Pérez 31ef7affcb
Merge branch 'master' into doc_versioning 2020-12-16 09:32:39 +01:00
CPerezz 65f17e1ca6
Implement rustdoc versioning
After refactoring what was done on the latest approach
this time we included the rustdoc versioning logic inside
the `compiler::rustdoc` fn.

- Created `RustDocFingerprint` struct so that is easier to
manage all of the logic & functions related to rustdoc
versioning as well as scaling it in the future if needed.
2020-12-16 09:21:56 +01:00
Eric Huss 9efa0d5526 Fix non-determinism with new feature resolver. 2020-09-13 10:06:19 -07:00
Eric Huss c3e422c6b8 Remove embed-bitcode check now that it is on stable. 2020-07-18 09:32:39 -07:00
Eric Huss 8d344dc1f7 Allow Windows dylibs without dll suffix. 2020-06-02 10:50:55 -07:00
Matthias Krüger 63ffc6ae88 more clippy fixes 2020-05-08 23:28:12 +02:00
Eric Huss eac3b66bd4 Rework how Cargo computes the rustc file outputs. 2020-05-05 14:32:52 -07:00
Eric Huss 7a06be149c Add CrateType to replace LibKind. 2020-05-05 14:32:52 -07:00
Alex Crichton e221925469 Don't force rustc to do codegen for LTO builds
This commit updates Cargo's implementation of LTO builds to do less work
and hopefully be faster when doing a cold build. Additionaly this should
save space on disk! The general idea is that the compiler does not need
object files if it's only going to perform LTO with some artifacts. In
this case all rustc needs to do is load bitcode from dependencies. This
means that if you're doing an LTO build generating object code for
intermediate dependencies is just wasted time!

Here Cargo is updated with more intrusive knowledge about LTO. Cargo
will now analyze the dependency graph to figure out which crates are
being compiled with LTO, and then it will figure out which dependencies
only need to have bitcode in them. Pure-bitcode artifacts are emitted
with the `-Clinker-plugin-lto` flag. Some artifacts are still used in
multiple scenarios (such as those shared between build scripts and final
artifacts), so those are not compiled with `-Clinker-plugin-lto` since
the linker is not guaranteed to know how to perform LTO.

This functionality was recently implemented in rust-lang/rust#71528
where rustc is now capable of reading bitcode from `-Clinker-plugin-lto`
rlibs. Previously rustc would only read its own format of bitcode, but
this has now been extended! This support is now on nightly, hence this
PR.
2020-05-04 14:15:31 -07:00
bors 8dd98699b8 Auto merge of #8189 - matthiaskrgr:clippy_v12, r=ehuss
clippy fixes
2020-05-04 19:12:37 +00:00
Alex Crichton 1840d1631d Rename bitcode-in-rlib flag to embed-bitcode
This flag changed names in nightly, so let's rename it here in Cargo to
get our CI passing and enable the same wins for avoiding bitcode.
2020-05-04 10:53:18 -07:00
Matthias Krüger 6694fdb677 clippy fixes 2020-05-01 01:16:30 +02:00
Alex Crichton 3fd28143de Support multiple `--target` flags on the CLI
This commit refactors the internals of Cargo to no longer have a
singular `--target` flag (and singular `requested_target` kind throught)
but to instead have a list. The semantics of multiple `--target` flags
is to build the selected targets for each of the input `--target` flag
inputs.

For now this is gated behind `-Zmultitarget` as an unstable features,
since I'm not entirely sure this is the interface we want. In general
it'd be great if we had a way to simply specify `Unit` structures of
what to build on the CLI, but we're in general very far away from that,
so I figured that this is probably sufficient at least for testing for
now.

cc #8156
2020-04-28 15:16:47 -07:00
Eric Huss b19d6ac2a7 Update tests and comments for testing windows-gnu. 2020-04-21 11:00:37 -07:00
Hugo Beauzée-Luyssen 68c22a16bc Add implib to the stamp files
This was already done when targetting msvc, but it needs to be done for
all targets to allow rustc to link with shared libraries when using llvm
-l<dllname> is only supported by gcc, while llvm needs an import library
to link indirectly with a dll
2020-04-21 10:29:11 -07:00
bors 5b620dc044 Auto merge of #8134 - nnethercote:bitcode-in-rlib, r=alexcrichton
Change `-Cembed-bitcode=no` use to `-Cbitcode-in-rlib=no`.

Because the latter will replace the planned use of the former in rustc.
2020-04-19 19:09:12 +00:00
Alex Crichton 7b9f56b36e Re-add code removed for debugging 2020-04-19 10:37:16 -07:00
Alex Crichton 45d49579ae Make `Unit` an owned value 2020-04-19 10:36:26 -07:00
Eric Huss e0bd9e231d bcx reorg 2020-04-19 10:36:26 -07:00
Nicholas Nethercote cb48e3a37b Change `-Cembed-bitcode=no` use to `-Cbitcode-in-rlib=no`.
Because the latter will replace the planned use of the former in rustc.
2020-04-19 20:34:52 +10:00
Eric Huss 3acd15eb47 Fix pdb uplift when executable has dashes. 2020-04-16 18:02:47 -07:00
Alex Crichton bac300bda0 Add support for `-Cembed-bitcode=no`
This commit is the Cargo half of support necessary for
rust-lang/rust#70458. Today the compiler emits embedded bytecode in
rlibs by default, but compresses it. This is both extraneous disk space
and wasted build time for almost all builds, so the PR in question there
is changing rustc to have a `-Cembed-bitcode` flag which, when enabled,
places the bitcode in the object file rather than an auxiliary file (no
extra compression), but also enables `-Cembed-bitcode=no` to disable
bitcode emission entirely.

This Cargo support changes Cargo to pass `-Cembed-bitcode=no` for almost
all compilations. Cargo will keep `lto = true` and such working by not
passing this flag (and thus allowing bitcode to get embedded), but by
default `cargo build` and `cargo build --release` will no longer have
any bitcode in rlibs which should result in speedier builds!

Most of the changes here were around the test suite and various
assertions about the `rustc` command lines we spit out. One test was
hard-disabled until we can get `-Cembed-bitcode=no` into nightly, and
then we can make it a nightly-only test. The test will then be stable
again once `-Cembed-bitcode=no` hits stable.

Note that this is intended to land before the upstream `-Cembed-bitcode`
change. The thinking is that we'll land everything in rust-lang/rust all
at once so there's no build time regressions for anyone. If we were to
land the `-Cembed-bitcode` PR first then there would be a build time
regression until we land Cargo changes because rustc would be emitting
uncompressed bitcode by default and Cargo wouldn't be turning it off.
2020-04-01 14:31:06 -07:00
Eric Huss b8ab32ea31 Partially revert change to filter debug_assertions. 2020-03-05 08:20:52 -08:00
Alex Tokarev a6239da8b2 Filter out cfgs which should not be used during build
Fixes #7933: Filter invalid CARGO_CFG_ in build scripts
2020-02-27 11:53:53 +03:00
Eric Huss 9d98645aca build-std: remove sysroot probe 2020-02-25 07:57:56 -08:00
Eric Huss 949eccac3e Move rustc target collection out of bcx.
This allows querying it earlier, and independently of the rest of stuff in BuildContext.
2020-02-20 12:04:28 -08:00
Eric Huss 75fa342d59 Fix inaccurate doc comment on `env_args`. 2020-02-16 09:00:26 -08:00
Eric Huss f8fafbc3de Bump to 0.44.0. 2020-01-31 12:05:14 -08:00
Eric Huss c622bea91b Add and update some doc comments.
Just some random things that I felt could use clarification.
2020-01-14 18:07:08 -08:00
Alex Crichton 3a18c89a55 Migrate from the `failure` crate to `anyhow`
The `anyhow` crate interoperates with the `std::error::Error` trait
rather than a custom `Fail` trait, and this is the general trend of
error handling in Rust as well.

Note that this is mostly mechanical (sed) and intended to get the test
suite passing. As usual there's still more idiomatic cleanup that can
happen, but that's left to later commits.
2020-01-07 16:50:09 -08:00
Javier Blazquez a1b846189c Fix dynamic linking for Windows UWP targets 2019-12-31 16:08:22 -08:00
Eric Huss 381251aa1f Config refactoring. 2019-12-19 09:44:01 -08:00
Eric Huss 4d64eb99a4 Add proc_macro to the extern prelude. 2019-12-12 16:56:38 -08:00
Alex Crichton 3a6cd74434 Run rustfmt 2019-10-07 17:12:03 -07:00