36 Commits

Author SHA1 Message Date
Weihang Lo
56f44bb212
test: avoid hardcoded target spec json
Read a real target spec JSON so we no longer need to hardcode
a target spec JSON here.
Cargo itself should not care about the spec schema.

Let's stop bothering compiler contributors.
2025-08-23 22:26:08 -04:00
Weihang Lo
58ff5efe61
test(build-std): relax the thread name assertion
rust-lang/rust#115746 changed to print thread ID,
so we update accordingly.
2025-08-08 17:34:48 -04:00
houpo-bob
cbef1d150a chore: fix some minor issues in comments
Signed-off-by: houpo-bob <houpocun@outlook.com>
2025-07-30 15:53:03 +08:00
Noratrieb
a6e1f11d4e Remove unnecessary target-c-int-width from target specs
This is not necessary, as 32 is the default, and actually of the wrong
type now since it's a number now.
When planning to make these type mismatches error, cargo would fail
here, so I just removed it.

This custom target test very much shows how Cargo should be a subtree,
in this case it was fine because there's a compatible fix that I can
push now, otherwise it would have been very annoying.
2025-07-20 15:04:25 +02:00
Eric Huss
1ce8023626 Rustfmt 2024 2025-07-05 19:50:36 -07:00
Ross Sullivan
15f755cefd
chore: Created CargoProjectExt extention trait 2025-06-25 23:18:00 +09:00
Weihang Lo
b65e1dde25
test(build-std): address overly-matched snapshot
Still trying to bisect what went wrong,
but this should be fairly safe to merge.

Failed on nightly-2025-03-18 but not nightly-2025-03-17 btw.
2025-03-18 13:55:52 -04:00
Weihang Lo
b7d98618b6
test: relax panic output assertion
rust-lang/rust#122565 adds a new line to thread panic output.
To make the current test suites works on stable, beta, and nightly,
similar to rust-lang/cargo#14602,
this relaxes the assertion around that by globbing everything.
2024-12-29 13:45:24 -05:00
Weihang Lo
0149bca5cc
fix(build-std): behavior revert of 125e873dffc4b68b
This is kinda a revert of 125e873dffc4b68b263c5decd88750ec10fd441e
in terms of the behavior.

After this, now `std_resolve` is always resolved by the same set of
packages that Cargo will use to generate the unit graph, (technically
the same set of crates + `sysroot`), by sharing the same set of primary
packages via `std_crates` functions.
2024-12-17 19:02:35 -05:00
Weihang Lo
f004691aa4
test(build-std): resolve too less deps
This failed because since 125e873dffc4b68b263c5decd88750ec10fd441e
[`std_resolve`][1] only includes `sysroot` as primary package.
When any custom Cargo feature is provided via `-Zbuild-std-feature`,
the default feature set `panic-unwind` would be gone, so no
`panic_unwind` crate presents in `std_resolve`.

When then calling [`std_resolve.query`][2] with the default set of
crates from [`std_crates`][3], which automatically includes
`panic_unwind` when `std` presents, it'll result in spec not found
because `panic_unwind` was not in `std_resolve` anyway.

[1]: addcc8ca71/src/cargo/core/compiler/standard_lib.rs (L96)
[2]: addcc8ca71/src/cargo/core/compiler/standard_lib.rs (L158)
[3]: addcc8ca71/src/cargo/core/compiler/standard_lib.rs (L156)

See rust-lang/cargo#14935
2024-12-17 19:02:35 -05:00
Weihang Lo
ca59614620
test(build-std): Isolate output test to avoid spurious [BLOCKING] messages from concurrent runs
47c2095b1dd580a91e42cb6197b58a318526b8c4 didn't really fix the flakiness.

build-std tests use the users `CARGO_HOME` for downloading registry
dependencies of the standard library. This reduces disk needs of the
tests, speeds up the tests, and reduces the number of network requests
that could fail.

However, this means all of the tests access the same locks for the
package cache.  In one test, we assert on the output and a `[BLOCKING]`
message can show up, depending on test execution time from concurrent
test runs.

We are going to hack around this by having the one test that asserts
on test output to use the standard `cargo-test-support` `CARGO_HOME`,
rather than the users `CARGO_HOME`. There will then only be one process
accessing the lock and no `[BLOCKING]` messages.
2024-12-17 18:43:17 -05:00
Weihang Lo
47c2095b1d
test(build-std): download deps first
So that we can assert the full output of `cargo test` without wildcard
2024-11-26 13:39:36 -05:00
Weihang Lo
4527567c9f
fix(build-std): always link to std when testing/running proc-macros 2024-11-22 00:01:14 -05:00
Weihang Lo
33e6b331c8
test(build-std): shows that proc macro unittest fails
This starts failing since https://github.com/rust-lang/rust/pull/131188
2024-11-21 23:57:51 -05:00
bors
9abcaefd51 Auto merge of #14317 - harmou01:dev/harmou01/remove-target-flag-req, r=ehuss
Remove requirement for --target when invoking Cargo with -Zbuild-std

This PR addresses [this issue](https://github.com/rust-lang/wg-cargo-std-aware/issues/25) re: build-std stabilization. We believe the requirement for --target to be specified when invoking cargo with -Zbuild-std, from our testing, is no longer needed. Now, with this change, by default Cargo will use the Host CompileKind, rather than a manually specified CompileTarget. We propose removing this restriction in order to test this more widely. Our own testing is detailed below.

This change has been tested in the following manner:
* Building crates depending on proc_macro, std, and build scripts (which themselves depend on proc_macro)
* Various RUSTFLAGS, such as `-Zsanitizer=cfi`, `-Cembed-bitcode=yes`, `-Cforce-frame-pointers`, `-Cforce-unwind-tables=yes`, `-Csoft-float=yes`, `-Zbranch-protection=pac-ret`.
2024-10-30 13:54:02 +00:00
Weihang Lo
8534276f0d
test(build-std): relax compiler panic assertions 2024-09-30 13:25:34 -04:00
Harry Moulton
3597f4cd9b test: build-std proc_macro test case without --target requirement
Add a new test case for building a crate with -Zbuild-std, without the
requirement for the --target flag, and that uses a proc_macro.
2024-09-25 10:52:40 +01:00
Weihang Lo
9af3930321
test(build-std): expand assertion to ensure no index update 2024-08-05 23:22:19 -04:00
Ed Page
5b9799c6f4 refactor: Migrate from extern crate to test-support prelude
We now include the prelude in so many places, this simplifies how we can
present how `cargo-test-support` works.

Yes, this included some `use` clean ups but its already painful enough
walking through every test file, I didn't want to do it twice.
2024-07-12 15:57:00 -05:00
eth3lbert
04cccfa259
test: migrate build-std/main to snapbox 2024-07-12 11:56:07 +08:00
Ed Page
dc5ac62cab fix(test): Deprecate non-snapbox assertions
While this is noisy and hides other deprecations, I figured deprecations would
make it easier for people to discover what tasks remain and allow us to
divide and conquer this work rather than doing a heroic PR.
In theory, this will be short lived and we'll go back to seeing
deprecations in our tests.
2024-06-10 10:20:52 -05:00
Lin Yihai
01de3e0fe7 feat: Add "-Zpublic-dependency" for public-dependency feature 2024-02-27 05:10:17 +08:00
Eric Huss
d3c2a7723f Update target data layout for LLVM update. 2024-02-15 08:47:26 -08:00
Ed Page
e7e8d8748a fix(compiler): Clarify we're showing a profile name 2024-02-08 14:01:39 -06:00
Weihang Lo
f1aefdd9f7
test: data layout fix for x86_64-unknown-none-gnu 2024-01-28 15:52:14 -05:00
Weihang Lo
8709835a01
fix: reorder --remap-path-prefix flags for -Zbuild-std
Order of `--remap-path-prefix` flags is important for `-Zbuild-std`.
We want to show `/rustc/<hash>/library/std` instead of `std-0.0.0`.
2023-11-28 15:29:03 -05:00
Weihang Lo
d6b46bfd37
test(trim-paths): demonstrate not work properly with -Zbuild-std 2023-11-28 15:07:10 -05:00
Weihang Lo
870f9ea7b3
lint: allow disallow_methods 2023-11-16 11:35:21 -05:00
Eric Huss
1c3640e05c Add requirements to cargo_test. 2022-07-30 19:36:58 -07:00
Scott Schafer
c239e407e7 add a reason to masquerade_as_nightly_cargo so it is searchable 2022-07-15 21:32:23 -05:00
Eric Huss
3b7cb69eed Fix build-std updating the index on every build. 2021-04-22 17:18:26 -07:00
Alex Crichton
4c02977c21 Improve support for non-master main branches
This commit improves Cargo's support for git repositories whose "main
branch" is not called `master`. Cargo currently pretty liberally assumes
that if nothing else about a git repository is specified then `master`
is the branch name to use. Instead now Cargo has a fourth option as the
desired reference of a repository named `DefaultBranch`. Cargo doesn't
know anything about the actual name of the default branch, it just
updates how git references are fetched internally.

This commit is motivated by news that GitHub is likely to switch away
from the default branch being named `master` in the near future. It
would be a bit of a bummer if from now on everyone had to type
`branch = '...'`, so this tries to improve that!
2020-06-18 10:56:19 -07:00
Eric Huss
98b6f8160e Wrap Package/Target in Rc.
This is intended to make it easier to deal with Unit lifetimes.
2020-04-19 10:36:26 -07:00
Eric Huss
285dc3182a Update documentation for custom target dependencies. 2019-11-22 10:22:26 -08:00
Eric Huss
53a3db05a6 Some more --sysroot tests. 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