Commit Graph

223865 Commits

Author SHA1 Message Date
Matthias Krüger
f440999bb2
Rollup merge of #111167 - cuviper:type-decl-disubprogram, r=michaelwoerister
debuginfo: split method declaration and definition

When we're adding a method to a type DIE, we only want a DW_AT_declaration
there, because LLVM LTO can't unify type definitions when a child DIE is a
full subprogram definition. Now the subprogram definition gets added at the
CU level with a specification link back to the abstract declaration.

Both GCC and Clang write debuginfo this way for C++ class methods.

Fixes #109730.
Fixes #109934.
2023-05-06 13:30:05 +02:00
Matthias Krüger
8ec84dd523
Rollup merge of #110989 - jyn514:bug-report-url, r=WaffleLapkin
Make the BUG_REPORT_URL configurable by tools

This greatly simplifies how hard it is to set a custom bug report url; previously tools had to copy
the entire hook implementation.

I haven't changed clippy in case they want to make the change upstream instead of the subtree, but
I'm happy to do so here if the maintainers want - cc ````@rust-lang/clippy````

Fixes https://github.com/rust-lang/rust/issues/109486.
2023-05-06 13:30:04 +02:00
Matthias Krüger
8172ada984
Rollup merge of #110985 - Amanieu:normalize_asm_spans, r=b-naber
Fix spans in LLVM-generated inline asm errors

Previously, incorrect spans were reported if inline assembly contained CRLF (Windows) line endings.

Fixes #110885
2023-05-06 13:30:04 +02:00
Matthias Krüger
77004eafea
Rollup merge of #110610 - spastorino:smir-terminator, r=oli-obk
Add Terminator conversion from MIR to SMIR, part #1

This adds internal MIR TerminatorKind to SMIR Terminator conversion.

r? ```@oli-obk```
2023-05-06 13:30:03 +02:00
Matthias Krüger
bcc9aa01b5
Rollup merge of #110577 - compiler-errors:drop-impl-fulfill, r=lcnr
Use fulfillment to check `Drop` impl compatibility

Use an `ObligationCtxt` to ensure that a `Drop` impl does not have stricter requirements than the ADT that it's implemented for, rather than using a `SimpleEqRelation` to (more or less) syntactically equate predicates on an ADT with predicates on an impl.

r? types

### Some background

The old code reads:

```rust
// An earlier version of this code attempted to do this checking
// via the traits::fulfill machinery. However, it ran into trouble
// since the fulfill machinery merely turns outlives-predicates
// 'a:'b and T:'b into region inference constraints. It is simpler
// just to look for all the predicates directly.
```

I'm not sure what this means, but perhaps in the 8 years since that this comment was written (cc #23638) it's gotten easier to process region constraints after doing fulfillment? I don't know how this logic differs from anything we do in the `compare_impl_item` module. Ironically, later on it says:

```rust
// However, it may be more efficient in the future to batch
// the analysis together via the fulfill (see comment above regarding
// the usage of the fulfill machinery), rather than the
// repeated `.iter().any(..)` calls.
```

Also:
* Removes `SimpleEqRelation` which was far too syntactical in its relation.
* Fixes #110557
2023-05-06 13:30:03 +02:00
Lukas Markeffsky
7e3b93417c clean up transmutes in core 2023-05-06 13:28:38 +02:00
bors
333b920fee Auto merge of #109421 - mhammerly:extern-force-option, r=petrochenkov
Add `force` option for `--extern` flag

When `--extern force:foo=libfoo.so` is passed to `rustc` and `foo` is not actually used in the crate, ~inject an `extern crate foo;` statement into the AST~ force it to be resolved anyway in `CrateLoader::postprocess()`. This allows you to, for instance, inject a `#[panic_handler]` implementation into a `#![no_std]` crate without modifying its source so that it can be built as a `dylib`. It may also be useful for `#![panic_runtime]` or `#[global_allocator]`/`#![default_lib_allocator]` implementations.

My work previously involved integrating Rust into an existing C/C++ codebase which was built with Buck and shipped on, among other platforms, Android. When targeting Android, Buck builds all "native" code with shared linkage* so it can be loaded from Java/Kotlin. My project was not itself `#![no_std]`, but many of our dependencies were, and they would fail to build with shared linkage due to a lack of a panic handler. With this change, that project can add the new `force` option to the `std` dependency it already explicitly provides to every crate to solve this problem.

*This is an oversimplification - Buck has a couple features for aggregating dependencies into larger shared libraries, but none that I think sustainably solve this problem.

~The AST injection happens after macro expansion around where we similarly inject a test harness and proc-macro harness. The resolver's list of actually-used extern flags is populated during macro expansion, and if any of our `--extern` arguments have the `force` option and weren't already used, we inject an `extern crate` statement for them. The injection logic was added in `rustc_builtin_macros` as that's where similar injections for tests, proc-macros, and std/core already live.~

(New contributor - grateful for feedback and guidance!)
2023-05-06 11:24:37 +00:00
Amanieu d'Antras
bba2a1e071 Fix spans in LLVM-generated inline asm errors
Previously, incorrect spans were reported if inline assembly contained
CRLF (Windows) line endings.

Fixes #110885
2023-05-06 09:31:57 +01:00
Scott McMurray
ec3a9bcdb7 Remove some assumes from slice iterators that don't do anything 2023-05-06 00:33:32 -07:00
bors
151a070afe Auto merge of #104872 - luqmana:packed-union-align, r=oli-obk
Avoid alignment mismatch between ABI and layout for unions.

Fixes #104802
Fixes #103634

r? `@eddyb` cc `@RalfJung`
2023-05-06 07:25:50 +00:00
Michael Goulet
2a1ef34223 More robust debug assertions for Instance::resolve on built-in traits with custom items 2023-05-06 05:58:04 +00:00
bors
6e96802bf5 Auto merge of #107129 - wesleywiser:musl_1.2_upgrade, r=petrochenkov
Update the version of musl used on `*-linux-musl` targets to 1.2.3

Update the version of musl used on our Linux musl targets from 1.1.24 to 1.2.3 as proposed in rust-lang/compiler-team#572. musl 1.2.3 is the latest version of musl and supports the same range of Linux kernels as the 1.1 series. As such, it does not affect the minimum supported version of Linux for any of the musl targets.

One of the major musl 1.2 features is support for [time64](https://musl.libc.org/time64.html). This support is both source and ABI compatible with programs built against musl 1.1 and so updating the musl version for these targets should not cause Rust programs to fail to run or compile (a [crater run](https://github.com/rust-lang/rust/pull/107129#issuecomment-1407196104) has been completed which demonstrates this for the `i686-unknown-linux-musl` target).

Once this change reaches stable, the `libc` crate will then be able to [update their definitions to support 64-bit time](https://github.com/rust-lang/libc/pull/3068), matching the default musl 1.2 APIs exactly.

Fixes #91178
2023-05-06 04:20:18 +00:00
bors
6d140d59bb Auto merge of #111271 - JohnTitor:rollup-t07qk1c, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #109677 (Stabilize raw-dylib, link_ordinal, import_name_type and -Cdlltool)
 - #110780 (rustdoc-search: add slices and arrays to index)
 - #110830 (Add FreeBSD cpuset support to `std:🧵:available_concurrency`)
 - #111139 (Fix MXCSR configuration dependent timing)
 - #111239 (Remove unnecessary attribute from a diagnostic)
 - #111246 (forbid escaping bound vars in combine)
 - #111251 (Issue 109502 follow up, remove unnecessary Vec::new() from compile_test())
 - #111261 (Mark `ErrorGuaranteed` constructor as deprecated so people don't use it)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-06 00:34:37 +00:00
Josh Stone
67ae38a336 Expand the LLVM coverage of --print target-cpus
We've been relying on a custom patch to add `MCSubtargetInfo::getCPUTable`
for `rustc --print target-cpus`, and just printing that it's not supported
on external LLVM builds. LLVM `main` now has `getAllProcessorDescriptions`
that can replace ours, so now we try to use that. In addition, the fallback
path can at least print the native and default cpu options.

There were also some mismatches in the function signatures here between
`LLVM_RUSTLLVM` and otherwise; this is now mitigated by sharing these
functions and only using cpp to adjust the function bodies.
2023-05-05 17:27:59 -07:00
Yuki Okushi
393e285e14
Rollup merge of #111261 - compiler-errors:error-guaranteed-should-be-scarier-to-construct, r=BoxyUwU
Mark `ErrorGuaranteed` constructor as deprecated so people don't use it

You should never ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever use this function unless you know what you're doing, so make it harder to accidentally use it!

Alternatives are to change the name to sound scarier, make it `unsafe` (though it's not really a soundness thing), or work on deeper refactors to make it private.

r? `@BoxyUwU`
2023-05-06 09:09:34 +09:00
Yuki Okushi
d97cef099e
Rollup merge of #111251 - mj10021:issue-109502-follow-up, r=oli-obk
Issue 109502 follow up, remove unnecessary Vec::new() from compile_test()

As mentioned in comment on PR #110773 , adding a separate function to pass the test passes into the `dump-mir` is a bit nicer
2023-05-06 09:09:34 +09:00
Yuki Okushi
ce71f570f4
Rollup merge of #111246 - lcnr:no-escaping-bound-vars, r=compiler-errors
forbid escaping bound vars in combine

removes the `CollectAllMismatches` in favor of a slightly more manual approach.

r? types cc ``@estebank``
2023-05-06 09:09:33 +09:00
Yuki Okushi
bc4a1198fc
Rollup merge of #111239 - TaKO8Ki:fix-111232, r=compiler-errors
Remove unnecessary attribute from a diagnostic

Fixes #111232

ref: 06ff310cf9
2023-05-06 09:09:33 +09:00
Yuki Okushi
ea1a0d76af
Rollup merge of #111139 - fortanix:raoul/fix_mxcsr_configuration_dependent_timing, r=thomcc
Fix MXCSR configuration dependent timing

Dependent on the (potentially secret) data some vector instructions operate on, and the content in MXCSR, instruction retirement may be delayed by one cycle. This is a potential side channel.

This PR fixes this vulnerability for the `x86_64-fortanix-unknown-sgx` platform by loading MXCSR with `0x1fbf` through an `xrstor` instruction when the enclave is entered and executing an `lfence` immediately after. Other changes of the MXCSR happen only when the enclave is about to be exited and no vector instructions will be executed before it will actually do so. Users of EDP who change the MXCSR and do wish to defend against this side channel, will need to implement the software mitigation described [here](https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/best-practices/mxcsr-configuration-dependent-timing.html).

cc: `@jethrogb` `@monokles`
2023-05-06 09:09:32 +09:00
Yuki Okushi
3d9a1de690
Rollup merge of #110830 - Freaky:freebsd-cpuset, r=thomcc
Add FreeBSD cpuset support to `std:🧵:available_concurrency`

Use libc::cpuset_getaffinity to determine the CPUs available to the current process.

The existing sysconf and sysctl paths are left as fallback.
2023-05-06 09:09:32 +09:00
Yuki Okushi
30220be929
Rollup merge of #110780 - notriddle:notriddle/slice-index, r=GuillaumeGomez
rustdoc-search: add slices and arrays to index

This indexes them as primitives with generics, so `slice<u32>` is how you search for `[u32]`, and `array<u32>` for `[u32; 1]`. A future commit will desugar the square bracket syntax to search both arrays and slices at once.
2023-05-06 09:09:31 +09:00
Yuki Okushi
923a5a2ca7
Rollup merge of #109677 - dpaoliello:rawdylib, r=michaelwoerister,wesleywiser
Stabilize raw-dylib, link_ordinal, import_name_type and -Cdlltool

This stabilizes the `raw-dylib` feature (#58713) for all architectures (i.e., `x86` as it is already stable for all other architectures).

Changes:
* Permit the use of the `raw-dylib` link kind for x86, the `link_ordinal` attribute and the `import_name_type` key for the `link` attribute.
* Mark the `raw_dylib` feature as stable.
* Stabilized the `-Zdlltool` argument as `-Cdlltool`.
* Note the path to `dlltool` if invoking it failed (we don't need to do this if `dlltool` returns an error since it prints its path in the error message).
* Adds tests for `-Cdlltool`.
* Adds tests for being unable to find the dlltool executable, and dlltool failing.
* Fixes a bug where we were checking the exit code of dlltool to see if it failed, but dlltool always returns 0 (indicating success), so instead we need to check if anything was written to `stderr`.

NOTE: As previously noted (https://github.com/rust-lang/rust/pull/104218#issuecomment-1315895618) using dlltool within rustc is temporary, but this is not the first time that Rust has added a temporary tool use and argument: https://github.com/rust-lang/rust/pull/104218#issuecomment-1318720482

Big thanks to ``````@tbu-`````` for the first version of this PR (#104218)
2023-05-06 09:09:30 +09:00
Luqman Aden
8e7714d3bb Reorder to keep duplicate checks in sync. 2023-05-05 16:30:32 -07:00
Luqman Aden
012f9a333b Review feedback 2023-05-05 16:14:36 -07:00
Luqman Aden
c63a204e23 Don't discard preferred alignment in scalar pair. 2023-05-05 16:11:08 -07:00
Luqman Aden
3b1e535f36 Factor out checks in layout check and add helper inherent_size. 2023-05-05 16:11:03 -07:00
Luqman Aden
f2d81defa1 Add additional test case for repr(packed) allowing union abi opt to kick in. 2023-05-05 16:05:04 -07:00
Luqman Aden
d5ab3a06d2 Add test cases for #104802. 2023-05-05 16:05:03 -07:00
Luqman Aden
4f4f22b11c Incorporate review feedback from 103926. 2023-05-05 16:04:59 -07:00
Luqman Aden
a3800535b1 Add helper methods inherent_align and to_union on Abi. 2023-05-05 16:00:19 -07:00
Oli Scherer
23d09aebc8 Do not use scalar layout if there are ZSTs with alignment > 1 2023-05-05 16:00:12 -07:00
Luqman Aden
c7c042ad31 Address review comments.
Remove bitcasts in OperandRef::extract_field; only pointercasts should
be needed.
2023-05-05 15:13:18 -07:00
Luqman Aden
7b1eedaae8 Switch test back to run-pass. 2023-05-05 14:58:52 -07:00
bors
963e5c0eff Auto merge of #111255 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2023-05-05 21:50:14 +00:00
Luqman Aden
2942121736 Update test location. 2023-05-05 14:43:20 -07:00
Luqman Aden
6a5ee11027 Don't bitcast aggregate field. 2023-05-05 14:25:56 -07:00
Luqman Aden
af69cc0ea0 Make test more targeted. 2023-05-05 14:25:56 -07:00
Luqman Aden
75f3fafa72 Add test. 2023-05-05 14:25:56 -07:00
Luqman Aden
48af94c080 Operand::extract_field: only cast llval if it's a pointer and replace bitcast w/ pointercast. 2023-05-05 14:25:55 -07:00
Matthew Jasper
f46eabb9e5 Report nicer lifetime errors for specialization
Add an obligation cause for these error so that the error points to the
implementations that caused the error.
2023-05-05 22:19:56 +01:00
Boxy
73b3ce26ec improve diagnostics and bless tests 2023-05-05 21:42:54 +01:00
Boxy
442617c046 misc nameres changes for anon consts 2023-05-05 21:31:35 +01:00
Matt Hammerly
812f2d75e1 add "force" option to --extern 2023-05-05 13:02:43 -07:00
Chris Denton
e314a3b21f
Sort windows_sys.lst alphabetically 2023-05-05 20:48:17 +01:00
Chris Denton
3ffb27ff89
Use new bindings 2023-05-05 20:48:16 +01:00
Chris Denton
e92ee03559
Generate windows-sys bindings 2023-05-05 20:48:16 +01:00
Chris Denton
f9b3d6a525
Generate windows-sys bindings 2023-05-05 20:48:16 +01:00
Charisee
37f3e2f4b1 rewriting match on endianness 2023-05-05 19:47:00 +00:00
est31
83b4df4e61 Add feature gate 2023-05-05 21:44:48 +02:00
est31
5eb29c7f49 Migrate offset_of from a macro to builtin # syntax 2023-05-05 21:44:13 +02:00