Commit graph

28 commits

Author SHA1 Message Date
Eric Huss 502a9c5407 Fix tests due to change in dead_code diagnostic. 2022-06-23 13:08:08 -07:00
Joshua Nelson 55b680c194 Add support for -Zbuild-std to cargo fetch
This allows downloading the dependencies for libstd in advance, which
can be useful in e.g. sandboxed build environments.

- Abstract check for `--target` out into a function
- Try to abstract `test` special-casing into a function

  This avoids hard-coding crate names in multiple places.

- Unify handling of checks for `--target` in `BuildConfig::new`

  This makes sure it's checked consistently, without requiring each new command to check it explicitly.

- Share more code between `fetch` and `build` by adding `std_crates()`
- Warn about `--build-plan` and `-Zbuild-std` consistently, not just for `build`

  Currently only `build` uses build-plan. But cargo may choose to add it to new commands in the future (e.g. check and doc).
  Future-proof it, since it's simple to do.
2022-05-03 20:07:14 -05:00
Eric Huss 00e925f61f Fix panic with build-std of a proc-macro. 2021-08-23 12:06:32 -07:00
Eric Huss 0ac41f0051 Fix tests not working with a different CARGO_TARGET_DIR. 2020-12-16 11:19:32 -08:00
Alex Crichton 049b2727b1 Fix a test 2020-12-11 08:43:27 -08:00
Alex Crichton 602f6b64de Revert "Check if rust-src contains a vendor dir, and patch it in"
This reverts commit eadb4fc86c.
2020-12-11 07:45:27 -08:00
Eric Huss 6b472c90e1 Fix panic with -Zbuild-std and no roots. 2020-12-04 13:34:34 -08:00
Alexis Beingessner eadb4fc86c Check if rust-src contains a vendor dir, and patch it in
This is the cargo side of https://github.com/rust-lang/wg-cargo-std-aware/issues/23
2020-11-10 11:47:32 -05:00
Alex Crichton 1faf5b9f00 Add a -Zbuild-std-features flag
This flag is intended to pair with `-Zbuild-std` as necessary to
configure the features that libstd is built with. This is highly
unlikely to ever be stabilized in any form (unlike `-Zbuild-std` which
we'd like to stabilize at some point), but can be useful for
experimenting with the standard library. For example today it can be
used to test changes to binary size by disabling backtraces.

My intention is that we won't need a `--no-default-features` equivalent
for libstd, where after rust-lang/rust#74377 is merged we can
unconditionally specify default features are disabled but the default
set of features lists `default`. That way if users want to override the
list *and* include the default feature, they can just be sure to include
`default`.
2020-07-17 07:02:19 -07:00
Alex Crichton 78314caf38 Ensure unstable.build-std works like -Zbuild-std
This fixes an issue where the deserializer for `-Zbuild-std` was a bit
fancier than the `unstable.build-std` directive.

cc #8393
2020-07-16 08:49:04 -07: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 b6a4b074ed build-std: Don't treat std like a "local" package. 2020-04-28 13:05:55 -07:00
bors 90931d9b31 Auto merge of #8077 - faern:use-assoc-int-consts, r=ehuss
Use associated constants directly on primitive types instead of modules

This PR is in no way critical. It's more of a code cleanup. It comes as a result of me making https://github.com/rust-lang/rust/pull/70857 and search-and-replacing all usage of the soft-deprecated ways of reaching primitive type constants.

It makes the code slightly shorter, that's basically it. And showcases the recommended way of reaching these consts on new code :)
2020-04-28 01:56:59 +00:00
Mateusz Mikuła 9f742466f1 Update tests for windows-gnu 2020-04-21 17:25:25 +02:00
Linus Färnstrand c428c0ef41 Use associated constants directly on primitive types instead of modules 2020-04-06 23:37:06 +02:00
Eric Huss 1c779ac5d4 Switch build-std to use --extern 2019-12-12 08:18:15 -08:00
Eric Huss 83571aee56 Minor testsuite organization. 2019-11-24 18:42:45 -08:00
Matthias Krüger 3fce509208 fix a bunch of clippy warnings 2019-09-26 17:51:19 +02:00
Eric Huss d0ab04add4 Simplify mock rustc wrapper. 2019-09-24 12:45:32 -07:00
Eric Huss 53a3db05a6 Some more --sysroot tests. 2019-09-23 18:53:28 -07:00
Alex Crichton bc5c441b12 Change how standard_lib tests work
* Minimize the sysroot crates in play
* Don't use build scripts to inject args
* Use `RUSTC_WRAPPER` to dynamically switch `--sysroot` depending on
  whether we're building sysroot crates or not.
* Minimize dependency graph in sysroot, only have each crate depend on a
  dummy crates.io crate for testing and otherwise don't depend on
  anything to load the desired sysroot crate directly.
2019-09-23 18:53:28 -07:00
Alex Crichton 0dd79670d4 Add back a full integration test for -Zbuild-std
Only run these tests on one CI builder (not all platforms) though. This
is extremely resource intensive since it rebuilds libstd. Currently this
does not share a build directly like before because the number of tests
are supposed to be small, but if necessary we can add that in later too.
2019-09-16 11:47:09 -07:00
Alex Crichton 9115b2c326 Extract support directory to its own crate
Extract out all our test support code to its own standalone crate so it
can be shared between multiple test suites if necessary.
2019-09-16 11:47:09 -07:00
Alex Crichton 4cbfd02eff Improve test suite for -Zbuild-std
This commit is aimed directly at rust-lang/wg-cargo-std-aware#33 and in
general making the `-Zbuild-std` tests more robust. The main change here
is that a new source tree is checked in, `tests/testsuite/mock-std`,
which mirrors rust-lang/rust's own tree for libstd. This mock tree is as
empty as it can be, ideally duplicating almost nothing but for not
requiring duplication of Cargo metadata about patches and such.

The end result here looks like:

* All `-Zbuild-std` tests are now run in parallel
* All tests run much more quickly since they're compiling tiny crates
  instead of actually compiling libstd/libcore
* No tests require network access
* We verify that crates have access to the "custom" libraries
  that we build

Coverage of tests is not currently expanded, but it's hoped that we
could add that shortly afterwards. Coverage has actually gone down
slightly since the custom target test was commented out temporarily and
the full integration test of running `-Zbuild-std` isn't run on CI any
more.

Closes rust-lang/wg-cargo-std-aware#33
2019-09-16 11:46:46 -07:00
Philipp Oppermann 6b4fd44ea6 Add a test for -Zbuild-std with custom test frameworks 2019-09-15 17:54:35 +02:00
Alex Crichton 2ed112c14e Add alloc and proc_macro to libstd crates
These two have been stabilized for all targets like `std` so if `std` is
requested let's be sure to make them available to other crates as well.
2019-09-06 13:49:48 -07:00
Eric Huss aee4048229 Remove bin_nostd test, it will likely to finicky. 2019-09-03 13:53:59 -07:00
Eric Huss 1f14fa3172 Basic standard library support. 2019-09-03 13:53:59 -07:00