Commit Graph

452 Commits

Author SHA1 Message Date
Nicholas Nethercote
a56eff2b41 Rename some Diagnostic setters.
`Diagnostic` has 40 methods that return `&mut Self` and could be
considered setters. Four of them have a `set_` prefix. This doesn't seem
necessary for a type that implements the builder pattern. This commit
removes the `set_` prefixes on those four methods.
2024-01-03 19:40:20 +11:00
bors
a2efaf0030 Auto merge of #118705 - WaffleLapkin:codegen-atomic-exhange-untuple, r=cjgillot
Change `rustc_codegen_ssa`'s `atomic_cmpxchg` interface to return a pair of values

Doesn't change much, but a little nicer that way.
2023-12-30 07:42:19 +00:00
Michael Goulet
eca05c6cb0 Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
Bernd Schmidt
69b5a9f2eb Change rustc_codegen_ssa's atomic_cmpxchg interface to return a pair of values 2023-12-28 09:40:47 +00:00
Nicholas Nethercote
02ed790631 Remove Session methods that duplicate DiagCtxt methods.
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier
access.
2023-12-24 08:05:28 +11:00
Nicholas Nethercote
472ea06999 Add level arg to into_diagnostic.
And make all hand-written `IntoDiagnostic` impls generic, by using
`DiagnosticBuilder::new(dcx, level, ...)` instead of e.g.
`dcx.struct_err(...)`.

This means the `create_*` functions are the source of the error level.
This change will let us remove `struct_diagnostic`.

Note: `#[rustc_lint_diagnostics]` is added to `DiagnosticBuilder::new`,
it's necessary to pass diagnostics tests now that it's used in
`into_diagnostic` functions.
2023-12-19 09:19:25 +11:00
Nicholas Nethercote
5ea71c1150 Rename many DiagCtxt arguments. 2023-12-18 16:06:22 +11:00
Nicholas Nethercote
a5c63ae13b Rename CodegenContext::create_diag_handler as CodegenContext::create_dcx. 2023-12-18 16:06:21 +11:00
Nicholas Nethercote
590e0d9573 Rename Handler as DiagCtxt. 2023-12-18 16:06:19 +11:00
bors
335e3ec566 Auto merge of #118828 - mu001999:master, r=b-naber
Remove dead codes in rustc_codegen_gcc

Detected by #118257
2023-12-17 12:15:56 +00:00
Urgau
b1affb9321 Move rustc_codegen_ssa target features to rustc_target 2023-12-14 14:40:55 +01:00
Lukasz Anforowicz
e1f039f562 Add unstable -Zdefault-hidden-visibility cmdline flag for rustc.
The new flag has been described in the Major Change Proposal at
https://github.com/rust-lang/compiler-team/issues/656
2023-12-13 21:14:23 +00:00
Urgau
a72e20d773 Fix rustc codegen gcc tests 2023-12-11 18:48:49 +01:00
r0cky
92de9d4210 Remove dead codes 2023-12-11 23:24:32 +08:00
bors
c578f4302c Auto merge of #117873 - quininer:android-emutls, r=Amanieu
Add emulated TLS support

This is a reopen of https://github.com/rust-lang/rust/pull/96317 . many android devices still only use 128 pthread keys, so using emutls can be helpful.

Currently LLVM uses emutls by default for some targets (such as android, openbsd), but rust does not use it, because `has_thread_local` is false.

This commit has some changes to allow users to enable emutls:

1. add `-Zhas-thread-local` flag to specify that std uses `#[thread_local]` instead of pthread key.
2. when using emutls, decorate symbol names to find thread local symbol correctly.
3. change `-Zforce-emulated-tls` to `-Ztls-model=emulated` to explicitly specify whether to generate emutls.

r? `@Amanieu`
2023-12-09 05:32:35 +00:00
bors
17f0dd5898 Auto merge of #118324 - RalfJung:ctfe-read-only-pointers, r=saethlin
compile-time evaluation: detect writes through immutable pointers

This has two motivations:
- it unblocks https://github.com/rust-lang/rust/pull/116745 (and therefore takes a big step towards `const_mut_refs` stabilization), because we can now detect if the memory that we find in `const` can be interned as "immutable"
- it would detect the UB that was uncovered in https://github.com/rust-lang/rust/pull/117905, which was caused by accidental stabilization of `copy` functions in `const` that can only be called with UB

When UB is detected, we emit a future-compat warn-by-default lint. This is not a breaking change, so completely in line with [the const-UB RFC](https://rust-lang.github.io/rfcs/3016-const-ub.html), meaning we don't need t-lang FCP here. I made the lint immediately show up for dependencies since it is nearly impossible to even trigger this lint without `const_mut_refs` -- the accidentally stabilized `copy` functions are the only way this can happen, so the crates that popped up in #117905 are the only causes of such UB (in the code that crater covers), and the three cases of UB that we know about have all been fixed in their respective crates already.

The way this is implemented is by making use of the fact that our interpreter is already generic over the notion of provenance. For CTFE we now use the new `CtfeProvenance` type which is conceptually an `AllocId` plus a boolean `immutable` flag (but packed for a more efficient representation). This means we can mark a pointer as immutable when it is created as a shared reference. The flag will be propagated to all pointers derived from this one. We can then check the immutable flag on each write to reject writes through immutable pointers.

I just hope perf works out.
2023-12-07 18:11:01 +00:00
Ralf Jung
cb32ffd8da ctfe interpreter: extend provenance so that it can track whether a pointer is immutable 2023-12-07 17:46:36 +01:00
Urgau
3cfff05ac7 Allow internal_features in rustc_codegen_gcc examples 2023-12-07 15:26:18 +01:00
Urgau
19e11760ab Update rustc_codegen_gcc libc 2023-12-07 14:59:37 +01:00
quininer
2baa073fb1 Add emulated TLS support
Currently LLVM uses emutls by default
for some targets (such as android, openbsd),
but rust does not use it, because `has_thread_local` is false.

This commit has some changes to allow users to enable emutls:

1. add `-Zhas-thread-local` flag to specify
    that std uses `#[thread_local]` instead of pthread key.
2. when using emutls, decorate symbol names
    to find thread local symbol correctly.
3. change `-Zforce-emulated-tls` to `-Ztls-model=emulated`
    to explicitly specify whether to generate emutls.
2023-12-07 00:21:32 +08:00
Nicholas Nethercote
f9a228df48 Rename some arguments.
`sess` is a terribly misleading name for a `Handler`! This confused me
for a bit.
2023-12-04 18:57:41 +11:00
Nicholas Nethercote
8e13be084a Use rustc_fluent_macro::fluent_messages! directly.
Currently we always do this:
```
use rustc_fluent_macro::fluent_messages;
...
fluent_messages! { "./example.ftl" }
```
But there is no need, we can just do this everywhere:
```
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
```
which is shorter.
2023-11-26 08:38:40 +11:00
Nicholas Nethercote
4de5d372aa Avoid need for {D,Subd}iagnosticMessage imports.
The `fluent_messages!` macro produces uses of
`crate::{D,Subd}iagnosticMessage`, which means that every crate using
the macro must have this import:
```
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
```

This commit changes the macro to instead use
`rustc_errors::{D,Subd}iagnosticMessage`, which avoids the need for the
imports.
2023-11-26 08:38:00 +11:00
Antoni Boucher
456754c21a Pass TyCtxt by value 2023-11-19 14:04:40 -05:00
Antoni Boucher
75fce09751 Merge commit '2e8386e9fb3506cef991d04f8b3bc78f9a0c2630' into subtree-update_cg_gcc_2023-11-17 2023-11-19 13:42:13 -05:00
Mark Rousskov
a6493c1f65 Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
Ralf Jung
b2add8a63e target_feature: make it more clear what that 'Option' means 2023-11-12 12:46:05 +01:00
Guillaume Gomez
a13408d824 Remove libc dependency in cg_gcc alloc_system example 2023-11-02 21:03:27 +01:00
Guillaume Gomez
1075b80649 Pass --sysroot option 2023-11-02 21:03:27 +01:00
Guillaume Gomez
a37446bbb7 Fix config.sh script 2023-11-02 21:03:27 +01:00
Guillaume Gomez
34e6386f63 Fix compilation errors in rustc_codegen_gcc examples 2023-11-02 21:03:27 +01:00
Guillaume Gomez
249969c205 Disable master feature by default when building rustc_codegen_gcc 2023-11-02 21:03:27 +01:00
Antoni Boucher
ff57d7007f Merge commit '09ce29d0591a21e1abae22eac4d41ffd32993af8' into subtree-update_cg_gcc_2023-10-25 2023-10-27 16:07:01 -04:00
Antoni Boucher
9f4f90b19a Merge commit 'e4fe941b11a55c5005630696e9b6d81c65f7bd04' into subtree-update_cg_gcc_2023-10-25 2023-10-26 17:42:02 -04:00
Oli Scherer
a690467938 s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Oli Scherer
67b28ac34b s/Generator/Coroutine/ 2023-10-20 21:10:38 +00:00
Michael Howell
e1cb8187e1 docs: add Rust logo to more compiler crates
c6e6ecb1af added it to some of the
compiler's crates, but avoided adding it to all of them to reduce
bit-rot. This commit adds to more.
2023-10-16 15:38:08 -07:00
Antoni Boucher
ba103e34c0 Use IntoDynSyncSend 2023-10-09 17:13:35 -04:00
Antoni Boucher
22e6f6caaf Fix checks 2023-10-09 16:03:05 -04:00
Antoni Boucher
242a482c88 Merge commit '11a0cceab966e5ff1058ddbcab5977e8a1d6d290' into subtree-update_cg_gcc_2023-10-09 2023-10-09 15:53:34 -04:00
bors
91ab7909e1 Auto merge of #102099 - InnovativeInventor:re-cold-land, r=nikic
Rebased: Mark drop calls in landing pads cold instead of noinline

I noticed that certain inlining optimizations were missing while staring at some compiled code output. I'd like to see this relanded, so I rebased the PR from `@erikdesjardins` (PR #94823).

This PR reapplies https://github.com/rust-lang/rust/pull/92419, which was reverted in https://github.com/rust-lang/rust/pull/94402 due to https://github.com/rust-lang/rust/issues/94390.

Fixes https://github.com/rust-lang/rust/issues/46515, fixes https://github.com/rust-lang/rust/issues/87055.

Update: fixes #97217.
2023-10-02 22:02:12 +00:00
Erik Desjardins
7e8c85ba31 Reapply: Mark drop calls in landing pads cold instead of noinline
Co-authored-by: Max Fan <git@max.fan>
Co-authored-by: Nikita Popov <npopov@redhat.com>
2023-10-02 10:37:53 +02:00
bors
c7407eff9d Auto merge of #115898 - onur-ozkan:config-change-tracking, r=Mark-Simulacrum
bootstrap major change detection implementation

The use of `changelog-seen` and `bootstrap/CHANGELOG.md` has not been functional in any way for many years. We often do major/breaking changes but never update the changelog file or the `changelog-seen`. This is an alternative method for tracking major or breaking changes and informing developers when such changes occur.

Example output when bootstrap detects a major change:
![image](https://github.com/rust-lang/rust/assets/39852038/ee802dfa-a02b-488b-a433-f853ce079b8a)
2023-10-02 07:41:52 +00:00
onur-ozkan
b1862af177 implement major change tracking for the bootstrap configuration
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-01 16:54:52 +03:00
Oli Scherer
8373b05514 Have a single struct for queries and hook 2023-09-22 16:26:20 +00:00
Oli Scherer
38b9e26a75 Add a way to decouple the implementation and the declaration of a TyCtxt method. 2023-09-22 09:23:15 +00:00
Ralf Jung
cd519aabd7 fix gcc, cranelift build 2023-09-15 10:43:44 +02:00
Ralf Jung
22e13b4c55 clarify PassMode::Indirect as well 2023-09-15 10:43:44 +02:00
Deadbeef
d7766ffa36 treat host effect params as erased generics in codegen
This fixes the changes brought to codegen tests when effect params are
added to libcore, by not attempting to monomorphize functions that get
the host param by being `const fn`.
2023-09-14 07:34:35 +00:00
Daniel Paoliello
8028885239 Deduplicate inlined function debug info, but create a new lexical scope to child subsequent scopes and variables from colliding 2023-09-01 14:27:21 -07:00