Commit Graph

252424 Commits

Author SHA1 Message Date
Rémy Rakic
97795923fc port rust-lld test to rmake
also check that turning off the linker feature does not use lld
2024-04-15 17:33:02 +00:00
Rémy Rakic
682535e777 add regex to run_make_support
note: version more recent than 1.8 depend on memchr 2.6, which creates
conflicts as memchr 2.5.0 is pinned elsewhere in the workspace
2024-04-15 17:23:16 +00:00
Rémy Rakic
96e7d25891 add missing lld directive to compiletest 2024-04-15 17:23:06 +00:00
bors
023084804e Auto merge of #123937 - RalfJung:miri-link-section, r=oli-obk
Miri on Windows: run .CRT$XLB linker section on thread-end

Hopefully fixes https://github.com/rust-lang/rust/issues/123583

First commit is originally by `@bjorn3`

r? `@oli-obk`
Cc `@ChrisDenton`
2024-04-15 14:36:12 +00:00
bors
84e729a59f Auto merge of #123851 - NobodyXu:patch-1, r=BurntSushi
Update document for std::io::Error::downcast

Resolve concern raised by `@BurntSushi` https://github.com/rust-lang/rust/issues/99262#issuecomment-2042641813
2024-04-15 12:32:57 +00:00
Jiahao XU
05366ee270
Update doc for std::io::Error::downcast 2024-04-15 21:58:36 +10:00
bors
d493fd148d Auto merge of #115717 - jsgf:stablize-json-unused-externs, r=oli-obk
Stabilize --json unused-externs(-silent)

Implement https://github.com/rust-lang/compiler-team/issues/674 ~~(pending its approval)~~
2024-04-15 10:11:46 +00:00
bors
5dcb678ad8 Auto merge of #122917 - saethlin:atomicptr-to-int, r=nikic
Add the missing inttoptr when we ptrtoint in ptr atomics

Ralf noticed this here: https://github.com/rust-lang/rust/pull/122220#discussion_r1535172094

Our previous codegen forgot to add the cast back to integer type. The code compiles anyway, because of course all locals are in-memory to start with, so previous codegen would do the integer atomic, store the integer to a local, then load a pointer from that local. Which is definitely _not_ what we wanted: That's an integer-to-pointer transmute, so all pointers returned by these `AtomicPtr` methods didn't have provenance. Yikes.

Here's the IR for `AtomicPtr::fetch_byte_add` on 1.76: https://godbolt.org/z/8qTEjeraY
```llvm
define noundef ptr `@atomicptr_fetch_byte_add(ptr` noundef nonnull align 8 %a, i64 noundef %v) unnamed_addr #0 !dbg !7 {
start:
  %0 = alloca ptr, align 8, !dbg !12
  %val = inttoptr i64 %v to ptr, !dbg !12
  call void `@llvm.lifetime.start.p0(i64` 8, ptr %0), !dbg !28
  %1 = ptrtoint ptr %val to i64, !dbg !28
  %2 = atomicrmw add ptr %a, i64 %1 monotonic, align 8, !dbg !28
  store i64 %2, ptr %0, align 8, !dbg !28
  %self = load ptr, ptr %0, align 8, !dbg !28
  call void `@llvm.lifetime.end.p0(i64` 8, ptr %0), !dbg !28
  ret ptr %self, !dbg !33
}
```

r? `@RalfJung`
cc `@nikic`
2024-04-15 08:07:47 +00:00
bors
85b884b058 Auto merge of #122997 - matthiaskrgr:compiletest_ices, r=oli-obk
compiletest ice tracking

see https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/where.20to.20mass-add.20known.20ices.20.2F.20merging.20glacier.20into.20rust/near/429082963

This will allow us to sunset most of https://github.com/rust-lang/glacier
The rustc ices will be tracked directly inside the rust testsuite
There are a couple of .sh tests remaining that I have not ported over yet.

This adds `tests/crashes`, a file inside this directory MUST ice, otherwise it is considered test-fail.
This will be used to track ICEs from glacier and the bugtracker.
When someones pr accidentally fixes one of these ICEs, they can move the test from `crashes` into `ui` for example.

I also added a new tidy lint that warns when a test inside `tests/crashes` does not have a `//@ known-bug: ` line

the env var `COMPILETEST_VERBOSE_CRASHES` can be set to get exit code, stderr and stdout of a crash-test to aid debugging/adding tests.
2024-04-15 06:04:50 +00:00
bors
9db7a74525 Auto merge of #123928 - tbu-:pr_statx_enosys, r=workingjubilee
`statx` probe: `ENOSYS` might come from a faulty FUSE driver

Do the availability check regardless of the error returned from `statx`.

CC https://github.com/rust-lang/rust/pull/122079#discussion_r1564761281
2024-04-15 02:07:35 +00:00
bors
1d8f4a6d9c Auto merge of #123828 - cuviper:cargo-aarch64-gnu, r=Mark-Simulacrum
ci: test cargo on `aarch64-gnu`

Since `aarch64-unknown-linux-gnu` is a tier-1 target, we should also test cargo on it, especially since cargo's own CI doesn't cover this yet. This might have helped us discover #123733 sooner, which is not a cargo problem but was uncovered by a new cargo test (which we'll have to skip for now). Everything else passes in my local run, so at least we'll have a guard against future regressions.
2024-04-15 00:04:04 +00:00
Matthias Krüger
2ce487c45c crashes: limit a couple tests to only run on x86_64 and/or not on windows 2024-04-14 23:53:39 +02:00
bors
0d8b3346a3 Auto merge of #123945 - GuillaumeGomez:rollup-14x3enh, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #120900 (std: use `stream_position` where applicable)
 - #123373 (skip Codegen{GCC,Cranelift} when using CI rustc)
 - #123618 (Discard overflow obligations in `impl_may_apply`)
 - #123905 (rustdoc: check redundant explicit links with correct itemid)
 - #123915 (improve documentation slightly regarding some pointer methods)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-14 21:47:39 +00:00
Guillaume Gomez
32be7b7129
Rollup merge of #123915 - shenawy29:patch-1, r=Nilstrieb
improve documentation slightly regarding some pointer methods
2024-04-14 23:24:34 +02:00
Guillaume Gomez
4d32bc3801
Rollup merge of #123905 - notriddle:notriddle/redundant-explicit-link-hunks, r=GuillaumeGomez
rustdoc: check redundant explicit links with correct itemid

Fixes #123677 (a regression caused by #120702)
2024-04-14 23:24:34 +02:00
Guillaume Gomez
86b791a272
Rollup merge of #123618 - compiler-errors:overflow-ambig, r=spastorino
Discard overflow obligations in `impl_may_apply`

Hacky fix for #123493. Throws away obligations that are overflowing in `impl_may_apply` when we recompute if an impl applies, since those will lead to fatal overflow if processed during fulfillment.

Something about #114811 (I think it's the predicate reordering) caused us to evaluate predicates differently in error reporting leading to fatal overflow, though I believe the underlying overflow is possible to hit since this code was rewritten to use fulfillment.

Fixes #123493
2024-04-14 23:24:33 +02:00
Guillaume Gomez
f3a68fb718
Rollup merge of #123373 - onur-ozkan:skip-codegen, r=Mark-Simulacrum
skip Codegen{GCC,Cranelift} when using CI rustc

CI rustc uses the default codegen backend, therefore we can't run `CodegenGCC` and `CodegenCranelift` tests when using it.

cc `@bjorn3` (to make sure I am not doing anything wrong)

Fixes #123331
2024-04-14 23:24:33 +02:00
Guillaume Gomez
fa483a4829
Rollup merge of #120900 - marcospb19:std-use-seek-stream-position, r=joshtriplett
std: use `stream_position` where applicable

by replacing `seek(SeekFrom::Current(0))` calls
2024-04-14 23:24:32 +02:00
Jeremy Fitzhardinge
8880b702fe Add documentation for unused-externs(-silent) 2024-04-14 14:20:58 -07:00
Jeremy Fitzhardinge
fdcb8a9fea Stabilize --json unused-externs(-silent)
Implement https://github.com/rust-lang/compiler-team/issues/674
2024-04-14 14:20:55 -07:00
bors
29b120740b Auto merge of #123719 - RalfJung:compiler_builtins, r=Mark-Simulacrum
update compiler_builtins to 0.1.109

This pulls in https://github.com/rust-lang/compiler-builtins/pull/583 so we should make sure that does not come with any perf surprises.

Cc `@Amanieu`
2024-04-14 18:42:50 +00:00
Ralf Jung
5934aaaa97 Miri: run .CRT$XLB linker section on thread-end 2024-04-14 20:09:05 +02:00
Josh Stone
2970ae5a6b
Fix ENV quotes in aarch64-gnu/Dockerfile
Co-authored-by: Eric Huss <eric@huss.org>
2024-04-14 10:42:59 -07:00
bjorn3
3305e71095 Run static initializers 2024-04-14 18:19:52 +02:00
Tobias Bucher
2325b81d04 statx probe: ENOSYS might come from a faulty FUSE driver
Do the availability check regardless of the error returned from `statx`.

CC https://github.com/rust-lang/rust/pull/122079#discussion_r1564761281
2024-04-14 17:04:41 +02:00
bors
a8a88fe524 Auto merge of #122268 - ChrisDenton:no-libc, r=Mark-Simulacrum
Link MSVC default lib in core

## The Problem

On Windows MSVC, Rust invokes the linker directly. This means only the objects and libraries Rust explicitly passes to the linker are used. In short, this is equivalent to passing `-nodefaultlibs`, `-nostartfiles`, etc for gnu compilers.

To compensate for this [the libc crate links to the necessary libraries](a0f5b4b213/src/windows/mod.rs (L258-L261)). The libc crate is then linked from std, thus when you use std you get the defaults back.or integrate with C/C++.

However, this has a few problems:

- For `no_std`, users are left to manually pass the default lib to the linker
- Whereas `std` has the opposite problem, using [`/nodefaultlib`](https://learn.microsoft.com/en-us/cpp/build/reference/nodefaultlib-ignore-libraries?view=msvc-170) doesn't work as expected because Rust treats them as normal libs. This is a particular problem when you want to use e.g. the debug CRT libraries in their place or integrate with C/C++..

## The solution

This PR fixes this in two ways:

- moves linking the default lib into `core`
- passes the lib to the linker using [`/defaultlib`](https://learn.microsoft.com/en-us/cpp/build/reference/defaultlib-specify-default-library?view=msvc-170). This allows users to override it in the normal way (i.e. with [`/nodefaultlib`](https://learn.microsoft.com/en-us/cpp/build/reference/nodefaultlib-ignore-libraries?view=msvc-170)).

This is more or less equivalent to what the MSVC C compiler does. You can see what this looks like in my second commit, which I'll reproduce here for convenience:

```rust
// In library/core
#[cfg(all(windows, target_env = "msvc"))]
#[link(
    name = "/defaultlib:msvcrt",
    modifiers = "+verbatim",
    cfg(not(target_feature = "crt-static"))
)]
#[link(name = "/defaultlib:libcmt", modifiers = "+verbatim", cfg(target_feature = "crt-static"))]
extern "C" {}
```

## Alternatives

- Add the above to `unwind` and `std` but not `core`
- The status quo
- Some other kind of compiler magic maybe

This bares some discussion so I've t-libs nominated it.
2024-04-14 13:28:21 +00:00
Matthias Krüger
37df49059d update README and add COMPILETEST_VERBOSE_CRASHES env var which when set print stdout, stderr and exit code of "crashes" tests, useful for debugging or adding new tests 2024-04-14 11:30:29 +02:00
Matthias Krüger
6d9175f98e crashes: fix ice detection which did not trigger if code compiled without error by accident 2024-04-14 11:21:58 +02:00
Matthias Krüger
7d826ae43e tests/crashes: add ICEs from matthiaskrgr/glacier2 2024-04-14 11:21:51 +02:00
Matthias Krüger
98dd566033 add .rs crashes from https://github.com/rust-lang/glacier 2024-04-14 11:18:23 +02:00
Matthias Krüger
a5932b1507 compiletest: switch crash detection logic for run_crash_test around
previously we would explicitly look for exit code 101 and call it a crash,
however in case of stack overflows for example, exit code could differ due to the
process being killed by a signal which is not easy to detect on none-unix.

So now we reject everything that exits with 0 (no error) or 1 (compiler failed to compile code)
and "accept" everyhing else as an internal compiler error.
2024-04-14 11:18:23 +02:00
Matthias Krüger
dd1e35f9c0 run_crash_test(): better error message when we get a none-ice 2024-04-14 11:18:23 +02:00
Matthias Krüger
dde3178d58 compiletest: crashes: turn off backtraces for faster tests 2024-04-14 11:17:12 +02:00
Matthias Krüger
7048ce7e8f tidy: add tidy check agains \.rs files inside tests/crashes that are missing "//@ known-bug: " 2024-04-14 11:16:26 +02:00
Matthias Krüger
e09244fab2 add ignore-mode-crashes to the know list of compiletest directive names 2024-04-14 11:16:26 +02:00
Matthias Krüger
d6e70df1a2 crashes: add another test showing that everything works fine when we need compile-flags to repro an ice and add README 2024-04-14 11:16:15 +02:00
Matthias Krüger
7b05360a1e bootstrap/compiletest: implement "crashes" tests that fail if no ice is reproduced 2024-04-14 11:14:45 +02:00
Matthias Krüger
65ca71815a add initial ice as test 2024-04-14 11:04:27 +02:00
bors
78bc0a5656 Auto merge of #123913 - matthiaskrgr:rollup-w8stnwl, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #123651 (Thread local updates for idiomatic examples)
 - #123699 (run-make-support: tidy up support library)
 - #123779 (OpenBSD fix long socket addresses)
 - #123875 (Doc: replace x with y for hexa-decimal fmt)
 - #123879 (Add missing `unsafe` to some internal `std` functions)
 - #123889 (reduce tidy overheads in run-make checks)
 - #123898 (Generic associated consts: Check regions earlier when comparing impl with trait item def)
 - #123902 (compiletest: Update rustfix to 0.8.1)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-14 09:02:22 +00:00
Mohamed El-Shenawy
5b8864ab80
improve documentation slightly regarding some pointer methods 2024-04-14 09:56:33 +02:00
Chris Denton
87e1dd0dfd
Move msvc libs to core 2024-04-14 07:11:53 +00:00
Chris Denton
b1f1039d8b
Replace libc::c_int with core::ffi::c_int
And remove the libc crate when it isn't needed
2024-04-14 07:11:51 +00:00
Matthias Krüger
ab65c68585
Rollup merge of #123902 - ehuss:update-rustfix2, r=Mark-Simulacrum
compiletest: Update rustfix to 0.8.1

This updates the version of rustfix used in compiletest to be closer to what cargo is using. This is to help ensure `cargo fix` and compiletest are aligned. There are some unpublished changes to `rustfix`, which will update in a future PR when those are published.

Will plan to update ui_test in the near future to avoid the duplicate.
2024-04-14 09:02:00 +02:00
Matthias Krüger
20656d9202
Rollup merge of #123898 - fmease:gci-cmp-impl-item-lt-params, r=compiler-errors
Generic associated consts: Check regions earlier when comparing impl with trait item def

Fixes #123836.

r? compiler-errors or compiler
2024-04-14 09:01:59 +02:00
Matthias Krüger
d1782dba49
Rollup merge of #123889 - onur-ozkan:improve-tidy, r=Mark-Simulacrum
reduce tidy overheads in run-make checks

This change makes tidy to handle run-make checks with a single iteration, avoiding the need for multiple iterations and copying.
2024-04-14 09:01:59 +02:00
Matthias Krüger
2ba0c627de
Rollup merge of #123879 - beetrees:missing-unsafe, r=Mark-Simulacrum
Add missing `unsafe` to some internal `std` functions

Adds `unsafe` to a few internal functions that have safety requirements but were previously not marked as `unsafe`. Specifically:

- `std::sys::pal::unix:🧵:min_stack_size` needs to be `unsafe` as `__pthread_get_minstack` might dereference the passed pointer. All callers currently pass a valid initialised `libc::pthread_attr_t`.
- `std:🧵:Thread::new` (and `new_inner`) need to be `unsafe` as it requires the passed thread name to be valid UTF-8, otherwise `Thread::name` will trigger undefined behaviour. I've taken the opportunity to split out the unnamed thread case into a separate `new_unnamed` function to make the safety requirement clearer. All callers meet the safety requirement now that #123505 has been merged.
2024-04-14 09:01:58 +02:00
Matthias Krüger
2bec57d4a9
Rollup merge of #123875 - Ghamza-Jd:master, r=joboet
Doc: replace x with y for hexa-decimal fmt

I found it a bit unintuitive to know which is variable and which is the format string in `format!("{x:x}")`, so I switched it to `y`.
2024-04-14 09:01:58 +02:00
Matthias Krüger
0638780570
Rollup merge of #123779 - semarie:notgull-openbsd-socket, r=Mark-Simulacrum
OpenBSD fix long socket addresses

Original diff from ``@notgull`` in #118349, small changes from me.

on OpenBSD, getsockname(2) returns the actual size of the socket address, and  not the len of the content. Figure out the length for ourselves. see https://marc.info/?l=openbsd-bugs&m=170105481926736&w=2

Fixes #116523
2024-04-14 09:01:57 +02:00
Matthias Krüger
bd4f67c2cd
Rollup merge of #123699 - jieyouxu:rmake-refactor, r=Mark-Simulacrum
run-make-support: tidy up support library

- Make `handle_failed_output` take `&Command` instead of having the caller keep doing `format!("{:#?}", s)`.
- Introduce a helper macro for implementing common command wrappers, such as `arg`, `args`, `run`, `run_fail`.
    - Use the helper macro on existing command wrappers and remove manual copy-pasta'd implementations.
2024-04-14 09:01:57 +02:00
Matthias Krüger
7c8c2f08e1
Rollup merge of #123651 - tgross35:thread-local-updates, r=Mark-Simulacrum
Thread local updates for idiomatic examples

Update thread local examples to make more idiomatic use of `Cell` for `Copy` types, `RefCell` for non-`Copy` types.

Also shrink the size of `unsafe` blocks, add `SAFETY` comments, and fix `clippy::redundant_closure_for_method_calls`.
2024-04-14 09:01:56 +02:00