Commit Graph

301 Commits

Author SHA1 Message Date
Zalathar
584c8200de Use a method to apply RustcOptGroup to getopts::Options 2024-11-08 12:46:39 +11:00
klensy
bc1d8e72e7 make time format parsing compiletime 2024-11-03 15:51:39 +03:00
Noratrieb
ba481518da Add --print host-triple
People often parse `-vV` output to get to the host triple, which is
annoying to do. It's easier to just get it directly.
2024-11-02 21:29:59 +01:00
Noratrieb
a26450cf81 Rename target triple to target tuple in many places in the compiler
This changes the naming to the new naming, used by `--print
target-tuple`.
It does not change all locations, but many.
2024-11-02 21:29:59 +01:00
Mads Marquart
1ef1af1c60 Emit diagnostics for incorrect deployment targets 2024-11-01 17:07:19 +01:00
Mads Marquart
e1233153ac Move versioned LLVM target creation to rustc_codegen_ssa
The OS version depends on the deployment target environment variables,
the access of which we want to move to later in the compilation pipeline
that has access to more information, for example `env_depinfo`.
2024-11-01 17:07:18 +01:00
klensy
746b675c5a fix clippy::clone_on_ref_ptr for compiler 2024-10-28 18:05:08 +03:00
Jubilee
31fbf67ce3
Rollup merge of #130899 - bjorn3:wasi_bootstrap_fixes, r=davidtwco
Couple of changes to make it easier to compile rustc for wasm

This is a subset of the patches I have on my rust fork to compile rustc for wasm32-wasip1.
2024-10-07 11:10:53 -07:00
mu001999
aa75b5f686 Update out-dated link 2024-10-06 18:08:28 +08:00
bjorn3
bf1f5c902b
Avoid unused import warning for the Ctrl-C handler on wasm 2024-10-04 12:25:48 +02:00
klensy
26c09b6553 bump few deps
cargo_metadata, thorin-dwp, windows
2024-09-27 09:23:05 +03:00
Michael Goulet
c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
bors
5ba6db1b64 Auto merge of #124895 - obeis:static-mut-hidden-ref, r=compiler-errors
Disallow hidden references to mutable static

Closes #123060

Tracking:
- https://github.com/rust-lang/rust/issues/123758
2024-09-20 17:25:34 +00:00
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
Obei Sideg
74cab947f7
Disallow hidden references to mutable static 2024-09-13 13:33:43 +03: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