Commit graph

1339 commits

Author SHA1 Message Date
bors
91a0e1604f Auto merge of #138127 - compiler-errors:rollup-kcarqrz, r=compiler-errors
Rollup of 17 pull requests

Successful merges:

 - #137827 (Add timestamp to unstable feature usage metrics)
 - #138041 (bootstrap and compiletest: Use `size_of_val` from the prelude instead of imported)
 - #138046 (trim channel value in `get_closest_merge_commit`)
 - #138053 (Increase the max. custom try jobs requested to `20`)
 - #138061 (triagebot: add a `compiler_leads` ad-hoc group)
 - #138064 (Remove - from xtensa targets cpu names)
 - #138075 (Use final path segment for diagnostic)
 - #138078 (Reduce the noise of bootstrap changelog warnings in --dry-run mode)
 - #138081 (Move `yield` expressions behind their own feature gate)
 - #138090 (`librustdoc`: flatten nested ifs)
 - #138092 (Re-add `DynSend` and `DynSync` impls for `TyCtxt`)
 - #138094 (a small borrowck cleanup)
 - #138098 (Stabilize feature `const_copy_from_slice`)
 - #138103 (Git ignore citool's target directory)
 - #138105 (Fix broken link to Miri intrinsics in documentation)
 - #138108 (Mention me (WaffleLapkin) when changes to `rustc_codegen_ssa` occur)
 - #138117 ([llvm/PassWrapper] use `size_t` when building arg strings)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-07 02:56:46 +00:00
Michael Goulet
234a68f06f
Rollup merge of #137827 - yaahc:timestamp-metrics, r=estebank
Add timestamp to unstable feature usage metrics

part of https://github.com/rust-lang/rust/issues/129485

with this we should be able to temporarily enable metrics on docs.rs to gather a nice test dataset for the initial PoC dashboard

r? ```@estebank```
2025-03-06 15:40:00 -05:00
Michael Goulet
e05a97769b
Rollup merge of #137643 - beetrees:repr128-dwarf-variant-test, r=jieyouxu
Add DWARF test case for non-C-like `repr128` enums

LLVM 20 fixes DWARF debuginfo for non-C-like 128-bit enums: this PR adds a test case to the `repr128-dwarf` test to ensure that LLVM doesn't regress in the future.

Tracking issue: #56071
2025-03-06 12:22:14 -05:00
许杰友 Jieyou Xu (Joe)
65da1ffe41
Rollup merge of #136581 - jieyouxu:makefile-be-gone, r=Kobzol
Retire the legacy `Makefile`-based `run-make` test infra

The final piece of [porting run-make tests to use Rust #121876](https://github.com/rust-lang/rust/issues/121876).
Closes #121876.
Closes #40713.
Closes #81791 (no longer using `wc`).
Closes #56475 (no longer a problem in current form of that test; we don't ignore the test on `aarch64-unknown-linux-gnu`).

### Summary

This PR removes the legacy `Makefile`-based `run-make` test infra which has served us well over the years. The legacy infra is no longer needed since we ported all of `Makefile`-based `run-make` tests to the new `rmake.rs` infra.

Additionally, this PR:

- Removes `tests/run-make/tools.mk` since no more `Makefile`-based tests remain.
- Updates `tests/run-make/README.md` and rustc-dev-guide docs to remove mention about `Makefile`-based `run-make` tests
- Update test suite requirements in rustc-dev-guide on Windows to no longer need MSYS2 (they should also now run successfully on native Windows MSVC).
- Update `triagebot.toml` to stop backlinking to #121876.

**Thanks to everyone who helped in this effort to modernize the `run-make` test infra and test suite!**

r? bootstrap
2025-03-05 21:46:32 +08:00
Rémy Rakic
36efaf8437 normalize away -Wlinker-messages wrappers from rust-lld rmake test 2025-03-05 11:54:53 +01:00
Jubilee
e5ac9f89eb
Rollup merge of #137373 - Kobzol:tool-stage0-improve, r=jieyouxu
Compile run-make-support and run-make tests with the bootstrap compiler

It does not seem necessary to have to recompile run-make-support on changes to the local compiler/stdlib. This PR simplifies the implementation of a few tools, then switches rms to stage0 and also makes the handling of environment variables in run-make tests simpler.

Best reviewed commit-by-commit. I can split it into multiple PRs if you want.

Also tested that `COMPILETEST_FORCE_STAGE0=1 ./x test tests/run-make --stage 0` still works. Incredibly, it looks like it even passes more tests than on `master` 😆

r? ``@jieyouxu``
2025-03-04 14:50:39 -08:00
bors
f9e0239a7b Auto merge of #135695 - Noratrieb:elf-raw-dylib, r=bjorn3
Support raw-dylib link kind on ELF

raw-dylib is a link kind that allows rustc to link against a library without having any library files present.
This currently only exists on Windows. rustc will take all the symbols from raw-dylib link blocks and put them in an import library, where they can then be resolved by the linker.

While import libraries don't exist on ELF, it would still be convenient to have this same functionality. Not having the libraries present at build-time can be convenient for several reasons, especially cross-compilation. With raw-dylib, code linking against a library can be cross-compiled without needing to have these libraries available on the build machine. If the libc crate makes use of this, it would allow cross-compilation without having any libc available on the build machine. This is not yet possible with this implementation, at least against libc's like glibc that use symbol versioning. The raw-dylib kind could be extended with support for symbol versioning in the future.

This implementation is very experimental and I have not tested it very well. I have tested it for a toy example and the lz4-sys crate, where it was able to successfully link a binary despite not having a corresponding library at build-time.

I was inspired by Björn's comments in https://internals.rust-lang.org/t/bundle-zig-cc-in-rustup-by-default/22096/27
Tracking issue: #135694

r? bjorn3

try-job: aarch64-apple
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
try-job: test-various
2025-03-04 15:39:44 +00:00
bors
2010bba886 Auto merge of #137927 - matthiaskrgr:rollup-yj463ns, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #132388 (Implement `#[cfg]` in `where` clauses)
 - #134900 (Fix parsing of ranges after unary operators)
 - #136938 (Remove `:` from `stack-protector-heuristics-effect.rs` Filecheck Pattern)
 - #137054 (Make phantom variance markers transparent)
 - #137525 (Simplify parallelization in test-float-parse)
 - #137618 (Skip `tidy` in pre-push hook if the user is deleting a remote branch)
 - #137741 (Stop using `hash_raw_entry` in `CodegenCx::const_str`)
 - #137849 (Revert "Remove Win SDK 10.0.26100.0 from CI")
 - #137862 (ensure we always print all --print options in help)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-03 22:57:01 +00:00
Jane Losare-Lusby
ddd04d03d1 Add timestamp to unstable feature usage metrics 2025-03-03 13:24:30 -08:00
Matthias Krüger
f726e5cb84
Rollup merge of #137684 - GuillaumeGomez:rustdoc-dep-info, r=notriddle
Add rustdoc support for `--emit=dep-info[=path]`

Fixes #91982.

This PR adds the `--emit=dep-info` command line flag support. It will be helpful for `cargo` development.

cc ````@epage````

r? ````@notriddle````
2025-03-03 06:41:34 +01:00
许杰友 Jieyou Xu (Joe)
9b17c98d76 run-make: update test suite README 2025-03-02 05:56:56 +08:00
许杰友 Jieyou Xu (Joe)
413b824e5b run-make: remove tools.mk
It has served us well, but it's time to retire the `Makefile` support
file since this is no longer needed.
2025-03-02 05:16:38 +08:00
Jakub Beránek
9d6ca5f286 Ignore a-b-a-linker-guard during cross-compilation 2025-03-01 22:11:14 +01:00
Jakub Beránek
0034d6c928 Compile run-make recipes using the stage0 compiler 2025-03-01 22:11:02 +01:00
Michael Toner
6f505ba767 ensure we always print all --print options in help 2025-03-01 12:05:51 -06:00
bors
0c72c0d11a Auto merge of #133250 - DianQK:embed-bitcode-pgo, r=nikic
The embedded bitcode should always be prepared for LTO/ThinLTO

Fixes #115344. Fixes #117220.

There are currently two methods for generating bitcode that used for LTO. One method involves using `-C linker-plugin-lto` to emit object files as bitcode, which is the typical setting used by cargo. The other method is through `-C embed-bitcode=yes`.

When using with `-C embed-bitcode=yes -C lto=no`, we run a complete non-LTO LLVM pipeline to obtain bitcode, then the bitcode is used for LTO. We run the Call Graph Profile Pass twice on the same module.

This PR is doing something similar to LLVM's `buildFatLTODefaultPipeline`, obtaining the bitcode for embedding after running `buildThinLTOPreLinkDefaultPipeline`.

r? nikic
2025-03-01 08:22:18 +00:00
许杰友 Jieyou Xu (Joe)
d09523d842
Rollup merge of #137540 - yotamofek:pr/more-deprecated-test-directives, r=notriddle
Fix (more) test directives that were accidentally ignored

Continuation of #137099 , caught by #137103 (and needed to unblock that one).
These test directives were accidentally using the old (`// ```@`)``` syntax
2025-02-28 22:29:51 +08:00
许杰友 Jieyou Xu (Joe)
61e90040db
Rollup merge of #137017 - bjorn3:ignore_invalid_bitcode, r=oli-obk
Don't error when adding a staticlib with bitcode files compiled by newer LLVM

cc https://github.com/rust-lang/rust/issues/128955#issuecomment-2657811196
2025-02-28 22:29:49 +08:00
Yotam Ofek
660241d1d4 Fix test directives that were accidentally ignored 2025-02-27 13:22:16 +00:00
Guillaume Gomez
b97310c449 Add run-make test for rustdoc --emit=dep-info option 2025-02-26 20:36:23 +01:00
Noratrieb
a954c51280 Support raw-dylib link kind on ELF
raw-dylib is a link kind that allows rustc to link against a library
without having any library files present.
This currently only exists on Windows. rustc will take all the symbols
from raw-dylib link blocks and put them in an import library, where they
can then be resolved by the linker.

While import libraries don't exist on ELF, it would still be convenient
to have this same functionality. Not having the libraries present at
build-time can be convenient for several reasons, especially
cross-compilation. With raw-dylib, code linking against a library can be
cross-compiled without needing to have these libraries available on the
build machine. If the libc crate makes use of this, it would allow
cross-compilation without having any libc available on the build
machine. This is not yet possible with this implementation, at least
against libc's like glibc that use symbol versioning.
The raw-dylib kind could be extended with support for symbol versioning
in the future.

This implementation is very experimental and I have not tested it very
well. I have tested it for a toy example and the lz4-sys crate, where it
was able to successfully link a binary despite not having a
corresponding library at build-time.
2025-02-26 19:09:51 +01:00
Maja Kądziołka
b8c7e8aa72
Make -Z unpretty=mir suggest -Z dump-mir as well 2025-02-26 13:07:12 +01:00
beetrees
a7bd4a309c
Add DWARF test case for non-C-like repr128 enums 2025-02-25 22:26:52 +00:00
bors
c51b9b6d52 Auto merge of #133832 - madsmtm:apple-symbols.o, r=DianQK
Make `#[used]` work when linking with `ld64`

To make `#[used]` work in static libraries, we use the `symbols.o` trick introduced in https://github.com/rust-lang/rust/pull/95604.

However, the linker shipped with Xcode, ld64, works a bit differently from other linkers; in particular, [it completely ignores undefined symbols by themselves](https://github.com/apple-oss-distributions/ld64/blob/ld64-954.16/src/ld/parsers/macho_relocatable_file.cpp#L2455-L2468), and only consider them if they have relocations (something something atoms something fixups, I don't know the details).

So to make the `symbols.o` file work on ld64, we need to actually insert a relocation. That's kinda cumbersome to do though, since the relocation must be valid, and hence must point to a valid piece of machine code, and is hence very architecture-specific.

Fixes https://github.com/rust-lang/rust/issues/133491, see that for investigation.

---

Another option would be to pass `-u _foo` to the final linker invocation. This has the problem that `-u` causes the linker to not be able to dead-strip the symbol, which is undesirable. (If we did this, we would possibly also want to do it by putting the arguments in a file by itself, and passing that file via ``@`,` e.g. ``@undefined_symbols.txt`,` similar to https://github.com/rust-lang/rust/issues/52699, though that [is only supported since Xcode 12](https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes#Linking), and I'm not sure we wanna bump that).

Various other options that are probably all undesirable as they affect link time performance:
- Pass `-all_load` to the linker.
- Pass `-ObjC` to the linker (the Objective-C support in the linker has different code paths that load more of the binary), and instrument the binaries that contain `#[used]` symbols.
- Pass `-force_load` to libraries that contain `#[used]` symbols.

Failed attempt: Embed `-u _foo` in the object file with `LC_LINKER_OPTION`, akin to https://github.com/rust-lang/rust/issues/121293. Doesn't work, both because `ld64` doesn't read that from archive members unless it already has a reason to load the member (which is what this PR is trying to make it do), and because `ld64` only support the `-l`, `-needed-l`, `-framework` and `-needed_framework` flags in there.

---

TODO:
- [x] Support all Apple architectures.
- [x] Ensure that this works regardless of the actual type of the symbol.
- [x] Write up more docs.
- [x] Wire up a few proper tests.

`@rustbot` label O-apple
2025-02-25 11:59:11 +00:00
Mads Marquart
b202430084 Make #[used] work when linking with ld64 2025-02-24 04:04:59 +01:00
DianQK
1a99ca8da9
The embedded bitcode should always be prepared for LTO/ThinLTO 2025-02-23 21:23:36 +08:00
bjorn3
ec45166166 Tell llvm-ar to not create a symbol table 2025-02-21 13:30:17 +00:00
Patryk Wychowaniec
d5128f9274
avr-rjmp-offset: Explain .target_cpu() 2025-02-20 15:05:06 +01:00
Patryk Wychowaniec
78ddabf31d
Create a generic AVR target: avr-none
This commit removes the `avr-unknown-gnu-atmega328` target and replaces
it with a more generic `avr-none` variant that must be specialized with
the `-C target-cpu` flag (e.g. `-C target-cpu=atmega328p`).
2025-02-19 19:01:51 +01:00
Matthias Krüger
fab38375bc
Rollup merge of #137095 - saethlin:use-hash64-for-hashes, r=workingjubilee
Replace some u64 hashes with Hash64

I introduced the Hash64 and Hash128 types in https://github.com/rust-lang/rust/pull/110083, essentially as a mechanism to prevent hashes from landing in our leb128 encoding paths. If you just have a u64 or u128 field in a struct then derive Encodable/Decodable, that number gets leb128 encoding. So if you need to store a hash or some other value which behaves very close to a hash, don't store it as a u64.

This reverts part of https://github.com/rust-lang/rust/pull/117603, which turned an encoded Hash64 into a u64.

Based on https://github.com/rust-lang/rust/pull/110083, I don't expect this to be perf-sensitive on its own, though I expect that it may help stabilize some of the small rmeta size fluctuations we currently see in perf reports.
2025-02-17 06:38:14 +01:00
Ben Kimock
4cf21866e8 Move hashes from rustc_data_structure to rustc_hashes so they can be shared with rust-analyzer 2025-02-16 16:18:30 -05:00
Jacob Pratt
20004d4bdd
Rollup merge of #135909 - Flakebi:amdgpu-kd, r=jieyouxu,workingjubilee
Export kernel descriptor for amdgpu kernels

The host runtime (HIP or HSA) expects a kernel descriptor object for each kernel in the ELF file. The amdgpu LLVM backend generates the object. It is created as a symbol with the name of the kernel plus a `.kd` suffix.

Add it to the exported symbols in the linker script, so that it can be found.

For reference, the symbol is created here in LLVM: d5457e4c16/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp (L966)
I wrote [a test](6a9115b121) for this as well, I’ll add that once the target is merged and working.
With this, all PRs to get working code for amdgpu are open (this + the target + the two patches adding addrspacecasts for alloca and global variables).

Tracking issue: #135024

r? `@workingjubilee`
2025-02-16 00:51:24 -05:00
bjorn3
9147b6dd28 Add test 2025-02-14 10:54:56 +00:00
clubby789
2966256133 Make -O mean -C opt-level=3 2025-02-13 19:47:55 +00:00
Flakebi
99ec64c34c
Export kernel descriptor for amdgpu kernels
The host runtime (HIP or HSA) expects a kernel descriptor object for
each kernel in the ELF file. The amdgpu LLVM backend generates the
object. It is created as a symbol with the name of the kernel plus a
`.kd` suffix.

Add it to the exported symbols in the linker script, so that it can be
found.
2025-02-12 22:44:39 +01:00
bors
6171d944ae Auto merge of #133092 - madsmtm:bootstrap-deployment-target, r=Mark-Simulacrum,jieyouxu
Always set the deployment target when building std

`cc` has [a bug/feature](https://github.com/rust-lang/cc-rs/issues/1171) (I guess depending on how you look at it) where the default deployment target is taken from the SDK instead of from `rustc`. This causes `compiler-builtins` to build `compiler-rt` with the wrong deployment target on iOS.

I've been meaning to change how `cc` works in this regard, but that's a lengthy process, so let's fix it in bootstrap for now.

The behaviour can be seen locally with `./x build library --set build.optimized-compiler-builtins=true` for various target triples, and then inspecting with `otool -l build/host/stage1/lib/rustlib/*/lib/libcompiler_builtins-*.rlib | rg 'minos|version'`. I have added a rmake test that ensures that we now have the same version everywhere.

Fixes https://github.com/rust-lang/rust/issues/128419
Fixes https://github.com/rust-lang/compiler-builtins/issues/650
Fixes https://github.com/rust-lang/rust/issues/136523
See also https://github.com/rust-lang/cargo/issues/13115, https://github.com/rust-lang/cc-rs/issues/1171, https://github.com/rust-lang/rust/issues/136113
See https://github.com/rust-lang/rust/pull/133092#issuecomment-2626206772 for a description of how the change works.

try-job: i686-gnu-1
try-job: i686-gnu-2
try-job: x86_64-apple-1
try-job: aarch64-apple
try-job: dist-apple-various
try-job: dist-aarch64-apple
try-job: dist-various-2
try-job: x86_64-fuchsia
2025-02-10 21:09:36 +00:00
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
Mads Marquart
9318fbb33a Always set the deployment target when building std 2025-01-31 04:07:06 +01: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