Commit graph

1252 commits

Author SHA1 Message Date
bjorn3
1fcae03369 Rustfmt 2025-02-08 22:12:13 +00:00
许杰友 Jieyou Xu (Joe)
4f35eb305b tests: add a missing needs-symlink 2025-02-07 01:41:54 +08:00
许杰友 Jieyou Xu (Joe)
58c4b3ce4a tests: port split-debuginfo to rmake.rs
Co-authored-by: Oneirical <manchot@videotron.ca>
2025-02-01 16:14:58 +08:00
许杰友 Jieyou Xu (Joe)
223e0f1ce1 tests: fix incorrect comment 2025-02-01 16:14:36 +08:00
许杰友 Jieyou Xu (Joe)
16e5ea4ec4 tests: fix incorrect comment for wrong path remap scope 2025-02-01 16:14:36 +08:00
许杰友 Jieyou Xu (Joe)
b06066341b tests: fix -Zunstable-options bug in split-debuginfo 2025-02-01 16:14:36 +08:00
许杰友 Jieyou Xu (Joe)
95ba76b3c5 tests: remove redundant -C debuginfo=2 when -g is already specified
`-g` is an alias for `-C debuginfo=2`.
2025-02-01 16:14:36 +08:00
许杰友 Jieyou Xu (Joe)
97ae7a0b8a tests: use an illustrative else-if branch in split-debuginfo Makefile
This does not work with GNU Make 3.80, but this is just to make it
easier to follow during review.
2025-02-01 16:14:36 +08:00
许杰友 Jieyou Xu (Joe)
d440ea0c8e tests: reformat split-debuginfo's Makefile
To make it easier to tell the conditional branching.
2025-02-01 16:14:36 +08:00
许杰友 Jieyou Xu (Joe)
9734ebb9be tests: port symbol-mangling-hashed to rmake.rs
- Use `object` based test logic instead of processing `nm`
  human-readable textual output.
- Try to expand test coverage to not be limited to only linux + x86_64.

Co-authored-by: binarycat <binarycat@envs.net>
2025-01-31 04:30:51 +00:00
bors
a730edcd67 Auto merge of #135030 - Flakebi:require-cpu, r=workingjubilee
Target option to require explicit cpu

Some targets have many different CPUs and no generic CPU that can be used as a default. For these targets, the user needs to explicitly specify a CPU through `-C target-cpu=`.

Add an option for targets and an error message if no CPU is set.

This affects the proposed amdgpu and avr targets.

amdgpu tracking issue: #135024
AVR MCP: https://github.com/rust-lang/compiler-team/issues/800
2025-01-30 20:21:50 +00:00
许杰友 Jieyou Xu (Joe)
6f5a1035f8 tests: port translation to rmake.rs
Co-authored-by: Oneirical <manchot@videotron.ca>
2025-01-29 08:11:01 +00:00
bors
aa6f5ab18e Auto merge of #133929 - saethlin:remove-inline-in-all-cgus, r=nnethercote
Remove -Zinline-in-all-cgus and clean up tests/codegen-units/

Implementation of https://github.com/rust-lang/compiler-team/issues/814

I've taken some liberties with cleaning up the CGU partitioning tests, because that's the only place this flag was used and also mattered. I've often fought a lot with the contents of `tests/codegen-units` and it has never been clear to me when a test failure indicates a problem with my changes as opposed to a test just needing to be manually blessed. Hopefully the combination of the new README, new comments, and using `-Zprint-mono-items=lazy` in the partitioning tests improves that.

I've also deleted some of the `tests/run-make/sepcomp` tests. I think all the "sepcomp" tests have been obviated for years by better-designed (less flaky, clearer failures) test suites, but here I'm just deleting the ones I'm confident in.
2025-01-28 09:43:03 +00:00
Ben Kimock
bf9df97660 Remove -Zinline-in-all-cgus and clean up CGU partitioning tests 2025-01-27 23:48:47 -05:00
jyn
97311a8969 Downgrade linker-warnings to allow-by-default
This needs more time to bake before we turn it on. Turning it on early risks people silencing the warning indefinitely, before we have the chance to make it less noisy.
2025-01-26 22:57:20 -05:00
jyn
c1b4ab0e73 Shorten linker output even more when --verbose is not present
- Don't show environment variables. Seeing PATH is almost never useful, and it can be extremely long.
- For .rlibs in the sysroot, replace crate hashes with a `"-*"` string. This will expand to the full crate name when pasted into the shell.
- Move `.rlib` to outside the glob.
- Abbreviate the sysroot path to `<sysroot>` wherever it appears in the arguments.

This also adds an example of the linker output as a run-make test. Currently it only runs on x86_64-unknown-linux-gnu, because each platform has its own linker arguments. So that it's stable across machines, pass BUILD_ROOT as an argument through compiletest through to run-make tests.

- Only use linker-flavor=gnu-cc if we're actually going to compare the output. It doesn't exist on MacOS.
2025-01-25 16:04:52 -05:00
bors
f7cc13af82 Auto merge of #119286 - jyn514:linker-output, r=bjorn3
show linker output even if the linker succeeds

Show stderr and stderr by default, controlled by a new `linker_messages` lint.

fixes https://github.com/rust-lang/rust/issues/83436. fixes https://github.com/rust-lang/rust/issues/38206. cc 408986134

<!-- try-job: dist-x86_64-msvc -->
try-job: aarch64-apple

r? `@bjorn3`
2025-01-25 17:16:33 +00:00
jyn
8b92619ce6 Allow LLD version info to be either stderr or stdout 2025-01-24 10:30:47 -05:00
bors
cf577f34c4 Auto merge of #135461 - jieyouxu:migrate-jobserver-errors, r=Noratrieb
tests: Port `jobserver-error` to rmake.rs

Part of #121876.

This PR ports `tests/run-make/jobserver-error` to rmake.rs, and is basically #128789 slightly adjusted.

The complexity involved here is mostly how to get `/dev/null/` piping to fd 3 working with std `Command`, whereas with a shell this is much easier (as is evident with the `Makefile` version).

Supersedes #128789.
This PR is co-authored with `@Oneirical` and `@coolreader18.`

try-job: aarch64-gnu
try-job: i686-gnu-1
try-job: x86_64-gnu-debug
try-job: x86_64-gnu-llvm-18-1
2025-01-23 05:31:12 +00:00
bors
3cd8fcbf87 Auto merge of #135164 - Kobzol:run-make-test-glibc-symbols, r=jieyouxu
Add test for checking used glibc symbols

This test checks that we do not use too new glibc symbols in the compiler on x64 GNU Linux, in order not to break our [glibc promises](https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements.html).

One thing that isn't solved in the PR yet is to make sure that this test will only run on `dist` CI, more specifically on the `dist-x86_64-linux` runner, in the opt-dist post-optimization tests (it can fail elsewhere, that doesn't matter). Any suggestions on how to do that are welcome.

Fixes: https://github.com/rust-lang/rust/issues/134037

r? `@jieyouxu`
2025-01-23 01:03:32 +00:00
Jakub Beránek
5482bbac0f
Reword comment slightly 2025-01-22 17:22:39 +01:00
Jakub Beránek
46ae7382a4
Use objdump instead of llvm-objdump 2025-01-22 12:47:44 +01:00
Jakub Beránek
7877883339
Run the glibc run-make test in opt-dist 2025-01-22 12:47:44 +01:00
许杰友 Jieyou Xu (Joe)
20229200c8 tests: port jobserver-error.rs to rmake.rs
Co-authored-by: Noa <coolreader18@gmail.com>
Co-authored-by: Oneirical <manchot@videotron.ca>
2025-01-22 12:26:50 +08:00
Matthias Krüger
60cb6c4044
Rollup merge of #135824 - jieyouxu:delete-bintools-check, r=Noratrieb
tests: delete `cat-and-grep-sanity-check`

Part of #121876.

All remaining `Makefile`s have open PRs that do not rely on platform `cat` or `grep` or the `cat-and-grep` script.
2025-01-21 23:30:22 +01:00
bors
ed43cbcb88 Auto merge of #134299 - RalfJung:remove-start, r=compiler-errors
remove support for the (unstable) #[start] attribute

As explained by `@Noratrieb:`
`#[start]` should be deleted. It's nothing but an accidentally leaked implementation detail that's a not very useful mix between "portable" entrypoint logic and bad abstraction.

I think the way the stable user-facing entrypoint should work (and works today on stable) is pretty simple:
- `std`-using cross-platform programs should use `fn main()`. the compiler, together with `std`, will then ensure that code ends up at `main` (by having a platform-specific entrypoint that gets directed through `lang_start` in `std` to `main` - but that's just an implementation detail)
- `no_std` platform-specific programs should use `#![no_main]` and define their own platform-specific entrypoint symbol with `#[no_mangle]`, like `main`, `_start`, `WinMain` or `my_embedded_platform_wants_to_start_here`. most of them only support a single platform anyways, and need cfg for the different platform's ways of passing arguments or other things *anyways*

`#[start]` is in a super weird position of being neither of those two. It tries to pretend that it's cross-platform, but its signature is  a total lie. Those arguments are just stubbed out to zero on ~~Windows~~ wasm, for example. It also only handles the platform-specific entrypoints for a few platforms that are supported by `std`, like Windows or Unix-likes. `my_embedded_platform_wants_to_start_here` can't use it, and neither could a libc-less Linux program.
So we have an attribute that only works in some cases anyways, that has a signature that's a total lie (and a signature that, as I might want to add, has changed recently, and that I definitely would not be comfortable giving *any* stability guarantees on), and where there's a pretty easy way to get things working without it in the first place.

Note that this feature has **not** been RFCed in the first place.

*This comment was posted [in May](https://github.com/rust-lang/rust/issues/29633#issuecomment-2088596042) and so far nobody spoke up in that issue with a usecase that would require keeping the attribute.*

Closes https://github.com/rust-lang/rust/issues/29633

try-job: x86_64-gnu-nopt
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
try-job: test-various
2025-01-21 19:46:20 +00:00
Ralf Jung
56c90dc31e remove support for the #[start] attribute 2025-01-21 06:59:15 -07:00
许杰友 Jieyou Xu (Joe)
c45e97c549 tests: delete cat-and-grep-sanity-check
All remaining `Makefile`s have open PRs that do not rely on platform
`cat` or `grep`.
2025-01-21 21:37:14 +08:00
Jakub Beránek
ef9349db86
Add test for checking used glibc symbols 2025-01-21 10:20:24 +01:00
jyn
26708aa941 Don't require --verbose to show linker stdout 2025-01-20 16:46:47 -05:00
jyn
b757663a00 don't ICE when emitting linker errors during -Z link-only
note that this still ICEs when passed `-Z link-only --error-format json` because i can't be bothered to fix it right now
2025-01-20 16:46:45 -05:00
jyn
c0822ed9b8 show linker warnings even if it returns 0 2025-01-20 16:46:00 -05:00
Kyle Huey
45ef92731b When LLVM's location discriminator value limit is exceeded, emit locations with dummy spans instead of dropping them entirely
Revert most of #133194 (except the test and the comment fixes). Then refix
not emitting locations at all when the correct location discriminator value
exceeds LLVM's capacity.
2025-01-19 07:17:33 -08:00
Jiahao XU
2af4197f42
Fix use of pipe in tests/run-make/broken-pipe-no-ice/rmake.rs
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-01-18 01:39:01 +11:00
bors
5cd16b7f2b Auto merge of #135458 - jieyouxu:migrate-extern-fn-reachable, r=lqd
tests: Port `extern-fn-reachable` to rmake.rs

Part of #121876.

## Summary

This PR ports `tests/run-make/extern-fn-reachable` to use `rmake.rs`. Notable changes:

- We now use the `object` crate and look at the exported symbols specifically.
- This test's coverage regressed against windows-msvc back in [replace dynamic library module with libloading #90716](https://github.com/rust-lang/rust/pull/90716), but since we use `object` now, we're able to claw the test coverage back.
- The checks are now stricter:
    1. It no longer looks for substring symbol matches in `nm` textual outputs, it inspects the symbol names precisely.
    2. We now also explicitly check for the presence of leading underscore in exported symbol names on apple vs non-apple targets.
- Added another case of `#[no_mangle] fn fun6() {}` (note the lack of `pub`) to check that Rust nameres visibility is orthogonal to symbol visibility in dylib.

## History

- Test was initially introduced as a run-pass[^run-pass] test as part of [Don't mark reachable extern fns as internal #10539](https://github.com/rust-lang/rust/pull/10539).
- Test re-introduced as a run-make test in https://github.com/rust-lang/rust/pull/13741.
- Later, the test coverage regressed in https://github.com/rust-lang/rust/pull/90716.

[^run-pass]: no longer a thing nowadays

Supersedes #128314.
Co-authored with `@lolbinarycat.`

try-job: x86_64-msvc
try-job: i686-msvc
try-job: i686-mingw
try-job: x86_64-mingw-1
try-job: x86_64-apple-1
try-job: aarch64-apple
try-job: test-various
2025-01-16 02:31:22 +00:00
Flakebi
53238c3db6
Target option to require explicit cpu
Some targets have many different CPUs and no generic CPU that can be
used as a default. For these targets, the user needs to explicitly
specify a CPU through `-C target-cpu=`.

Add an option for targets and an error message if no CPU is set.

This affects the proposed amdgpu and avr targets.
2025-01-16 01:22:50 +01:00
许杰友 Jieyou Xu (Joe)
98f673e93a tests: port extern-fn-reachable to rmake.rs
Co-authored-by: binarycat <binarycat@envs.net>
2025-01-15 01:05:16 +08:00
binarycat
f5e23d5c7b fix typo and unit test 2025-01-14 09:51:55 -06:00
binarycat
d4057e8df0 re-add --disable-minification to rustdoc
this also makes the rust.docs-minification option work
as advertised in config.toml

nothing fancy this time, this is intended to be perma-unstable.
it's only really here for the benefit of rustdoc devs.

mitegates https://github.com/rust-lang/rust/issues/135345
2025-01-11 12:33:25 -06:00
Xing Xue
7f31b579c7 Replace the random substring of a linker argument with a placeholder and nullify the timestamp field of XCOFF files for file comparison. 2025-01-06 16:59:46 -05:00
bors
feb32c6546 Auto merge of #134794 - RalfJung:abi-required-target-features, r=workingjubilee
Add a notion of "some ABIs require certain target features"

I think I finally found the right shape for the data and checks that I recently added in https://github.com/rust-lang/rust/pull/133099, https://github.com/rust-lang/rust/pull/133417, https://github.com/rust-lang/rust/pull/134337: we have a notion of "this ABI requires the following list of target features, and it is incompatible with the following list of target features". Both `-Ctarget-feature` and `#[target_feature]` are updated to ensure we follow the rules of the ABI.  This removes all the "toggleability" stuff introduced before, though we do keep the notion of a fully "forbidden" target feature -- this is needed to deal with target features that are actual ABI switches, and hence are needed to even compute the list of required target features.

We always explicitly (un)set all required and in-conflict features, just to avoid potential trouble caused by the default features of whatever the base CPU is. We do this *before* applying `-Ctarget-feature` to maintain backward compatibility; this poses a slight risk of missing some implicit feature dependencies in LLVM but has the advantage of not breaking users that deliberately toggle ABI-relevant target features. They get a warning but the feature does get toggled the way they requested.

For now, our logic supports x86, ARM, and RISC-V (just like the previous logic did). Unsurprisingly, RISC-V is the nicest. ;)

As a side-effect this also (unstably) allows *enabling* `x87` when that is harmless. I used the opportunity to mark SSE2 as required on x86-64, to better match the actual logic in LLVM and because all x86-64 chips do have SSE2. This infrastructure also prepares us for requiring SSE on x86-32 when we want to use that for our ABI (and for float semantics sanity), see https://github.com/rust-lang/rust/issues/133611, but no such change is happening in this PR.

r? `@workingjubilee`
2025-01-05 23:21:06 +00:00
bors
3f43b1a636 Auto merge of #135034 - Noratrieb:strip-correctly, r=jieyouxu
Pass objcopy args for stripping on OSX

When `-Cstrip` was changed in #131405 to use the bundled rust-objcopy instead of /usr/bin/strip on OSX, strip-like arguments were preserved.

But strip and objcopy are, while being the same binary, different, they have different defaults depending on which binary they are. Notably, strip strips everything by default, and objcopy doesn't strip anything by default.

Additionally, `-S` actually means `--strip-all`, so debuginfo stripped everything and symbols didn't strip anything.

We now correctly pass `--strip-debug` and `--strip-all`.

fixes #135028

try-job: aarch64-apple
try-job: dist-aarch64-apple
2025-01-03 17:20:39 +00:00
Noratrieb
4da3aedb5e Pass objcopy args for stripping on OSX
When `-Cstrip` was changed to use the bundled rust-objcopy instead of
/usr/bin/strip on OSX, strip-like arguments were preserved.

But strip and objcopy are, while being the same binary, different, they
have different defaults depending on which binary they are.
Notably, strip strips everything by default, and objcopy doesn't strip
anything by default.

Additionally, `-S` actually means `--strip-all`, so debuginfo stripped
everything and symbols didn't strip anything.

We now correctly pass `--strip-debug` and `--strip-all`.
2025-01-02 22:17:39 +01:00
John Kåre Alsaker
4bf85c25ec Try to write the panic message with a single write_all call 2025-01-01 15:58:29 +01:00
Ralf Jung
43ede97ebf arm: use target.llvm_floatabi over soft-float target feature 2024-12-31 12:41:20 +01:00
Stuart Cook
3048c4adfc
Rollup merge of #134829 - jieyouxu:migrate-libs-through-symlinks, r=lqd
Migrate `libs-through-symlink` to rmake.rs

Part of https://github.com/rust-lang/rust/issues/121876.

This PR migrates `tests/run-make/libs-through-symlink/` to use rmake.rs.

- Regression test for #13890.
- Original fix PR is #13903.
- Document test intent, backlink to #13890 and fix PR #13903.
- Fix the test logic: the `Makefile` version seems to not actually be exercising the "library search traverses symlink" logic, because the actual symlinked-to-library is present under the `$(TMPDIR)` directory tree when `bar.rs` is compiled, because the `$(RUSTC)` invocation has an implicit `-L $(TMPDIR)`. The symlink itself was actually broken, i.e. it should've been `ln -nsf $(TMPDIR)/outdir/$(NAME) $(TMPDIR)` but it used `ln -nsf outdir/$(NAME) $(TMPDIR)`. The rmake.rs version now explicitly separates the two directory trees and sets the CWD of the `bar.rs` rustc invocation so that the actual library is *not* present under its CWD tree.

I.e. it is now

```
$test_output/           # rustc foo.rs -o actual_lib_dir/libfoo.rlib
    actual_lib_dir/
        libfoo.rlib
    symlink_lib_dir/    # CWD set; rustc -L . bar.rs
        libfoo.rlib --> $test_output/actual_lib_dir/libfoo.rlib
```

Partially supersedes #129011.
This PR is co-authored with `@Oneirical.`

r? compiler
2024-12-28 16:50:38 +11:00
许杰友 Jieyou Xu (Joe)
b32591e580 tests: migrate branch-protection-check-IBT to rmake.rs
- The Makefile version *never* ran because of Makefile syntax confusion.
- The test would've always failed because precompiled std is not built
  with `-Z cf-protection=branch`, but linkers require all input object
  files to indicate IBT support in order to enable IBT for the
  executable, which is not the case for std.
- Thus, the test input file is instead changed to a `no_std` + `no_core`
  program.

Co-authored-by: Jerry Wang <jerrylwang123@gmail.com>
Co-authored-by: Oneirical <manchot@videotron.ca>
2024-12-28 11:58:32 +08:00
许杰友 Jieyou Xu (Joe)
b77ab2dd90 tests: migrate libs-through-symlink to rmake.rs
- Document test intent, backlink to #13890 and fix PR #13903.
- Fix the test logic: the `Makefile` version seems to not actually be
  exercising the "library search traverses symlink" logic, because the
  actual symlinked-to-library is present under the directory tree when
  `bar.rs` is compiled, because the `$(RUSTC)` invocation has an
  implicit `-L $(TMPDIR)`. The symlink itself was actually broken, i.e.
  it should've been `ln -nsf $(TMPDIR)/outdir/$(NAME) $(TMPDIR)` but it
  used `ln -nsf outdir/$(NAME) $(TMPDIR)`.

Co-authored-by: Oneirical <manchot@videotron.ca>
2024-12-28 11:53:01 +08:00
Guillaume Gomez
c016cd8670
Rollup merge of #134656 - jieyouxu:migrate-incr-add-rust-src-component, r=wesleywiser
Migrate `incr-add-rust-src-component` to rmake

This PR partially supersedes #128562, and ports the Makefile-based `tests/run-make/incr-add-rust-src-component` to use rmake.rs infra.

Part of #121876.

This run-make test is a regression test for https://github.com/rust-lang/rust/issues/70924. It (tries to) checks that if we add the `rust-src` component in between two incremental compiles, that the compiler doesn't ICE on the second invocation.

- Original issue:https://github.com/rust-lang/rust/issues/70924
- Fix PR: https://github.com/rust-lang/rust/pull/72767
- PR adding this regression test: https://github.com/rust-lang/rust/pull/72952

However, the Makefile version of this used `$SYSROOT/lib/rustlib/src/rust/src/libstd/lib.rs`, but that actually got moved around and reorganized over the years. As of Dec 2024, the `rust-src` component is more like (specific for our purposes):

```
$SYSROOT/lib/rustlib/src/rust/
    library/std/src/lib.rs
    src/
```

However, this run-make test is ancient and it exercises incr-comp system logic. I'm not sure if this test would actually catch the original regression.

This PR was co-authored with `@Oneirical.`

r? incremental

try-job: i686-msvc
try-job: x86_64-mingw-1
try-job: x86_64-msvc
try-job: aarch64-apple
2024-12-26 19:30:28 +01:00
Michael Goulet
92f93f6d11 Note def descr in NonConstFunctionCall 2024-12-23 22:15:32 +00:00