about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
AgeCommit message (Collapse)AuthorLines
2024-10-23Rollup merge of #132060 - joshtriplett:innermost-outermost, r=jieyouxuLeón Orell Valerian Liehr-1/+1
"innermost", "outermost", "leftmost", and "rightmost" don't need hyphens These are all standard dictionary words and don't require hyphenation. ----- Encountered an instance of this in error messages and it bugged me, so I figured I'd fix it across the entire codebase.
2024-10-23"innermost", "outermost", "leftmost", and "rightmost" don't need hyphensJosh Triplett-1/+1
These are all standard dictionary words and don't require hyphenation.
2024-10-23get rid of feature list in target feature logicRalf Jung-24/+2
2024-10-23nightly feature tracking: get rid of the per-feature bool fieldsRalf Jung-26/+26
2024-10-21Rollup merge of #130350 - RalfJung:strict-provenance, r=dtolnayMatthias Krüger-2/+5
stabilize Strict Provenance and Exposed Provenance APIs Given that [RFC 3559](https://rust-lang.github.io/rfcs/3559-rust-has-provenance.html) has been accepted, t-lang has approved the concept of provenance to exist in the language. So I think it's time that we stabilize the strict provenance and exposed provenance APIs, and discuss provenance explicitly in the docs: ```rust // core::ptr pub const fn without_provenance<T>(addr: usize) -> *const T; pub const fn dangling<T>() -> *const T; pub const fn without_provenance_mut<T>(addr: usize) -> *mut T; pub const fn dangling_mut<T>() -> *mut T; pub fn with_exposed_provenance<T>(addr: usize) -> *const T; pub fn with_exposed_provenance_mut<T>(addr: usize) -> *mut T; impl<T: ?Sized> *const T { pub fn addr(self) -> usize; pub fn expose_provenance(self) -> usize; pub fn with_addr(self, addr: usize) -> Self; pub fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self; } impl<T: ?Sized> *mut T { pub fn addr(self) -> usize; pub fn expose_provenance(self) -> usize; pub fn with_addr(self, addr: usize) -> Self; pub fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self; } impl<T: ?Sized> NonNull<T> { pub fn addr(self) -> NonZero<usize>; pub fn with_addr(self, addr: NonZero<usize>) -> Self; pub fn map_addr(self, f: impl FnOnce(NonZero<usize>) -> NonZero<usize>) -> Self; } ``` I also did a pass over the docs to adjust them, because this is no longer an "experiment". The `ptr` docs now discuss the concept of provenance in general, and then they go into the two families of APIs for dealing with provenance: Strict Provenance and Exposed Provenance. I removed the discussion of how pointers also have an associated "address space" -- that is not actually tracked in the pointer value, it is tracked in the type, so IMO it just distracts from the core point of provenance. I also adjusted the docs for `with_exposed_provenance` to make it clear that we cannot guarantee much about this function, it's all best-effort. There are two unstable lints associated with the strict_provenance feature gate; I moved them to a new [strict_provenance_lints](https://github.com/rust-lang/rust/issues/130351) feature since I didn't want this PR to have an even bigger FCP. ;) `@rust-lang/opsem` Would be great to get some feedback on the docs here. :) Nominating for `@rust-lang/libs-api.` Part of https://github.com/rust-lang/rust/issues/95228. [FCP comment](https://github.com/rust-lang/rust/pull/130350#issuecomment-2395114536)
2024-10-21move strict provenance lints to new feature gate, remove old feature gatesRalf Jung-1/+0
2024-10-21stabilize Strict Provenance and Exposed ProvenanceRalf Jung-1/+5
This comes with a big docs rewrite.
2024-10-19Get rid of const eval_* and try_eval_* helpersMichael Goulet-7/+11
2024-10-17Allow dropping dyn principalMichael Goulet-2/+3
2024-10-15Rollup merge of #131521 - jdonszelmann:rc, r=joboetMichael Goulet-2/+2
rename RcBox to RcInner for consistency Arc uses ArcInner too (created in collaboration with `@aDotInTheVoid` and `@WaffleLapkin` )
2024-10-11Rollup merge of #129079 - Zoxc:thinlto_imp_symbols, r=wesleywiserMatthias Krüger-1/+7
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-11rename RcBox in other places tooJonathan Dönszelmann-2/+2
2024-10-10Rollup merge of #130308 - davidtwco:tied-target-consolidation, r=wesleywiserMatthias Krüger-3/+73
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-10Rollup merge of #131480 - madsmtm:macos-fix-strip-binary, r=nnethercoteMatthias Krüger-1/+3
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-10Fix hardcoded strip path when cross-compiling from Linux to DarwinMads Marquart-1/+3
2024-10-10Avoid redundant -Wl,-dylib flag when linkingMads Marquart-3/+5
2024-10-08compiler: Factor rustc_target::abi out of cg_ssaJubilee Young-5/+7
2024-10-07Auto merge of #131354 - matthiaskrgr:rollup-hprnng2, r=matthiaskrgrbors-3/+2
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-07Rollup merge of #131344 - nnethercote:ref-Lrc, r=compiler-errorsMatthias Krüger-3/+2
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-07Auto merge of #131235 - ↵bors-3/+3
codemountains:rename-nestedmetaitem-to-metaitemlnner, r=nnethercote Rename `NestedMetaItem` to `MetaItemInner` Fixes #131087 r? `@nnethercote`
2024-10-07Convert `Option<&Lrc<T>>` return types to `Option<&T>`.Nicholas Nethercote-3/+2
It's simpler and more concise.
2024-10-06various fixes for `naked_asm!` implementationFolkert de Vries-6/+7
- 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-06Rename NestedMetaItem to MetaItemInnercodemountains-3/+3
2024-10-04Rollup merge of #131202 - Urgau:wide-ptrs-compiler, r=jieyouxuGuillaume Gomez-14/+14
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-04Rollup merge of #131034 - Urgau:cfg-true-false, r=nnethercoteGuillaume Gomez-1/+1
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-04Use wide pointers consistenly across the compilerUrgau-14/+14
2024-10-03Generate correct symbols.o for sparc-unknown-none-elfJonathan 'theJPster' Pallant-1/+9
Fixes #130172
2024-10-02Rollup merge of #131016 - madsmtm:no-sdk-version-in-object, r=jieyouxuMatthias Krüger-10/+48
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-02Rollup merge of #130863 - compiler-errors:relax-codegen-dyn-assert, r=lcnrMatthias Krüger-6/+54
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-01Use `ast::NestedMetaItem` when evaluating cfg predicateUrgau-1/+1
2024-09-30Unpin `cc` and upgrade to the latest versionTrevor Gross-1/+1
`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-30Relate binders explicitly, do a leak check tooMichael Goulet-14/+31
2024-09-30Relax a debug assertion in codegenMichael Goulet-6/+37
2024-09-29Do not specify an SDK version in object filesMads Marquart-3/+7
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-29Document a bit more how the SDK version actually worksMads Marquart-7/+41
2024-09-28Rollup merge of #130960 - cuviper:cdylib-soname, r=petrochenkovMatthias Krüger-15/+70
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-28Auto merge of #130874 - klensy:bumpme, r=jieyouxubors-2/+2
bump few deps Bumps cargo_metadata, thorin-dwp, windows. Should dedupe some crates around.
2024-09-27Only add an automatic SONAME for Rust dylibsJosh Stone-15/+70
2024-09-27bump few depsklensy-2/+2
cargo_metadata, thorin-dwp, windows
2024-09-26Move Apple linker args from `rustc_target` to `rustc_codegen_ssa`Mads Marquart-1/+132
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-26Auto merge of #130329 - khuey:reorder-constant-spills, r=davidtwcobors-18/+48
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-25Rollup merge of #130781 - monkeydbobo:mdb/fix_up_cross_compile_osx, r=davidtwcoMatthias Krüger-3/+4
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-25Add a debug assertion in codegen that unsize casts of the same principal ↵Michael Goulet-2/+22
trait def id are truly NOPs
2024-09-25Auto merge of #130816 - matthiaskrgr:rollup-jy25phv, r=matthiaskrgrbors-38/+44
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-25Rollup merge of #130734 - Luv-Ray:fix_vfe, r=lcnrMatthias Krüger-38/+44
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-25Auto merge of #130803 - cuviper:file-buffered, r=joshtriplettbors-8/+8
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-24Dogfood `feature(file_buffered)`Josh Stone-8/+8
2024-09-24be even more precise about "cast" vs "coercion"Lukas Markeffsky-7/+7
2024-09-24unify dyn* coercions with other pointer coercionsLukas Markeffsky-1/+1
2024-09-24Test fixing raw-dylibDaniel Paoliello-37/+70