Commit Graph

2562 Commits

Author SHA1 Message Date
Michael Goulet
1c799ff05e
Rollup merge of #131521 - jdonszelmann:rc, r=joboet
rename RcBox to RcInner for consistency

Arc uses ArcInner too (created in collaboration with `@aDotInTheVoid` and `@WaffleLapkin` )
2024-10-15 12:33:36 -04:00
Matthias Krüger
7c79621462
Rollup merge of #129079 - Zoxc:thinlto_imp_symbols, r=wesleywiser
Create `_imp__` symbols also when doing ThinLTO

When generating a rlib crate on Windows we create `dllimport` / `_imp__` symbols for each global. This effectively makes the rlib contain an import library for itself and allows them to both be dynamically and statically linked. However when doing ThinLTO we do not generate these and thus we end up with missing symbols. Microsoft's `link` can fix these up (and emits warnings), but `lld` seems to currently be unable to.

This PR also does this generation for ThinLTO avoiding those issues with `lld` and also avoids the warnings on `link`.

This is an workaround for https://github.com/rust-lang/rust/issues/81408.

cc `@lqd`
2024-10-11 15:36:51 +02:00
Jonathan Dönszelmann
0a9c87b1f5
rename RcBox in other places too 2024-10-11 10:04:22 +02:00
Matthias Krüger
13976f1f25
Rollup merge of #130308 - davidtwco:tied-target-consolidation, r=wesleywiser
codegen_ssa: consolidate tied target checks

Fixes #105110.
Fixes #105111.

`rustc_codegen_llvm` and `rustc_codegen_gcc` duplicated logic for checking if tied target features were partially enabled. This PR consolidates these checks into `rustc_codegen_ssa` in the `codegen_fn_attrs` query, which also is run pre-monomorphisation for each function, which ensures that this check is run for unused functions, as would be expected.

Also adds a test confirming that enabling one tied feature doesn't imply another - the appropriate error for this was already being emitted. I did a bisect and narrowed it down to two patches it was likely to be - something in #128796, probably #128221 or #128679.
2024-10-10 22:00:45 +02:00
Matthias Krüger
68313623fc
Rollup merge of #131480 - madsmtm:macos-fix-strip-binary, r=nnethercote
Fix hardcoded strip path when cross-compiling from Linux to Darwin

Fixes https://github.com/rust-lang/rust/issues/131206.

I fear that https://github.com/rust-lang/rust/pull/131405 might end up taking some time, so opening this PR to resolve the regression.

`@rustbot` label O-apple
2024-10-10 12:49:20 +02:00
Mads Marquart
09b634a4ba Fix hardcoded strip path when cross-compiling from Linux to Darwin 2024-10-10 04:03:48 +02:00
Mads Marquart
d6aaf7b036 Avoid redundant -Wl,-dylib flag when linking 2024-10-10 03:51:11 +02:00
Jubilee Young
839cf1c1a4 compiler: Factor rustc_target::abi out of cg_ssa 2024-10-08 18:24:56 -07:00
bors
7caad69253 Auto merge of #131354 - matthiaskrgr:rollup-hprnng2, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #131331 (Revert "warn_old_master_branch" check)
 - #131344 (Avoid `&Lrc<T>` in various places)
 - #131346 (Restrict `ignore-mode-*` directives)
 - #131353 (Add documentation for `runtest::check_rustdoc_test_option` method)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-07 11:30:33 +00:00
Matthias Krüger
df61a0b1b2
Rollup merge of #131344 - nnethercote:ref-Lrc, r=compiler-errors
Avoid `&Lrc<T>` in various places

Seeing `&Lrc<T>` is a bit suspicious, and `&T` or `Lrc<T>` is often better.

r? `@oli-obk`
2024-10-07 12:23:54 +02:00
bors
0b16baa570 Auto merge of #131235 - codemountains:rename-nestedmetaitem-to-metaitemlnner, r=nnethercote
Rename `NestedMetaItem` to `MetaItemInner`

Fixes #131087

r? `@nnethercote`
2024-10-07 08:59:55 +00:00
Nicholas Nethercote
731469fee5 Convert Option<&Lrc<T>> return types to Option<&T>.
It's simpler and more concise.
2024-10-07 13:56:29 +11:00
Folkert de Vries
5fc60d1e52 various fixes for naked_asm! implementation
- fix for divergence
- fix error message
- fix another cranelift test
- fix some cranelift things
- don't set the NORETURN option for naked asm
- fix use of naked_asm! in doc comment
- fix use of naked_asm! in run-make test
- use `span_bug` in unreachable branch
2024-10-06 19:00:09 +02:00
codemountains
6dfc4a0473 Rename NestedMetaItem to MetaItemInner 2024-10-06 23:28:30 +09:00
Guillaume Gomez
ba94a2ada1
Rollup merge of #131202 - Urgau:wide-ptrs-compiler, r=jieyouxu
Use wide pointers consistenly across the compiler

This PR replace every use of "fat pointer" for the more recent "wide pointer" terminology.

Since some time T-lang as preferred the "wide pointer" terminology, as can be seen on [the last RFCs](https://github.com/search?q=repo%3Arust-lang%2Frfcs+%22wide+pointer%22&type=code), on some [lints](https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#ambiguous-wide-pointer-comparisons), but also in [the reference](https://doc.rust-lang.org/stable/reference/expressions/operator-expr.html?highlight=wide%20pointer#pointer-to-pointer-cast).

Currently we have a [mix of both](https://github.com/search?q=repo%3Arust-lang%2Frust+%22wide+pointer%22&type=code) (including in error messages), which isn't great, but with this PR no more.

r? `@jieyouxu` (feel free to re-roll)
2024-10-04 15:42:54 +02:00
Guillaume Gomez
2ceeeb159d
Rollup merge of #131034 - Urgau:cfg-true-false, r=nnethercote
Implement RFC3695 Allow boolean literals as cfg predicates

This PR implements https://github.com/rust-lang/rfcs/pull/3695: allow boolean literals as cfg predicates, i.e. `cfg(true)` and `cfg(false)`.

r? `@nnethercote` *(or anyone with parser knowledge)*
cc `@clubby789`
2024-10-04 15:42:53 +02:00
Urgau
018ba0528f Use wide pointers consistenly across the compiler 2024-10-04 14:06:48 +02:00
Matthias Krüger
5fd6218d72
Rollup merge of #131016 - madsmtm:no-sdk-version-in-object, r=jieyouxu
Apple: Do not specify an SDK version in `rlib` object files

This was added in https://github.com/rust-lang/rust/pull/114114, but is unnecessary, since it ends up being overwritten when linking anyhow, and it feels wrong to embed some arbitrary SDK version in here. The object files produced by LLVM also do not set this, and the tooling shows `n/a` when it's `0`, so it seems to genuinely be optional in object files.

I've also added a test for the different places the SDK version shows up, and documented a bit more in the code how SDK versions work.

See https://github.com/rust-lang/rust/issues/129432 for the bigger picture.

Tested with (excludes the same few targets as in https://github.com/rust-lang/rust/pull/130435):
```console
./x test tests/run-make/apple-sdk-version --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,armv7k-apple-watchos,armv7s-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
IPHONEOS_DEPLOYMENT_TARGET=10.0 ./x test tests/run-make/apple-sdk-version --target=i386-apple-ios
```

CC `@BlackHoleFox,` you [originally commented on these values](https://github.com/rust-lang/rust/pull/114114#discussion_r1300599445).

`@rustbot` label O-apple
2024-10-02 17:10:43 +02:00
Matthias Krüger
f9ba5529eb
Rollup merge of #130863 - compiler-errors:relax-codegen-dyn-assert, r=lcnr
Relax a debug assertion for dyn principal *equality* in codegen

Maybe this sucks and I should just bite the bullet and use `infcx.sub` here. Thoughts?

r? lcnr

Fixes #130855
2024-10-02 17:10:43 +02:00
Urgau
57b9b1f974 Use ast::NestedMetaItem when evaluating cfg predicate 2024-10-01 10:01:09 +02:00
Trevor Gross
eaaa94318b Unpin cc and upgrade to the latest version
`cc` was previously pinned because version 1.1.106 dropped support for
Visual Studio 12 (2013), and we wanted to decouple that from the rest of
the automated updates. As noted in [2], there is no longer anything
indicating we support VS2013, so it should be okay to unpin it.

`cc` 1.1.22 contains a fix that may help improve the high MSVC CI
failure rate [3], so we also have motivation to update to that point.

[1]: https://github.com/rust-lang/rust/issues/129307
[2]: https://github.com/rust-lang/rust/issues/129307#issuecomment-2383749868
[3]: https://github.com/rust-lang/rust/issues/127883
2024-09-30 13:31:42 -04:00
Michael Goulet
cbb5047d35 Relate binders explicitly, do a leak check too 2024-09-30 12:42:29 -04:00
Michael Goulet
eb75d20a55 Relax a debug assertion in codegen 2024-09-30 12:18:02 -04:00
Mads Marquart
6b06ceb2fd Do not specify an SDK version in object files
This is unnecessary, since it ends up being overwritten when linking
anyhow, and it feels wrong to embed some arbitrary SDK version in here.
2024-09-29 14:45:09 +02:00
Mads Marquart
0bebedd799 Document a bit more how the SDK version actually works 2024-09-29 14:45:08 +02:00
Matthias Krüger
cfe0cff5b9
Rollup merge of #130960 - cuviper:cdylib-soname, r=petrochenkov
Only add an automatic SONAME for Rust dylibs

#126094 added an automatic relative `SONAME` to all dynamic libraries, but it was really only needed for Rust `--crate-type="dylib"`. In Fedora, it was a surprise to see `SONAME` on `"cdylib"` libraries like Python modules, especially because that generates an undesirable RPM `Provides`. We can instead add a `SONAME` just for Rust dylibs by passing the crate-type argument farther.

Ref: https://bugzilla.redhat.com/show_bug.cgi?id=2314879
2024-09-28 15:11:22 +02:00
bors
851f698682 Auto merge of #130874 - klensy:bumpme, r=jieyouxu
bump few deps

Bumps cargo_metadata, thorin-dwp, windows.

Should dedupe some crates around.
2024-09-28 05:15:29 +00:00
Josh Stone
f46057bf1c Only add an automatic SONAME for Rust dylibs 2024-09-27 15:53:26 -07:00
klensy
26c09b6553 bump few deps
cargo_metadata, thorin-dwp, windows
2024-09-27 09:23:05 +03:00
Mads Marquart
fb10eeb42b Move Apple linker args from rustc_target to rustc_codegen_ssa
They are dependent on the deployment target and SDK version, but having
these in `rustc_target` makes it hard to introduce that dependency.
2024-09-26 16:40:25 +02:00
bors
76ed7a1fa4 Auto merge of #130329 - khuey:reorder-constant-spills, r=davidtwco
Reorder stack spills so that constants come later.

Currently constants are "pulled forward" and have their stack spills emitted first. This confuses LLVM as to where to place breakpoints at function entry, and results in argument values being wrong in the debugger. It's straightforward to avoid emitting the stack spills for constants until arguments/etc have been introduced in debug_introduce_locals, so do that.

Example LLVM IR (irrelevant IR elided):
Before:
```
define internal void `@_ZN11rust_1289457binding17h2c78f956ba4bd2c3E(i64` %a, i64 %b, double %c) unnamed_addr #0 !dbg !178 { start:
  %c.dbg.spill = alloca [8 x i8], align 8
  %b.dbg.spill = alloca [8 x i8], align 8
  %a.dbg.spill = alloca [8 x i8], align 8
  %x.dbg.spill = alloca [4 x i8], align 4
  store i32 0, ptr %x.dbg.spill, align 4, !dbg !192            ; LLVM places breakpoint here.
    #dbg_declare(ptr %x.dbg.spill, !190, !DIExpression(), !192)
  store i64 %a, ptr %a.dbg.spill, align 8
    #dbg_declare(ptr %a.dbg.spill, !187, !DIExpression(), !193)
  store i64 %b, ptr %b.dbg.spill, align 8
    #dbg_declare(ptr %b.dbg.spill, !188, !DIExpression(), !194)
  store double %c, ptr %c.dbg.spill, align 8
    #dbg_declare(ptr %c.dbg.spill, !189, !DIExpression(), !195)
  ret void, !dbg !196
}
```
After:
```
define internal void `@_ZN11rust_1289457binding17h2c78f956ba4bd2c3E(i64` %a, i64 %b, double %c) unnamed_addr #0 !dbg !178 { start:
  %x.dbg.spill = alloca [4 x i8], align 4
  %c.dbg.spill = alloca [8 x i8], align 8
  %b.dbg.spill = alloca [8 x i8], align 8
  %a.dbg.spill = alloca [8 x i8], align 8
  store i64 %a, ptr %a.dbg.spill, align 8
    #dbg_declare(ptr %a.dbg.spill, !187, !DIExpression(), !192)
  store i64 %b, ptr %b.dbg.spill, align 8
    #dbg_declare(ptr %b.dbg.spill, !188, !DIExpression(), !193)
  store double %c, ptr %c.dbg.spill, align 8
    #dbg_declare(ptr %c.dbg.spill, !189, !DIExpression(), !194)
  store i32 0, ptr %x.dbg.spill, align 4, !dbg !195            ; LLVM places breakpoint here.
    #dbg_declare(ptr %x.dbg.spill, !190, !DIExpression(), !195)
  ret void, !dbg !196
}
```
Note in particular the position of the "LLVM places breakpoint here" comment relative to the stack spills for the function arguments. LLVM assumes that the first instruction with with a debug location is the end of the prologue. As LLVM does not currently offer front ends any direct control over the placement of the prologue end reordering the IR is the only mechanism available to fix argument values at function entry in the presence of MIR optimizations like SingleUseConsts. Fixes #128945

r? `@michaelwoerister`
2024-09-26 02:37:52 +00:00
Matthias Krüger
81ac893d3b
Rollup merge of #130781 - monkeydbobo:mdb/fix_up_cross_compile_osx, r=davidtwco
Fix up setting strip = true in Cargo.toml makes build scripts fail in…

Fix issue: https://github.com/rust-lang/rust/issues/110536
Strip binary is PATH dependent which breaks builds in MacOS.
For example, on my Mac, the output of 'which strip' is '/opt/homebrew/opt/binutils/bin/strip', which leads to incorrect 'strip' results. Therefore, just like on other systems, it is also necessary to specify 'stripcmd' on macOS. However, it seems that there is a bug in binutils [bugzilla-Bug 31571](https://sourceware.org/bugzilla/show_bug.cgi?id=31571), which leads to the problem mentioned above.
2024-09-25 20:10:59 +02:00
Michael Goulet
3209943604 Add a debug assertion in codegen that unsize casts of the same principal trait def id are truly NOPs 2024-09-25 11:13:59 -04:00
bors
2933f68abe Auto merge of #130816 - matthiaskrgr:rollup-jy25phv, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #130549 (Add RISC-V vxworks targets)
 - #130595 (Initial std library support for NuttX)
 - #130734 (Fix: ices on virtual-function-elimination about principal trait)
 - #130787 (Ban combination of GCE and new solver)
 - #130809 (Update llvm triple for OpenHarmony targets)
 - #130810 (Don't trap into the debugger on panics under Linux)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-25 08:43:14 +00:00
Matthias Krüger
0e439090cb
Rollup merge of #130734 - Luv-Ray:fix_vfe, r=lcnr
Fix: ices on virtual-function-elimination about principal trait

Extract `load_vtable` function to ensure the `virtual_function_elimination` option is always checked.
It's okay not to use `llvm.type.checked.load` to load the vtable if there is no principal trait.

Fixes #123955
Fixes #124092
2024-09-25 10:09:23 +02:00
bors
4c62024cd5 Auto merge of #130803 - cuviper:file-buffered, r=joshtriplett
Add `File` constructors that return files wrapped with a buffer

In addition to the light convenience, these are intended to raise visibility that buffering is something you should consider when opening a file, since unbuffered I/O is a common performance footgun to Rust newcomers.

ACP: https://github.com/rust-lang/libs-team/issues/446
Tracking Issue: #130804
2024-09-25 04:57:12 +00:00
Josh Stone
0999b019f8 Dogfood feature(file_buffered) 2024-09-24 14:25:16 -07:00
Lukas Markeffsky
bd31e3ed70 be even more precise about "cast" vs "coercion" 2024-09-24 23:12:02 +02:00
Lukas Markeffsky
46ecb23198 unify dyn* coercions with other pointer coercions 2024-09-24 22:17:55 +02:00
David Wood
207bc77e15
codegen_ssa: consolidate tied feature checking
`rustc_codegen_llvm` and `rustc_codegen_gcc` duplicated logic for
checking if tied target features were partially enabled. This commit
consolidates these checks into `rustc_codegen_ssa` in the
`codegen_fn_attrs` query, which also is run pre-monomorphisation for
each function, which ensures that this check is run for unused functions,
as would be expected.
2024-09-24 15:48:49 +01:00
bors
4cbfcf1b7f Auto merge of #130389 - Luv-Ray:LLVMMDNodeInContext2, r=nikic
llvm: replace some deprecated functions

`LLVMMDStringInContext` and `LLVMMDNodeInContext` are deprecated, replace them with `LLVMMDStringInContext2` and `LLVMMDNodeInContext2`.
Also replace `Value` with `Metadata` in some function signatures for better consistency.
2024-09-24 12:07:48 +00:00
monkeydbobo
802bf71ece Fix up setting strip = true in Cargo.toml makes build scripts fail in release mode on MacOS 2024-09-24 19:51:11 +08:00
Luv-Ray
16093faea8 fix ices on vfe about principal trait 2024-09-23 15:25:52 +08:00
Michael Goulet
c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
John Kåre Alsaker
b7a490ab33 Create _imp__ symbols also when doing ThinLTO 2024-09-22 11:37:21 +02:00
Michael Goulet
2a9525bb90
Rollup merge of #127766 - folkertdev:c-cmse-nonsecure-entry, r=jackh726
add `extern "C-cmse-nonsecure-entry" fn`

tracking issue #75835

in https://github.com/rust-lang/rust/issues/75835#issuecomment-1183517255 it was decided that using an abi, rather than an attribute, was the right way to go for this feature.

This PR adds that ABI and removes the `#[cmse_nonsecure_entry]` attribute. All relevant tests have been updated, some are now obsolete and have been removed.

Error 0775 is no longer generated. It contains the list of targets that support the CMSE feature, and maybe we want to still use this? right now a generic "this abi is not supported on this platform" error is returned when this abi is used on an unsupported platform. On the other hand, users of this abi are likely to be experienced rust users, so maybe the generic error is good enough.
2024-09-21 15:18:55 -04:00
bors
2836482241 Auto merge of #129283 - saethlin:unreachable-allocas, r=scottmcm
Don't alloca for unused locals

We already have a concept of mono-unreachable basic blocks; this is primarily useful for ensuring that we do not compile code under an `if false`. But since we never gave locals the same analysis, a large local only used under an `if false` will still have stack space allocated for it.

There are 3 places we traverse MIR during monomorphization: Inside the collector, `non_ssa_locals`, and the walk to generate code. Unfortunately, https://github.com/rust-lang/rust/pull/129283#issuecomment-2297925578 indicates that we cannot afford the expense of tracking reachable locals during the collector's traversal, so we do need at least two mono-reachable traversals. And of course caching is of no help here because the benchmarks that regress are incr-unchanged; they don't do any codegen.

This fixes the second problem in https://github.com/rust-lang/rust/issues/129282, and brings us anther step toward `const if` at home.
2024-09-21 13:48:14 +00:00
Folkert
5722a80782 remove #[cmse_nonsecure_entry] 2024-09-21 13:05:21 +02:00
Ben Kimock
523f8f8398 Compute reachable locals as part of non_ssa_locals 2024-09-21 01:07:00 -04:00
Ben Kimock
0ea5dc506f Don't alloca for unused locals 2024-09-21 01:06:59 -04:00