Commit Graph

287 Commits

Author SHA1 Message Date
Matthias Krüger 732ad59779
Rollup merge of #129988 - arnaudgolfouse:modify-locale_resources, r=davidtwco
Use `Vec` in `rustc_interface::Config::locale_resources`

This allows a third-party tool to injects its own resources, when receiving the config via `rustc_driver::Callbacks::config`.
2024-09-17 17:28:32 +02:00
Matthias Krüger fe3428d9ac
Rollup merge of #128961 - GKFX:issue-128930-explain-missing-option, r=jieyouxu
Fix #128930: Print documentation of CLI options missing their arg

Fix #128930. Failing to give an argument to CLI options which require it now prints something like:
```
$ rustc --print
error: Argument to option 'print' missing
       Usage:
           --print [crate-name|file-names|sysroot|target-libdir|cfg|check-cfg|calling-conventions|target-list|target-cpus|target-features|relocation-models|code-models|tls-models|target-spec-json|all-target-specs-json|native-static-libs|stack-protector-strategies|link-args|deployment-target]
                               Compiler information to print on stdout
```
2024-09-17 17:28:31 +02:00
Nicholas Nethercote 072bf482c9 Remove unnecessary lifetime from `RunCompiler`.
This does change the external interface, but not in a way that will
cause any breakage because external users don't mention the lifetimes.
2024-09-13 15:36:55 +10:00
Michael Goulet 954419aab0 Simplify some nested if statements 2024-09-11 13:45:23 -04:00
bors 12b26c13fb Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68
Bump boostrap compiler to new beta

Accidentally left some comments on the update cfgs commit directly xd
2024-09-07 20:37:30 +00:00
bors 9afe713695 Auto merge of #129341 - madsmtm:refactor-deployment-target, r=petrochenkov
Apple: Refactor deployment target version parsing

Refactor deployment target parsing to make it easier to do https://github.com/rust-lang/rust/pull/129342 (I wanted to make sure of all the places that `std::env::var` is called).

Specifically, my goal was to minimize the amount of target-specific configuration, so to that end I renamed the `opts` function that generates the `TargetOptions` to `base`, and made it return the LLVM target and `target_arch` too. In the future, I would like to move even more out of the target files and into `spec::apple`, as it makes it easier for me to maintain.

For example, this fixed a bug in `aarch64-apple-watchos`, which wasn't passing the deployment target as part of the LLVM triple. This (probably) fixes https://github.com/rust-lang/rust/issues/123582 and fixes https://github.com/rust-lang/rust/issues/107630.

We also now parse the patch version of deployment targets, allowing the user to specify e.g. `MACOSX_DEPLOYMENT_TARGET=10.12.6`.

Finally, this fixes the LLVM target name for visionOS, it should be `*-apple-xros` and not `*-apple-visionos`.

Since I have changed all the Apple targets here, I smoke-tested my changes by running the following:
```console
# Build each target
./x build library --target="aarch64-apple-darwin,aarch64-apple-ios,aarch64-apple-ios-macabi,aarch64-apple-ios-sim,aarch64-apple-tvos,aarch64-apple-tvos-sim,aarch64-apple-visionos,aarch64-apple-visionos-sim,aarch64-apple-watchos,aarch64-apple-watchos-sim,arm64_32-apple-watchos,arm64e-apple-ios,armv7k-apple-watchos,armv7s-apple-ios,i386-apple-ios,x86_64-apple-darwin,x86_64-apple-ios,x86_64-apple-ios-macabi,x86_64-apple-tvos,x86_64-apple-watchos-sim,x86_64h-apple-darwin"

# Test that we can still at least link basic projects
cargo new foobar && cd foobar && cargo +stage1 build --target=aarch64-apple-darwin --target=aarch64-apple-ios --target=aarch64-apple-ios-macabi --target=aarch64-apple-ios-sim --target=aarch64-apple-tvos --target=aarch64-apple-tvos-sim --target=aarch64-apple-visionos --target=aarch64-apple-visionos-sim --target=aarch64-apple-watchos --target=aarch64-apple-watchos-sim --target=arm64_32-apple-watchos --target=armv7s-apple-ios --target=i386-apple-ios --target=x86_64-apple-darwin --target=x86_64-apple-ios --target=x86_64-apple-ios-macabi --target=x86_64-apple-tvos --target=x86_64-apple-watchos-sim --target=x86_64h-apple-darwin
```

I couldn't build for the `arm64e-apple-darwin` target, the `armv7k-apple-watchos` and `arm64e-apple-ios` targets failed to link, and I know that the `i686-apple-darwin` target requires a bit of setup, but all of this is as it was before this PR.

r? thomcc

CC `@BlackHoleFox`

I would recommend using `rollup=never` when merging this, in case we need to bisect this later.
2024-09-07 01:37:52 +00:00
Boxy 0091b8ab2a update cfgs 2024-09-05 17:24:01 +01:00
arnaudgolfouse 13d56dc160 Use a `Vec` in `rustc_interface::Config::locale_resources`
This allows a third-party tool to injects its own resources,
when receiving the config via `rustc_driver::Callbacks::config`.
2024-09-05 16:49:38 +02:00
Mads Marquart 5b51331abe Apple: Refactor deployment target version parsing
- Merge minimum OS version list into one function (makes it easier to
  see the logic in it).
- Parse patch deployment target versions.
- Consistently specify deployment target in LLVM target (previously
  omitted on `aarch64-apple-watchos`).
2024-09-05 06:47:13 +02:00
Matthias Krüger 8a60d0a5ec
Rollup merge of #101339 - the8472:ci-randomize-debug, r=Mark-Simulacrum
enable -Zrandomize-layout in debug CI builds

This builds rustc/libs/tools with `-Zrandomize-layout` on *-debug CI runners.

Only a handful of tests and asserts break with that enabled, which is promising. One test was fixable, the rest is dealt with by disabling them through new cargo features or compiletest directives.

The config.toml flag `rust.randomize-layout` defaults to false, so it has to be explicitly enabled for now.
2024-09-05 03:47:39 +02:00
Ralf Jung aa1f60ecff rustc_driver_impl: remove some old dead logic 2024-09-03 09:42:37 +02:00
The 8472 5bf8eeb9f3 disable size asserts in the compiler when randomizing layouts 2024-08-31 23:56:45 +02:00
Matthias Krüger 472c9645fb
Rollup merge of #129667 - dev-ardi:rustc_driver-cleanup, r=michaelwoerister
Rustc driver cleanup

This adds a few comments to the driver to clarify a bit what's happening and does some cleanup.
2024-08-28 17:12:19 +02:00
Orion Gonzalez a007d349a1 clarify a few things 2024-08-28 13:11:02 +02:00
Orion Gonzalez b218623ea0 cleanup make_input 2024-08-28 13:03:18 +02:00
Orion Gonzalez ddcb073c53 replace is_some() -> unwrap with if let 2024-08-28 13:03:15 +02:00
Matthias Krüger 489eb230dd
Rollup merge of #129648 - nnethercote:unreachable_pub-2, r=Urgau
More `unreachable_pub`

Add `unreachable_pub` checking to some more compiler crates. A follow-up to #126013.

r? ``@Urgau``
2024-08-27 18:59:29 +02:00
Nicholas Nethercote e81fad2b4d Add `warn(unreachable_pub)` to `rustc_driver_impl`. 2024-08-27 11:47:25 +10:00
Michael Goulet 38e62b9841 Use unsafe extern blocks throughout the compiler 2024-08-26 19:51:05 -04:00
George Bateman 6360287fd9
Fix #128930: Print documentation of CLI options missing their arg 2024-08-11 09:10:30 +01:00
Matthias Krüger 32e0fe129d
Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errors
Use more slice patterns inside the compiler

Nothing super noteworthy. Just replacing the common 'fragile' pattern of "length check followed by indexing or unwrap" with slice patterns for legibility and 'robustness'.

r? ghost
2024-08-11 07:51:51 +02:00
Jane Losare-Lusby 5212c75907 Add -Zerror-metrics=PATH to save diagnostic metadata to disk 2024-08-07 11:16:55 -07:00
León Orell Valerian Liehr c4c518d2d4
Use more slice patterns inside the compiler 2024-08-07 13:37:52 +02:00
Oli Scherer 92f263b792 Make RUSTC_OVERRIDE_VERSION_STRING overwrite the rendered version output, too 2024-07-30 14:08:02 +00:00
Nicholas Nethercote 84ac80f192 Reformat `use` declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
bjorn3 bd2ff518ce Move codegen_and_build_linker from Queries to Linker 2024-07-01 11:00:49 +00:00
bjorn3 8127461b0e Move -Zprint-type-sizes and -Zprint-vtable-sizes into codegen_and_build_linker 2024-06-30 18:01:55 +00:00
bors c2d2bb38c9 Auto merge of #126834 - bjorn3:interface_refactor, r=michaelwoerister
Various refactorings to rustc_interface

This should make it easier to move the driver interface away from queries in the future. Many custom drivers call queries like `queries.global_ctxt()` before they are supposed to be called, breaking some things like certain `--print` and `-Zunpretty` options, `-Zparse-only` and emitting the dep info at the wrong point in time. They are also not actually necessary at all. Passing around the query output manually would avoid recomputation too and would be just as easy. Removing driver queries would also reduce the amount of global mutable state of the compiler. I'm not removing driver queries in this PR to avoid breaking the aforementioned custom drivers.
2024-06-25 09:35:53 +00:00
Michael Goulet faa28be2f1
Rollup merge of #124712 - Enselic:deprecate-inline-threshold, r=pnkfelix
Deprecate no-op codegen option `-Cinline-threshold=...`

This deprecates `-Cinline-threshold` since using it has no effect. This has been the case since the new LLVM pass manager started being used, more than 2 years ago.

Recommend using `-Cllvm-args=--inline-threshold=...` instead.

Closes #89742 which is E-help-wanted.
2024-06-24 15:51:00 -04:00
bjorn3 8d1f5b30ef Avoid a couple of unnecessary EarlyDiagCtxt uses 2024-06-22 17:06:47 +00:00
bjorn3 7332e79d5f Inline write_dep_info query 2024-06-22 17:06:47 +00:00
Oli Scherer 7ba82d61eb Use a dedicated type instead of a reference for the diagnostic context
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-18 15:42:11 +00:00
Martin Nordholts f5f067bf9d Deprecate no-op codegen option `-Cinline-threshold=...`
This deprecates `-Cinline-threshold` since using it has no effect. This
has been the case since the new LLVM pass manager started being used,
more than 2 years ago.
2024-06-14 20:25:17 +02:00
Martin Nordholts 651ff643ae Fix typo in `-Cno-stack-check` deprecation warning
The flag `--no-stack-check` does not exist:

    $ rustc --no-stack-check
    error: Unrecognized option: 'no-stack-check'. Did you mean `-C no-stack-check`?
2024-06-14 20:21:05 +02:00
Nicholas Nethercote 75b164d836 Use `tidy` to sort crate attributes for all compiler crates.
We already do this for a number of crates, e.g. `rustc_middle`,
`rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`.

For the ones we don't, in many cases the attributes are a mess.
- There is no consistency about order of attribute kinds (e.g.
  `allow`/`deny`/`feature`).
- Within attribute kind groups (e.g. the `feature` attributes),
  sometimes the order is alphabetical, and sometimes there is no
  particular order.
- Sometimes the attributes of a particular kind aren't even grouped
  all together, e.g. there might be a `feature`, then an `allow`, then
  another `feature`.

This commit extends the existing sorting to all compiler crates,
increasing consistency. If any new attribute line is added there is now
only one place it can go -- no need for arbitrary decisions.

Exceptions:
- `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`,
  because they have no crate attributes.
- `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's
  ignored in `rustfmt.toml`).
2024-06-12 15:49:10 +10:00
Mara Bos 64e56db72a Rename std::panic::PanicInfo to PanicHookInfo. 2024-06-11 15:47:00 +02:00
Nicholas Nethercote 29629d0075 Remove some unused crate dependencies.
I found these by setting the `unused_crate_dependencies` lint
temporarily to `Warn`.
2024-06-10 19:55:49 +10:00
Nicholas Nethercote b9037339cb Make top-level `rustc_parse` functions fallible.
Currently we have an awkward mix of fallible and infallible functions:
```
       new_parser_from_source_str
 maybe_new_parser_from_source_str
       new_parser_from_file
(maybe_new_parser_from_file)        // missing
      (new_parser_from_source_file) // missing
 maybe_new_parser_from_source_file
       source_str_to_stream
 maybe_source_file_to_stream
```
We could add the two missing functions, but instead this commit removes
of all the infallible ones and renames the fallible ones leaving us with
these which are all fallible:
```
new_parser_from_source_str
new_parser_from_file
new_parser_from_source_file
source_str_to_stream
source_file_to_stream
```
This requires making `unwrap_or_emit_fatal` public so callers of
formerly infallible functions can still work.

This does make some of the call sites slightly more verbose, but I think
it's worth it for the simpler API. Also, there are two `catch_unwind`
calls and one `catch_fatal_errors` call in this diff that become
removable thanks this change. (I will do that in a follow-up PR.)
2024-06-05 10:38:03 +10:00
Nicholas Nethercote 25972aec67 Inline and remove `parse_crate{,_attrs}_from_{file,source_str}`.
All four functions are simple and have a single call site.

This requires making `Parser::parse_inner_attributes` public, which is
no big deal.
2024-06-05 10:38:02 +10:00
Michael Goulet 23f39a21db
Rollup merge of #125953 - nnethercote:streamline-nested-calls, r=lqd
Streamline `nested` calls.

`TyCtxt` impls `PpAnn` in `compiler/rustc_middle/src/hir/map/mod.rs`. We can call that impl, which then calls the one on `intravisit::Map`, instead of calling the one on `intravisit::Map` directly, avoiding a cast and extra references.

r? `@lqd`
2024-06-04 08:52:14 -04:00
Nicholas Nethercote 4798c20d31 Streamline `nested` calls.
`TyCtxt` impls `PpAnn` in `compiler/rustc_middle/src/hir/map/mod.rs`. We
can call that impl, which then calls the one on `intravisit::Map`,
instead of calling the one on `intravisit::Map` directly, avoiding a
cast and extra references.
2024-06-04 15:08:08 +10:00
Urgau 5f0043ace6 Handle no values cfg with --print=check-cfg 2024-06-02 11:49:28 +02:00
Oli Scherer a34c26e7ec Make `body_owned_by` return the body directly.
Almost all callers want this anyway, and now we can use it to also return fed bodies
2024-05-29 10:04:08 +00:00
许杰友 Jieyou Xu (Joe) 7e441a11a1
Rollup merge of #124320 - Urgau:print-check-cfg, r=petrochenkov
Add `--print=check-cfg` to get the expected configs

This PR adds a new `--print` variant `check-cfg` to get the expected configs.

Details and rational can be found on the MCP: https://github.com/rust-lang/compiler-team/issues/743

``@rustbot`` label +F-check-cfg +S-waiting-on-MCP
r? ``@petrochenkov``
2024-05-29 03:25:07 +01:00
Ben Kimock f1a18da4bb Exit the process a short time after entering our ctrl-c handler 2024-05-24 17:43:02 -04:00
Ben Kimock c3a606237d PR feedback 2024-05-21 20:12:30 -04:00
Ben Kimock 95150d7246 Add a footer in FileEncoder and check for it in MemDecoder 2024-05-21 20:12:29 -04:00
Tobias Bucher b98b8d76b1 Don't call `env::set_var` in `rustc_driver::install_ice_hook`
Modifying an environment variable would make the function unsafe to
call.
2024-05-13 09:37:29 +02:00
Caleb Sander 43c8e139fd compiler: upgrade time from 0.3.34 to 0.3.36
This ensures the version of time used in rustc includes this change:
https://github.com/time-rs/time/pull/671.
This fix is a necessary prerequisite for #99969,
which adds FromIterator implementations for Box<str>.
Previously, time had an Into::into that resolved to the identity impl
followed by a collect::<Result<Box<_>, _>>().
With the new FromIterator implementations for Box<str>,
the Into::into resolution is ambiguous and time fails to compile.
The fix removes the identity Into::into conversion,
allowing time to compile with the new FromIterator implementations.
This version of time also matches what cargo recently switched to
in https://github.com/rust-lang/cargo/pull/13834.
2024-05-04 21:18:41 -07:00
Nicholas Nethercote a503893567 Fix `Cargo.toml` whitespace. 2024-05-03 16:03:17 +10:00