Commit Graph

315 Commits

Author SHA1 Message Date
bors
fc1a4c5cc9 Auto merge of #123221 - pacak:cache_emit, r=fmease,jieyouxu
Save/restore more items in cache with incremental compilation

Right now they don't play very well together, consider a simple example:

```
$ export RUSTFLAGS="--emit asm"
$ cargo new --lib foo
     Created library `foo` package
$ cargo build -q
$ touch src/lib.rs
$ cargo build
error: could not copy
  "/path/to/foo/target/debug/deps/foo-e307cc7fa7b6d64f.4qbzn9k8mosu50a5.rcgu.s"
  to "/path/to/foo/target/debug/deps/foo-e307cc7fa7b6d64f.s":
  No such file or directory (os error 2)
```

Touch triggers the rebuild, incremental compilation detects no changes (yay) and everything explodes while trying to copy files were they should go.

This pull request fixes it by copying and restoring more files in the incremental compilation cache

Fixes https://github.com/rust-lang/rust/issues/89149
Fixes https://github.com/rust-lang/rust/issues/88829

Related: https://internals.rust-lang.org/t/interaction-between-incremental-compilation-and-emit/20551
2024-04-07 10:46:50 +00:00
Oneirical
a9c0ffa35b Rewrite version test as UI test
fix: re-add stout ignore

restore does-nothing

fix: universal check-pass
2024-04-06 15:14:16 -04:00
Michael Baikov
691e953da6 Save/restore more items in cache with incremental compilation 2024-04-06 10:59:24 -04:00
Guillaume Gomez
0d5ee650f8
Rollup merge of #123474 - jieyouxu:issue-7349-port, r=Mark-Simulacrum
Port `run-make/issue-7349` to a codegen test

The test does not need to be a run-make test, it can use the codegen test infrastructure.

Also took the opportunity to rename the test to `no-redundant-item-monomorphization` so it's not just some opaque issue number.

Part of #121876.
2024-04-05 16:38:51 +02:00
Guillaume Gomez
c36c009577
Rollup merge of #123149 - jieyouxu:rmake-arguments-non-c-like-enum, r=Mark-Simulacrum
Port argument-non-c-like-enum to Rust

Part of #121876.
2024-04-05 16:38:50 +02:00
许杰友 Jieyou Xu (Joe)
476156aedf
Port issue-7349 to a codegen test 2024-04-04 21:59:08 +01:00
Yaodong Yang
2575b8e79c move hir-tree test from run-make to ui test 2024-04-04 18:43:26 +08:00
许杰友 Jieyou Xu (Joe)
fd7bc59363
Port argument-non-c-like-enum to Rust 2024-04-01 17:07:49 +01:00
beetrees
0bbaa2505b
Fix error message for env! when env var is not valid Unicode 2024-04-01 05:44:45 +01:00
Jubilee
17737bfece
Rollup merge of #123180 - Oneirical:master, r=Mark-Simulacrum
Rewrite `core-no-fp-fmt-parse` test in Rust

Claiming the simple "core-no-fp-fmt-parse" test from #121876. `run_make_support` was altered with `arg_path` written in #121918 by `@abhay-51,` with additional doc comment.

Preliminary GSoC contribution for the project proposal mentored by `@jieyouxu.`
2024-03-31 13:18:16 -07:00
Oneirical
e477488267 Rewrite core-no-fp-fmt-parse in Rust
Rewrite core-no-fp-fmt-parse in Rust

fix: missing import

fix: tidiness check

more tidy checks

remove tidy line length ignore

new helper functions + arg_path generic

fix: remove unused import

delete arg_path, change arg_path to input
2024-03-30 19:40:18 -04:00
bors
685927aae6 Auto merge of #122450 - Urgau:simplify-trim-paths-feature, r=michaelwoerister
Simplify trim-paths feature by merging all debuginfo options together

This PR simplifies the trim-paths feature by merging all debuginfo options together, as described in https://github.com/rust-lang/rust/issues/111540#issuecomment-1994010274.

And also do some correctness fixes found during the review.

cc `@weihanglo`
r? `@michaelwoerister`
2024-03-29 14:00:21 +00:00
Urgau
106146fd95 Replace RemapFileNameExt::for_codegen with explicit calls 2024-03-28 18:47:26 +01:00
Urgau
777c6b46cc Simplify trim-paths feature by merging all debuginfo options together 2024-03-28 18:47:26 +01:00
许杰友 Jieyou Xu (Joe)
9762d66f72
Use compiletest directives for ignoring targets 2024-03-27 22:15:50 +00:00
许杰友 Jieyou Xu (Joe)
12e999274d
Convert wasmtime check into a compiletest needs directive 2024-03-27 22:15:49 +00:00
许杰友 Jieyou Xu (Joe)
08853804d0
Use compiletest directives for properly only running wasm32-wasip1 tests on that target 2024-03-27 21:55:09 +00:00
bors
0157da41ee Auto merge of #122460 - jieyouxu:rmake-example-refactor, r=Nilstrieb
Rework rmake support library API

### Take 1: Strongly-typed API

Context: https://github.com/rust-lang/rust/pull/122448#discussion_r1523774427

> My 2 cents: from my experience with writing similar "test DSLs", I would suggest to create these helpers as soon as possible in the process (basically the first time someone needs them, not only after N similar usages), and basically treat any imperative code in these high-level tests as a maintenance burden, basically making them as declarative as possible. Otherwise it might be a bit annoying to keep refactoring the tests later once such helpers are available.
>
> I would even discourage the arg method and create explicit methods for setting things like unpretty, the output file etc., but this might be more controversial, as it will make the invoked command-line arguments more opaque.

cc `@Kobzol` for the testing DSL suggestion.

Example:

```rs
let output = Rustc::new()
    .input_file("main.rs")
    .emit(&[EmitKind::Metadata])
    .extern_("stable", &stable_path)
    .output();
```

### Take 2: xshell-based macro API

Example:

```rs
let sh = Shell::new()?;
let stable_path = stable_path.to_string_lossy();
let output = cmd!(sh, "rustc main.rs --emit=metadata --extern stable={stable_path}").output()?;
```

### Take 3: Weakly-typed API with a few helper methods

```rs
let output = Rustc::new()
    .input("main.rs")
    .emit("metadata")
    .extern_("stable", &stable_path)
    .output();
```
2024-03-27 17:43:20 +00:00
bors
47ecded352 Auto merge of #118644 - madsmtm:macos-weak-linking-test, r=compiler-errors
Add test for Apple's `-weak_framework` linker argument

The [`-weak_framework`](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html) linker argument can sometimes be useful to reduce startup times, and to link newer frameworks while still having older deployment targets.

So I made a test to ensure that it continues to work.

Discussed in https://github.com/rust-lang/rust/issues/99427.
2024-03-26 20:22:54 +00:00
bors
c98ea0d808 Auto merge of #111769 - saethlin:ctfe-backtrace-ctrlc, r=RalfJung
Print a backtrace in const eval if interrupted

Demo:
```rust
#![feature(const_eval_limit)]
#![const_eval_limit = "0"]

const OW: u64 = {
    let mut res: u64 = 0;
    let mut i = 0;
    while i < u64::MAX {
        res = res.wrapping_add(i);
        i += 1;
    }
    res
};

fn main() {
    println!("{}", OW);
}
```
```
╭ ➜ ben@archlinux:~/rust
╰ ➤ rustc +stage1 spin.rs
^Cerror[E0080]: evaluation of constant value failed
 --> spin.rs:8:33
  |
8 |         res = res.wrapping_add(i);
  |                                 ^ Compilation was interrupted

note: erroneous constant used
  --> spin.rs:15:20
   |
15 |     println!("{}", OW);
   |                    ^^

note: erroneous constant used
  --> spin.rs:15:20
   |
15 |     println!("{}", OW);
   |                    ^^
   |
   = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.
```
2024-03-26 00:04:03 +00:00
bjorn3
3733dcc72d Add needs-unwind annotations to a couple of tests 2024-03-25 14:19:07 +00:00
许杰友 Jieyou Xu (Joe)
1f2178b9e7
Rework rmake support library to have a weakly-typed API with helper methods 2024-03-24 15:37:24 +00:00
Guillaume Gomez
bc4f1697fa Add regression test for #122722 2024-03-23 20:13:22 +01:00
bors
b3df0d7e5e Auto merge of #122580 - saethlin:compiler-builtins-can-panic, r=pnkfelix
"Handle" calls to upstream monomorphizations in compiler_builtins

This is pretty cooked, but I think it works.

compiler-builtins has a long-standing problem that at link time, its rlib cannot contain any calls to `core`. And yet, in codegen we _love_ inserting calls to symbols in `core`, generally from various panic entrypoints.

I intend this PR to attack that problem as completely as possible. When we generate a function call, we now check if we are generating a function call from `compiler_builtins` and whether the callee is a function which was not lowered in the current crate, meaning we will have to link to it.

If those conditions are met, actually generating the call is asking for a linker error. So we don't. If the callee diverges, we lower to an abort with the same behavior as `core::intrinsics::abort`. If the callee does not diverge, we produce an error. This means that compiler-builtins can contain panics, but they'll SIGILL instead of panicking. I made non-diverging calls a compile error because I'm guessing that they'd mostly get into compiler-builtins by someone making a mistake while working on the crate, and compile errors are better than linker errors. We could turn such calls into aborts as well if that's preferred.
2024-03-22 16:55:11 +00:00
Ben Kimock
2f6fb234de Add a test 2024-03-20 23:36:05 -04:00
Mads Marquart
440fce19a1 Ensure using otool that framework linking actually happened 2024-03-18 23:27:44 +01:00
Josh Stone
29430554f6 Update the minimum external LLVM to 17 2024-03-17 10:11:04 -07:00
Ben Kimock
9e0d1a3284 Print a backtrace in const eval if interrupted 2024-03-17 11:55:20 -04:00
León Orell Valerian Liehr
c2b7d77d95
Rollup merge of #122270 - onur-ozkan:fix-rmake-test-with-rpath-false, r=Mark-Simulacrum
fix `long-linker-command-lines` failure caused by `rust.rpath=false`

Fixes `long-linker-command-lines` test failure (which happens when `rust.rpath` is set to `false`) by adjusting `LD_LIBRARY_PATH`.

Fixes https://github.com/rust-lang/rust/issues/90921
2024-03-16 23:28:48 +01:00
bors
72d78970ec Auto merge of #122555 - GuillaumeGomez:rollup-tr6wu54, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #114651 (rustdoc: add `--test-builder-wrapper` arg to support wrappers such as RUSTC_WRAPPER when building doctests)
 - #122468 (Cleanup `MirBorrowckCtxt::prefixes`)
 - #122496 (Greatly reduce GCC build logs)
 - #122512 (Cursor.rs documentation fix)
 - #122513 (hir: Remove `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id`)
 - #122530 (less symbol interner locks)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-15 16:39:42 +00:00
Travis Finkenauer
3d53242e53 rustdoc: fix test's saved stdout
Also reword "test-builder-wrapper" argument help.
2024-03-15 01:41:37 -07:00
Michael Wörister
0a094bae28 Make pdb-alt-path test more unwind-friendly for i686-pc-windows-msvc 2024-03-14 11:03:15 +01:00
Michael Wörister
e1c3a5a7aa Force frame pointers in pdb-alt-path test case 2024-03-14 09:54:29 +01:00
Michael Wörister
3c49fe0cbd link.exe: don't embed full path to PDB file in binary. 2024-03-14 09:54:29 +01:00
Alex Crichton
7141379559 Convert some WebAssembly run-make tests to Rust
This commit rewrites a number of `run-make` tests centered around wasm
to instead use `rmake.rs` and additionally use the `wasm32-wasip1`
target instead of `wasm32-unknown-unknown`. Testing no longer requires
Node.js and additionally uses the `wasmparser` crate from crates.io to
parse outputs and power assertions.
2024-03-11 09:36:35 -07:00
Jacob Pratt
05f22c3614
Rollup merge of #121840 - oli-obk:freeze, r=dtolnay
Expose the Freeze trait again (unstably) and forbid implementing it manually

non-emoji version of https://github.com/rust-lang/rust/pull/121501

cc #60715

This trait is useful for generic constants (associated consts of generic traits). See the test (`tests/ui/associated-consts/freeze.rs`) added in this PR for a usage example. The builtin `Freeze` trait is the only way to do it, users cannot work around this issue.

It's also a useful trait for building some very specific abstrations, as shown by the usage by the `zerocopy` crate: https://github.com/google/zerocopy/issues/941

cc ```@RalfJung```

T-lang signed off on reexposing this unstably: https://github.com/rust-lang/rust/pull/121501#issuecomment-1969827742
2024-03-11 03:47:19 -04:00
Matthias Krüger
8b9b83b14c
Rollup merge of #121685 - fortanix:raoul/shellcheck_on_lvi_test_script, r=Mark-Simulacrum
Fixing shellcheck comments on lvi test script

Running `shellcheck` on `tests/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh` gives plenty of warnings. This PR fixes those issues. For completeness: #121683 fixes another warning as well
2024-03-10 10:58:16 +01:00
onur-ozkan
f25809d2d3 fix long-linker-command-lines failure caused by rust.rpath=false
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-03-10 09:29:13 +03:00
Matthias Krüger
8886c310e4
Rollup merge of #121683 - fortanix:raoul/lvi_fixes, r=cuviper
Fix LVI tests after frame pointers are enabled by default

#121203 enables frame pointers by default. This affects LVI mitigations for the `x86_64-fortanix-unknown-sgx` target. LVI remained mitigated correctly, but the tests were too strict.

``@nshyrei`` , ``@jethrogb``
2024-03-04 22:16:31 +01:00
Raoul Strackx
ede25ad319 Fix LVI tests after making frame pointers easily enableable 2024-03-04 11:05:13 +01:00
bors
17edacef07 Auto merge of #113026 - jieyouxu:run-make-v2, r=bjorn3
Introduce `run-make` V2 infrastructure, a `run_make_support` library and port over 2 tests as example

## Preface

See [issue #40713: Switch run-make tests from Makefiles to rust](https://github.com/rust-lang/rust/issues/40713) for more context.

## Basic Description of `run-make` V2

`run-make` V2 aims to eliminate the dependency on `make` and `Makefile`s for building `run-make`-style tests. Makefiles are replaced by *recipes* (`rmake.rs`). The current implementation runs `run-make` V2 tests in 3 steps:

1. We build the support library `run_make_support` which the `rmake.rs` recipes depend on as a tool lib.
2. We build the recipe `rmake.rs` and link in the support library.
3. We run the recipe to build and run the tests.

`rmake.rs` is basically a replacement for `Makefile`, and allows running arbitrary Rust code. The support library is built using cargo, and so can depend on external crates if desired.

The infrastructure implemented by this PR is very barebones, and is the minimally required infrastructure needed to build, run and pass the two example `run-make` tests ported over to the new infrastructure.

### Example `run-make` V2 test

```rs
// ignore-tidy-linelength

extern crate run_make_support;

use std::path::PathBuf;

use run_make_support::{aux_build, rustc};

fn main() {
    aux_build()
        .arg("--emit=metadata")
        .arg("stable.rs")
        .run();
    let mut stable_path = PathBuf::from(env!("TMPDIR"));
    stable_path.push("libstable.rmeta");
    let output = rustc()
        .arg("--emit=metadata")
        .arg("--extern")
        .arg(&format!("stable={}", &stable_path.to_string_lossy()))
        .arg("main.rs")
        .run();

    let stderr = String::from_utf8_lossy(&output.stderr);
    let version = include_str!(concat!(env!("S"), "/src/version"));
    let expected_string = format!("stable since {}", version.trim());
    assert!(stderr.contains(&expected_string));
}
```

## Follow Up Work

- [ ] Adjust rustc-dev-guide docs
2024-03-01 16:43:57 +00:00
bors
6db96de66c Auto merge of #120264 - weihanglo:split-dward-kind-lto, r=michaelwoerister
test: enable `unpacked-lto` tests

This enables the correct `unpacked-lto` tests.

Not sure whether `.o` should be removed.
They are bitcode for linker-plugin-lto, though there might be some `.o` for `#[no_builtins]`?
2024-03-01 13:45:10 +00:00
许杰友 Jieyou Xu (Joe)
48e9f92ce2
Add supporting infrastructure for run-make V2 tests 2024-02-29 16:30:38 +00:00
Oli Scherer
7849230740 Forbid implementing Freeze even if the trait is stabilized 2024-02-29 14:10:29 +00:00
Raoul Strackx
70639c8a6a Fixing shellcheck comments on lvi test script 2024-02-27 16:50:25 +01:00
Matthias Krüger
d95c321062
Rollup merge of #121598 - RalfJung:catch_unwind, r=oli-obk
rename 'try' intrinsic to 'catch_unwind'

The intrinsic has nothing to do with `try` blocks, and corresponds to the stable `catch_unwind` function, so this makes a lot more sense IMO.

Also rename Miri's special function while we are at it, to reflect the level of abstraction it works on: it's an unwinding mechanism, on which Rust implements panics.
2024-02-27 00:40:00 +01:00
Ralf Jung
b4ca582b89 rename 'try' intrinsic to 'catch_unwind' 2024-02-26 11:10:18 +01:00
Guillaume Gomez
0e08be5360
Rollup merge of #120656 - Zalathar:filecheck-flags, r=wesleywiser
Allow tests to specify a `//@ filecheck-flags:` header

This allows individual codegen/assembly/mir-opt tests to pass extra flags to the LLVM `filecheck` tool as needed.

---

The original motivation was noticing that `tests/run-make/instrument-coverage` was very close to being an ordinary codegen test, except that it needs some extra logic to set up platform-specific variables to be passed into filecheck.

I then saw the comment in `verify_with_filecheck` indicating that a `filecheck-flags` header might be useful for other purposes as well.
2024-02-26 10:27:41 +01:00
bors
dc00e8cdb6 Auto merge of #121317 - ChrisDenton:win10-sync, r=Mark-Simulacrum
Always use WaitOnAddress on Win10+

`WaitOnAddress` and `WakeByAddressSingle` are always available since Windows 8 so they can now be used without needing to delay load. I've also moved the Windows 7 thread parking fallbacks into a separate sub-module.
2024-02-26 06:31:30 +00:00
Chris Denton
35421c7461
Add synchronization library to run-make flags 2024-02-25 22:28:30 -03:00