Commit graph

249212 commits

Author SHA1 Message Date
bors b0170b693e Auto merge of #122365 - matthiaskrgr:rollup-4i350h6, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #115141 (Update Windows platform support)
 - #121865 (Add FileCheck annotations to MIR-opt unnamed-fields tests)
 - #122000 (Fix 32-bit overflows in LLVM composite constants)
 - #122194 (Enable creating backtraces via -Ztreat-err-as-bug when stashing errors)
 - #122319 (Don't ICE when non-self part of trait goal is constrained in new solver)
 - #122339 (Update books)
 - #122342 (Update /NODEFAUTLIB comment for msvc)
 - #122343 (Remove some unnecessary `allow(incomplete_features)` in the test suite)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-12 06:29:06 +00:00
Matthias Krüger 39e00760ec
Rollup merge of #122343 - compiler-errors:rando, r=fmease
Remove some unnecessary `allow(incomplete_features)` in the test suite

A useless change, but I like things to be clean.
2024-03-12 06:29:05 +01:00
Matthias Krüger 7b29381c8a
Rollup merge of #122342 - ChrisDenton:defautlib, r=petrochenkov
Update /NODEFAUTLIB comment for msvc

I've tried to explain a bit more about the effects of `/NODEFAULTLIB` when using msvc link.exe (or compatible) as they're different from `-nodefaultlib` on gnu.

I also removed the part about licensing as I'm not sure licensing is an issue? Or rather, it's no more or less of an issue no matter how you link msvc libraries. The license is the one you get if using VS at all and even dynamic linking includes static code (e.g. startup/shutdown code, etc).

r? petrochenkov
2024-03-12 06:29:05 +01:00
Matthias Krüger 3d5d83911f
Rollup merge of #122339 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/reference

3 commits in 3417f866932cb1c09c6be0f31d2a02ee01b4b95d..5afb503a4c1ea3c84370f8f4c08a1cddd1cdf6ad
2024-03-06 21:29:54 UTC to 2024-02-28 04:06:45 UTC

- Input format (rust-lang/reference#1459)
- Lexer: say that lifetime-like tokens can't be immediately followed by ' (rust-lang/reference#1479)
- Patterns and enums (rust-lang/reference#1460)

## rust-lang/rust-by-example

2 commits in 57f1e708f5d5850562bc385aaf610e6af14d6ec8..e093099709456e6fd74fecd2505fdf49a2471c10
2024-03-08 23:30:57 UTC to 2024-02-26 21:10:20 UTC

- While-Let Unable to compile code example on page (rust-lang/rust-by-example#1819)
- Update new_types.md wording (rust-lang/rust-by-example#1823)

## rust-lang/rustc-dev-guide

14 commits in 7b0ef5b0bea5e3ce3b9764aa5754a60e2cc05c52..8a5d647f19b08998612146b1cb2ca47083db63e0
2024-03-11 10:37:18 UTC to 2024-02-29 09:46:28 UTC

- update rustc-driver-interacting-with-the-ast.md (rust-lang/rustc-dev-guide#1930)
- Update rustc-driver-getting-diagnostics.md (rust-lang/rustc-dev-guide#1931)
- Document that test names cannot contain dots (rust-lang/rustc-dev-guide#1927)
- Update overview.md (rust-lang/rustc-dev-guide#1898)
- actually need to fix two occurances (rust-lang/rustc-dev-guide#1925)
- fix broken links (rust-lang/rustc-dev-guide#1924)
- next-solver: document caching (rust-lang/rustc-dev-guide#1923)
- Add compiletest docs for FileCheck prefixes and `//@ filecheck-flags:` (rust-lang/rustc-dev-guide#1914)
- Use different type in an example (rust-lang/rustc-dev-guide#1908)
- Update run-make test description (rust-lang/rustc-dev-guide#1920)
- Add some more details on feature gating (rust-lang/rustc-dev-guide#1891)
- make shell.nix better (rust-lang/rustc-dev-guide#1858)
- opaque types in new solver (rust-lang/rustc-dev-guide#1918)
- add implied bounds doc (rust-lang/rustc-dev-guide#1915)
2024-03-12 06:29:04 +01:00
Matthias Krüger cd2efff518
Rollup merge of #122319 - compiler-errors:next-solver-normalizing-self-constrains-args, r=lcnr
Don't ICE when non-self part of trait goal is constrained in new solver

Self-explanatory. See test for example when this can happen.
2024-03-12 06:29:04 +01:00
Matthias Krüger 0b127d82f3
Rollup merge of #122194 - oli-obk:stash_delay_bug, r=nnethercote
Enable creating backtraces via -Ztreat-err-as-bug when stashing errors

r? `@nnethercote`

Otherwise I can't debug stashed errors because I can't find their source
2024-03-12 06:29:03 +01:00
Matthias Krüger 60f4b7a56e
Rollup merge of #122000 - erer1243:issue-121868, r=nikic
Fix 32-bit overflows in LLVM composite constants

Inspired by #121868. Fixes unsoundness created when constructing constant arrays, strings, and structs with 2^32 or more elements on x86_64. This introduces copies of a few LLVM functions that have their signatures updated to use size_t in place of unsigned int. Alternatively we could just add overflow checks and just disallow huge composite constants. That introduces less code, but maybe a huge static block of memory is useful in embedded/no-os situations?
2024-03-12 06:29:03 +01:00
Matthias Krüger b4cbc882eb
Rollup merge of #121865 - Kirandevraj:unnamed-fields-filecheck, r=oli-obk
Add FileCheck annotations to MIR-opt unnamed-fields tests

Part of #116971
Adds filecheck annotations to unnamed-fields mir-opt tests in `tests/mir-opt/unnamed-fields`
2024-03-12 06:29:02 +01:00
Matthias Krüger 60ab300d47
Rollup merge of #115141 - ChrisDenton:windows-support, r=wesleywiser
Update Windows platform support

This should not be merged until Rust 1.76 but I'm told this may need an fcp in addition to [MCP 651](https://github.com/rust-lang/compiler-team/issues/651).

cc ```@rust-lang/compiler``` ```@rust-lang/release```
2024-03-12 06:29:02 +01:00
bors 0fa7feaf3f Auto merge of #121282 - saethlin:gep-null-means-no-provenance, r=scottmcm
Lower transmutes from int to pointer type as gep on null

I thought of this while looking at https://github.com/rust-lang/rust/pull/121242. See that PR's description for why this lowering is preferable.

The UI test that's being changed here crashes without changing the transmutes into casts. Based on that, this PR should not be merged without a crater build-and-test run.
2024-03-12 04:11:37 +00:00
bors 5aad51d015 Auto merge of #112268 - lqd:osx-1cgu, r=Kobzol
Build `rustc` with 1CGU on `x86_64-apple-darwin`

Distribute `x86_64-apple-darwin` artifacts built with `rust.codegen-units=1`, like we already do on Linux.

1) effect on code size on `x86_64-apple-darwin`: it's a 11.14% reduction on `librustc_driver.dylib`
- before, [`41d97c8a5dea2731b0e56fe97cd7cb79e21cff79`](https://ci-artifacts.rust-lang.org/rustc-builds/41d97c8a5dea2731b0e56fe97cd7cb79e21cff79/rustc-nightly-x86_64-apple-darwin.tar.xz): 161232048
- after, [`7549dbdc09f0c4f6cc84002ac03081828054784b`](https://ci-artifacts.rust-lang.org/rustc-builds/7549dbdc09f0c4f6cc84002ac03081828054784b/rustc-nightly-x86_64-apple-darwin.tar.xz): 143256928

2) time it took on CI:
- the [first `try` build](https://github.com/rust-lang-ci/rust/actions/runs/8155512915/job/22291187124) took: 1h 33m
- the [second `try` build](https://github.com/rust-lang-ci/rust/actions/runs/8157057880/job/22295839911) took: 1h 45m

3) most recent perf results on (a noisy) x64 mac are [here](https://github.com/rust-lang/rust/pull/112268#issuecomment-1575635073).

Related tracking issue for build configuration: #103595
2024-03-12 02:02:32 +00:00
bors dc2ffa4054 Auto merge of #122036 - alexcrichton:test-wasm-with-wasi, r=oli-obk
Test wasm32-wasip1 in CI, not wasm32-unknown-unknown

This commit changes CI to no longer test the `wasm32-unknown-unknown` target and instead test the `wasm32-wasip1` target. There was some discussion of this in a [Zulip thread], and the motivations for this PR are:

* Runtime failures on `wasm32-unknown-unknown` print nothing, meaning all you get is "something failed". In contrast `wasm32-wasip1` can print to stdout/stderr.

* The unknown-unknown target is missing lots of pieces of libstd, and while `wasm32-wasip1` is also missing some pieces (e.g. threads) it's missing fewer pieces. This means that many more tests can be run.

Overall my hope is to improve the debuggability of wasm failures on CI and ideally be a bit less of a maintenance burden.

This commit specifically removes the testing of `wasm32-unknown-unknown` and replaces it with testing of `wasm32-wasip1`. Along the way there were a number of other archiectural changes made as well, including:

* A new `target.*.runtool` option can now be specified in `config.toml` which is passed as `--runtool` to `compiletest`. This is used to reimplement execution of WebAssembly in a less-wasm-specific fashion.

* The default value for `runtool` is an ambiently located WebAssembly runtime found on the system, if any. I've implemented logic for Wasmtime.

* Existing testing support for `wasm32-unknown-unknown` and Emscripten has been removed. I'm not aware of Emscripten testing being run any time recently and otherwise `wasm32-wasip1` is in theory the focus now.

* I've added a new `//@ needs-threads` directive for `compiletest` and classified a bunch of wasm-ignored tests as needing threads. In theory these tests can run on `wasm32-wasi-preview1-threads`, for example.

* I've tried to audit all existing tests that are either `ignore-emscripten` or `ignore-wasm*`. Many now run on `wasm32-wasip1` due to being able to emit error messages, for example. Many are updated with comments as to why they can't run as well.

* The `compiletest` output matching for `wasm32-wasip1` automatically uses "match a subset" mode implemented in `compiletest`. This is because WebAssembly runtimes often add extra information on failure, such as the `unreachable` instruction in `panic!`, which isn't able to be matched against the golden output from native platforms.

* I've ported most existing `run-make` tests that use custom Node.js wrapper scripts to the new run-make-based-in-Rust infrastructure. To do this I added `wasmparser` as a dependency of `run-make-support` for the various wasm tests to use that parse wasm files. The one test that executed WebAssembly now uses `wasmtime`-the-CLI to execute the test instead. I have not ported over an exception-handling test as Wasmtime doesn't implement this yet.

* I've updated the `test` crate to print out timing information for WASI targets as it can do that (gets a previously ignored test now passing).

* The `test-various` image now builds a WASI sysroot for the WASI target and additionally downloads a fixed release of Wasmtime, currently the latest one at 18.0.2, and uses that for testing.

[Zulip thread]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Have.20wasm.20tests.20ever.20caused.20problems.20on.20CI.3F/near/424317944
2024-03-12 00:03:54 +00:00
Ben Kimock 2eb9c6d49e Lower transmutes from int to pointer type as gep on null 2024-03-11 18:19:17 -04:00
bors 4a0cc881dc Auto merge of #112267 - lqd:win-1cgu, r=Kobzol
Build `rustc` with 1CGU on `x86_64-pc-windows-msvc`

Distribute `x86_64-pc-windows-msvc` artifacts built with `rust.codegen-units=1`, like we already do on Linux.

1) effect on code size on `x86_64-pc-windows-msvc`: it's a 3.67% reduction on `rustc_driver.dll`
- before, [`41d97c8a5dea2731b0e56fe97cd7cb79e21cff79`](https://ci-artifacts.rust-lang.org/rustc-builds/41d97c8a5dea2731b0e56fe97cd7cb79e21cff79/rustc-nightly-x86_64-pc-windows-msvc.tar.xz): 137605632
- after, [`704aaa875e4acccc973cbe4579e66afbac425691`](https://ci-artifacts.rust-lang.org/rustc-builds/704aaa875e4acccc973cbe4579e66afbac425691/rustc-nightly-x86_64-pc-windows-msvc.tar.xz): 132551680

2) time it took on CI
- the [first `try` build](https://github.com/rust-lang-ci/rust/actions/runs/8155647651/job/22291592507) took: 1h 31m
- the [second `try` build](https://github.com/rust-lang-ci/rust/actions/runs/8157043594/job/22295790552) took: 1h 32m

3) most recent perf results:
- on a slightly noisy desktop [here](https://github.com/rust-lang/rust/pull/112267#issuecomment-1575758155)
- ChrisDenton's results [here](https://github.com/rust-lang/rust/pull/112267#issuecomment-1583295338)

Related tracking issue for build configuration: #103595
2024-03-11 21:40:34 +00:00
kirandevraj ba70528fd8 updating variable names in CHECK 2024-03-12 01:51:52 +05:30
Michael Goulet f614eaea2c Remove some unnecessary allow(incomplete_features) 2024-03-11 19:42:04 +00:00
Michael Goulet 0b6b3307fc Move project -> normalize, move normalize tests 2024-03-11 19:16:39 +00:00
Michael Goulet 2a1d4dd6e3 Don't ICE when non-self part of trait goal is constrained in new solver 2024-03-11 19:16:39 +00:00
bors 4ccbb7dc95 Auto merge of #121796 - oli-obk:eager_opaque_checks3, r=lcnr
Make `DefiningAnchor::Bind` only store the opaque types that may be constrained, instead of the current infcx root item.

This makes `Bind` almost always be empty, so we can start forwarding it to queries, allowing us to remove `Bubble` entirely (not done in this PR)

The only behaviour change is in diagnostics.

r? `@lcnr` `@compiler-errors`
2024-03-11 19:01:15 +00:00
Chris Denton aeec0d1269
Update /NODEFAUTLIB comment for msvc 2024-03-11 18:31:50 +00:00
Chris Denton 779ac6951f
Update Windows platform support 2024-03-11 17:50:33 +00:00
lcnr b0328c20ce update comment for RPITIT projections 2024-03-11 17:19:37 +00:00
Oli Scherer 7348dd1950 Eliminate DefiningAnchor::Error, it is indistinguishable from DefiningAnchor::Bind with an empty list 2024-03-11 17:19:37 +00:00
Oli Scherer 40d5609548 Make DefiningAnchor::Bind only store the opaque types that may be constrained, instead of the current infcx root item.
This makes `Bind` almost always be empty, so we can start forwarding it to queries, allowing us to remove `Bubble` entirely
2024-03-11 17:19:37 +00:00
rustbot b66d7f5827 Update books 2024-03-11 13:00:45 -04:00
bors 6554a5645a Auto merge of #122338 - workingjubilee:rollup-xzpt4v4, r=workingjubilee
Rollup of 15 pull requests

Successful merges:

 - #116791 (Allow codegen backends to opt-out of parallel codegen)
 - #116793 (Allow targets to override default codegen backend)
 - #117458 (LLVM Bitcode Linker: A self contained linker for nvptx and other targets)
 - #119385 (Fix type resolution of associated const equality bounds (take 2))
 - #121438 (std support for wasm32 panic=unwind)
 - #121893 (Add tests (and a bit of cleanup) for interior mut handling in promotion and const-checking)
 - #122080 (Clarity improvements to `DropTree`)
 - #122152 (Improve diagnostics for parenthesized type arguments)
 - #122166 (Remove the unused `field_remapping` field from `TypeLowering`)
 - #122249 (interpret: do not call machine read hooks during validation)
 - #122299 (Store backtrace for `must_produce_diag`)
 - #122318 (Revision-related tweaks for next-solver tests)
 - #122320 (Use ptradd for vtable indexing)
 - #122328 (unix_sigpipe: Replace `inherit` with `sig_dfl` in syntax tests)
 - #122330 (bootstrap readme: fix, improve, update)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-11 16:51:54 +00:00
Alex Crichton cf6d6050f7 Update test directives for wasm32-wasip1
* The WASI targets deal with the `main` symbol a bit differently than
  native so some `codegen` and `assembly` tests have been ignored.
* All `ignore-emscripten` directives have been updated to
  `ignore-wasm32` to be more clear that all wasm targets are ignored and
  it's not just Emscripten.
* Most `ignore-wasm32-bare` directives are now gone.
* Some ignore directives for wasm were switched to `needs-unwind`
  instead.
* Many `ignore-wasm32*` directives are removed as the tests work with
  WASI as opposed to `wasm32-unknown-unknown`.
2024-03-11 09:36:35 -07:00
Alex Crichton 4a5aa1a104 compiletest: Automatically compare output by subset with runners
This commit updates compiletest to automatically compare test output
with subsets if a `--runner` argument is configured. Runners might
inject extra information on failures, for example a WebAssembly runtime
printing a wasm stack trace, which won't be in the output of a native
runtime. The output with a `--runner` argument, however, should still
have all the native output present.
2024-03-11 09:36:35 -07:00
Alex Crichton fc746c8118 Update test-various docker image to test wasm32-wasip1
Drop testing of `wasm32-unknown-unknown` and instead only test a WASI
target which enables more debugging utilities such as printing.
2024-03-11 09:36:35 -07:00
Alex Crichton 341215c51d Configure a default runner for WASI targets
If one is not explicitly configured look in the system environment to
try and find one. For now just probing for `wasmtime` is implemented.
2024-03-11 09:36:35 -07:00
Alex Crichton 7d9690a3bc Remove old support for emscripten/wasm32-u-u
This commit removes the `wasm32-shim.js` file, for example, and deletes
old support for Emscripten which hasn't been exercised in some time.
2024-03-11 09:36:35 -07:00
Alex Crichton 8fcc009f7d libtest: Print timing information on WASI
This commit updates the libtest conditionals to use `std::time::Instant`
on WASI targets where it's implemented. Previously all wasm targets
wouldn't use this type.
2024-03-11 09:36:35 -07: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
Jubilee 7fa6fa4a1f
Rollup merge of #122330 - tshepang:patch-1, r=clubby789
bootstrap readme: fix, improve, update
2024-03-11 09:29:39 -07:00
Jubilee 9aca5c03c1
Rollup merge of #122328 - Enselic:sig_dfl-not-inherit, r=davidtwco
unix_sigpipe: Replace `inherit` with `sig_dfl` in syntax tests

The `sig_dfl` variant of the attribute is the most likely variant to be stabilized first, and thus to become the "most allowed" variant of the attribute. Because of this, it is the most appropriate variant to use in syntax tests, because even if the most allowed variant is used, the compiler shall still emit errors if it e.g. is used in the wrong places.

r? ``@davidtwco`` who already [approved ](https://github.com/rust-lang/rust/pull/120832#pullrequestreview-1875075341) this commit in https://github.com/rust-lang/rust/pull/120832.

It would be nice to land the last preparatory commit of that PR before we begin to [rename ](https://github.com/rust-lang/rust/pull/120832#issuecomment-1987023484) things which will of course create a lot of code conflicts.
2024-03-11 09:29:38 -07:00
Jubilee 028e2600c9
Rollup merge of #122320 - erikdesjardins:vtable, r=nikic
Use ptradd for vtable indexing

Extension of #121665.

After this, the only remaining usages of GEP are [this](cd81f5b27e/compiler/rustc_codegen_llvm/src/intrinsic.rs (L909-L920)) kinda janky Emscription EH code, which I'll change in a future PR, and array indexing / pointer offsets, where there isn't yet a canonical `ptradd` form. (Out of curiosity I tried converting the latter to `ptradd(ptr, mul(size, index))`, but that causes codegen regressions right now.)

r? `@nikic`
2024-03-11 09:29:38 -07:00
Jubilee a11e6c38b5
Rollup merge of #122318 - compiler-errors:next-solver-tests, r=lcnr
Revision-related tweaks for next-solver tests

1. Add `ignore-compare-mode-next-solver` to any test that already has explicit `current next` revisions, since the test failures when testing with `--compare-mode=next-solver` will be false positives.
2. Explicitly add revisions to a handful of tests where we expect behavior to diverge.

r? lcnr
2024-03-11 09:29:37 -07:00
Jubilee 671fc18ba2
Rollup merge of #122299 - compiler-errors:bt-for-must-diag, r=nnethercote
Store backtrace for `must_produce_diag`

This makes it significantly easier to debug a `must_produce_diag` ICE, since we have no other way to know where the heck the bug originates from.

Backtrace rendering kinda sucks right now since we're just printing it in the panic message; happy to apply some suggestions to make it prettier or reuse other bug printing machinery, but also don't want to iterate too much on the rendering since this really is just for debug purposes.

r? nnethercote
2024-03-11 09:29:37 -07:00
Jubilee f6ca4258d2
Rollup merge of #122249 - RalfJung:machine-read-hook, r=oli-obk
interpret: do not call machine read hooks during validation

Fixes https://github.com/rust-lang/miri/issues/3347

r? ``@oli-obk``
2024-03-11 09:29:36 -07:00
Jubilee afa058179d
Rollup merge of #122166 - beetrees:remove-field-remapping, r=davidtwco
Remove the unused `field_remapping` field from `TypeLowering`

The `field_remapping` field of `TypeLowering` has  been unused since #121665. This PR removes it, then replaces the `TypeLowering` struct with its only remaining member `&'ll Type`.
2024-03-11 09:29:36 -07:00
Jubilee 05ff86c389
Rollup merge of #122152 - wutchzone:120892, r=fmease
Improve diagnostics for parenthesized type arguments

Fixes #120892

r? fmease
2024-03-11 09:29:35 -07:00
Jubilee e3f9b2f27c
Rollup merge of #122080 - Zalathar:drop-tree, r=oli-obk
Clarity improvements to `DropTree`

These changes are based on some points of confusion I had when initially trying to understand this code.

The only “functional” change is an additional assertion in `<ExitScopes as DropTreeBuilder>::link_entry_point`, checking that the dummy terminator is `TerminatorKind::UnwindResume` as expected.
2024-03-11 09:29:35 -07:00
Jubilee 9300fbbed1
Rollup merge of #121893 - RalfJung:const-interior-mut-tests, r=oli-obk
Add tests (and a bit of cleanup) for interior mut handling in promotion and const-checking

Basically these are the parts of https://github.com/rust-lang/rust/pull/121786 that can be salvaged.

r? ``@oli-obk``
2024-03-11 09:29:34 -07:00
Jubilee 1279830068
Rollup merge of #121438 - coolreader18:wasm32-panic-unwind, r=cuviper
std support for wasm32 panic=unwind

Tracking issue: #118168

This adds std support for `-Cpanic=unwind` on wasm, and with it slightly more fleshed out rustc support. Now, the stable default is still panic=abort without exception-handling, but if you `-Zbuild-std` with `RUSTFLAGS=-Cpanic=unwind`, you get wasm exception-handling try/catch blocks in the binary:

```rust
#[no_mangle]
pub fn foo_bar(x: bool) -> *mut u8 {
    let s = Box::<str>::from("hello");
    maybe_panic(x);
    Box::into_raw(s).cast()
}

#[inline(never)]
#[no_mangle]
fn maybe_panic(x: bool) {
    if x {
        panic!("AAAAA");
    }
}
```
```wat
;; snip...
(try $label$5
 (do
  (call $maybe_panic
   (local.get $0)
  )
  (br $label$1)
 )
 (catch_all
  (global.set $__stack_pointer
   (local.get $1)
  )
  (call $__rust_dealloc
   (local.get $2)
   (i32.const 5)
   (i32.const 1)
  )
  (rethrow $label$5)
 )
)
;; snip...
```
2024-03-11 09:29:34 -07:00
Jubilee a4503390ba
Rollup merge of #119385 - fmease:assoc-const-eq-fixes-2, r=oli-obk,cjgillot
Fix type resolution of associated const equality bounds (take 2)

Instead of trying to re-resolve the type of assoc const bindings inside the `type_of` query impl in an incomplete manner, transfer the already (correctly) resolved type from `add_predicates_for_ast_type_binding` to `type_of`/`anon_type_of` through query feeding.

---

Together with #118668 (merged) and #121258, this supersedes #118360.
Fixes #118040.

r? ``@ghost``
2024-03-11 09:29:33 -07:00
Jubilee e1ceadcdfe
Rollup merge of #117458 - kjetilkjeka:embedded-linker, r=petrochenkov
LLVM Bitcode Linker: A self contained linker for nvptx and other targets

This PR introduces a new linker named `llvm-bitcode-linker`. It is a `self-contained` linker that can be used to link programs in `llbc` before optimizing and compiling to native code. It will first be used internally in the Rust compiler to enable tests for the `nvptx64-nvidia-cuda` target as the original `rust-ptx-linker` is deprecated. It will then be provided to users of the `nvptx64-nvidia-cuda` target with the purpose of linking ptx. More targets than nvptx will also be supported eventually.

The PR introduces a new unstable `LinkerFlavor` for the compiler. The compiler will also not be shipped with rustc but most likely instead be shipped in it's own unstable component (a follow up PR will be opened for this). This means that merging this PR should not add any stability guarantees.

When more details of `self-contained` is implemented it will only be possible to use the linker when `-Clink-self-contained=+linker` is passed.

<details>
  <summary>Original Description</summary>

**When this PR was created it was focused a bit differently. The original text is preserved here in case there's some interests in it**

I have experimenting with approaches to replace the ptx-linker and enable the nvptx target tests again. I think it's time to get some feedback on the approach.

### The problem
The only useful linker for the nvptx target is [this crate](https://github.com/denzp/rust-ptx-linker). Since this linker performs linking on llvm bitcode it needs to track the llvm version of rustc and use the same format. It has not been maintained for 3+ years and must be considered abandoned. Over the years rust have upgraded LLVM while the linker has been left to bitrot. It is no longer in a usable state.

Due to the difficulty of keeping the ptx-linker up to date outside of tree the nvptx tests was [disabled a long time ago](f8f9a2869c). It was [previously discussed](https://github.com/rust-lang/rust/pull/96842#issuecomment-1146470177) if adding the ptx-linker to the rust repo would be a possibility. My efforts in doing this stopped at getting an answered if the license would prohibit it from inclusion in the [Rust repo](https://github.com/rust-lang/rust/pull/96842#issuecomment-1148397554). I therefore concluded that a re-write would be necessary.

### The possible solution presented here
The llvm tools know perfectly well how to link and optimize llvm bitcode. Each of them only perform a single task, and are therefore a bit cumbersome to call with the current linker approach rustc takes.

This PR adds a simple tool (current name `embedded-linker`) which can link self contained (often embedded) programs in llvm bitcode before compiling to the target format. Optimization will also be performed if lto is enabled. The rust compiler will make a single invocation to this tool, while the tool will orchestrate the many calls to the llvm tools.

### The questions
 - Is having control over the nvptx linking and therefore also tests worth it to add such tool? or should the tool live outside the rust repo?
 - Is the approach of calling llvm tools acceptable? Or would we want to keep the ptx-linker approach of using the llvm library? The tools seems to provide more simplicity and stability, but more intermediate files are being written. Perhaps there also are some performance penalty for the calling tools approach.
 - What is the process for adding such tool? MCP?
 - Does adding `llvm-link` to the llvm-tool component require any process?
 - Does it require some sort of FCP to remove ptx-linker as the default linker for ptx? Or is it sufficient that using the upstream ptx-linker is broken in its current state. it is possible to use a somewhat patched version of ptx-linker.
</details>
2024-03-11 09:29:32 -07:00
Jubilee 86af4d25a5
Rollup merge of #116793 - WaffleLapkin:target_rules_the_backend, r=cjgillot
Allow targets to override default codegen backend

Implements https://github.com/rust-lang/compiler-team/issues/670.
2024-03-11 09:29:32 -07:00
Jubilee 88d387b263
Rollup merge of #116791 - WaffleLapkin:unparallel-backends, r=oli-obk
Allow codegen backends to opt-out of parallel codegen

This makes it a bit easier to write cursed codegen backends.
2024-03-11 09:29:31 -07:00
bors 65cd843ae0 Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco
Run a single huge par_body_owners instead of many small ones after each other.

This improves parallel rustc parallelism by avoiding the bottleneck after each individual `par_body_owners` (because it needs to wait for queries to finish, so if there is one long running one, a lot of cores will be idle while waiting for the single query).
2024-03-11 14:26:09 +00:00
Ralf Jung fb802f2e6e promote-not: add test that distinguishes promotion from outer scope rule 2024-03-11 14:17:34 +01:00