summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/back
AgeCommit message (Collapse)AuthorLines
2023-05-26Rollup merge of #111384 - bmisiak:issue-106021-fix, r=petrochenkovMatthias Krüger-0/+32
Fix linking Mac Catalyst by including LC_BUILD_VERSION in object files Hello. My first rustc PR! Issue #106021 prevents Rust code from being linked into Mac Catalyst applications. Apple's LD has started requiring object files to contain version information about the platform they were built for, such as: * the "deployment target" (minimum supported OS version), * the SDK version * the type of the platform (macOS/iOS/catalyst/tvOS/watchOS all have a different number). This is currently only enforced when building for Mac Catalyst. Rust uses the `object` crate which added support for including this information starting with `0.31.0`. ~~I upgraded it along with `thorin-dwp` so that everything depends on 0.31. Apparently 0.31 [pulls in](https://github.com/gimli-rs/object/issues/463) `ruzstd` due to a [new ELF standard](https://maskray.me/blog/2022-09-09-zstd-compressed-debug-sections) because its `compression` feature is enabled by thorin. If you find this objectionable, let me know what the best way to avoid pulling in those dependencies might be.~~ **(`object` upgraded in https://github.com/rust-lang/rust/pull/111413)** I then added two commits: * The first one adds very basic, hard-coded support for calling `set_macho_build_version` for `-macabi` (Catalyst) targets, where it claims deployment target of Catalyst 14.0 and SDK of 16.2. * The second weaves the versioning through `rust_target::spec::TargetOptions`, so that we can stick to specifying all target-related info in one place. Kudos to ``@ara4n`` for writing [this gist](https://gist.github.com/ara4n/320a53ea768aba51afad4c9ed2168536).
2023-05-25Auto merge of #86844 - bjorn3:global_alloc_improvements, r=pnkfelixbors-1/+12
Support #[global_allocator] without the allocator shim This makes it possible to use liballoc/libstd in combination with `--emit obj` if you use `#[global_allocator]`. This is what rust-for-linux uses right now and systemd may use in the future. Currently they have to depend on the exact implementation of the allocator shim to create one themself as `--emit obj` doesn't create an allocator shim. Note that currently the allocator shim also defines the oom error handler, which is normally required too. Once `#![feature(default_alloc_error_handler)]` becomes the only option, this can be avoided. In addition when using only fallible allocator methods and either `--cfg no_global_oom_handling` for liballoc (like rust-for-linux) or `--gc-sections` no references to the oom error handler will exist. To avoid this feature being insta-stable, you will have to define `__rust_no_alloc_shim_is_unstable` to avoid linker errors. (Labeling this with both T-compiler and T-lang as it originally involved both an implementation detail and had an insta-stable user facing change. As noted above, the `__rust_no_alloc_shim_is_unstable` symbol requirement should prevent unintended dependence on this unstable feature.)
2023-05-25Fix Mac Catalyst linking by adding build versionBrian M-0/+32
Issue #106021 Apple LD requires build versions in object files for Catalyst
2023-05-24Auto merge of #111694 - Amanieu:no-assume-bdynamic, r=petrochenkovbors-12/+12
Don't assume that `-Bdynamic` is the default linker mode In particular this is false when passing `-static` or `-static-pie` to the linker, which changes the default to `-Bstatic`. This PR ensures we explicitly initialize the correct mode when we first need it.
2023-05-21Auto merge of #111675 - Urgau:fix-local-libs-for-native-static-libs, r=bjorn3bors-0/+2
Fix local libs not included when printing native static libs This PR fixes https://github.com/rust-lang/rust/issues/111643 by adding the local used libs to the printed `--print=native-static-libs` output. It seems that `--print=native-static-libs` doesn't have any test, so I added one. It's very simple and doesn't even tries to compile the result to a binary as I don't know how to handle external library linking in CI. (Note that https://github.com/rust-lang/rust/blob/master/tests/run-make/staticlib-dylib-linkage/Makefile does compile to a binary) r? `@bjorn3`
2023-05-19Auto merge of #111641 - michaelwoerister:debugger-visualizer-fixes, r=cjgillotbors-1/+1
Fix dependency tracking for debugger visualizers This PR fixes dependency tracking for debugger visualizer files by changing the `debugger_visualizers` query to an `eval_always` query that scans the AST while it is still available. This way the set of visualizer files is already available when dep-info is emitted. Since the query is turned into an `eval_always` query, dependency tracking will now reliably detect changes to the visualizer script files themselves. TODO: - [x] perf.rlo - [x] Needs a bit more documentation in some places - [x] Needs regression test for the incr. comp. case Fixes https://github.com/rust-lang/rust/issues/111226 Fixes https://github.com/rust-lang/rust/issues/111227 Fixes https://github.com/rust-lang/rust/issues/111295 r? `@wesleywiser` cc `@gibbyfree`
2023-05-17Don't assume that `-Bdynamic` is the default linker modeAmanieu d'Antras-12/+12
In particular this is false when passing `-static` or `-static-pie` to the linker, which changes the default to `-Bstatic`. This PR ensures we explicitly initialize the correct mode when we first need it.
2023-05-17Fix issue #111643 by adding the local used librariesUrgau-0/+2
2023-05-17Rollup merge of #110145 - WaffleLapkin:share_slice_of_bytes, r=NilstriebDylan DPC-5/+4
Share slice of bytes r? `@Nilstrieb` cc `@noamtashma`
2023-05-16Move DebuggerVisualizerFile types from rustc_span to rustc_middleMichael Woerister-1/+1
2023-05-16Remove `MetadataRef` type aliasMaybe Waffle-5/+4
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-1/+1
2023-05-11Prevent insta-stable no alloc shim supportbjorn3-1/+12
You will need to add the following as replacement for the old __rust_* definitions when not using the alloc shim. #[no_mangle] static __rust_no_alloc_shim_is_unstable: u8 = 0;
2023-05-10Auto merge of #106560 - bjorn3:support_staticlib_dylib_linking, r=pnkfelixbors-5/+70
Support linking to rust dylib with --crate-type staticlib This allows for example dynamically linking libstd, while statically linking the user crate into an executable or C dynamic library. For this two unstable flags (`-Z staticlib-allow-rdylib-deps` and `-Z staticlib-prefer-dynamic`) are introduced. Without the former you get an error. The latter is the equivalent to `-C prefer-dynamic` for the staticlib crate type to indicate that dynamically linking is preferred when both options are available, like for libstd. Care must be taken to ensure that no crate ends up being merged into two distinct staticlibs that are linked together. Doing so will cause a linker error at best and undefined behavior at worst. In addition two distinct staticlibs compiled by different rustc may not be combined under any circumstances due to some rustc private symbols not being mangled. To successfully link a staticlib, `--print native-static-libs` can be used while compiling to ask rustc for the linker flags necessary when linking the staticlib. This is an existing flag which previously only listed native libraries. It has been extended to list rust dylibs too. Trying to locate libstd yourself to link against it is not supported and may break if for example the libstd of multiple rustc versions are put in the same directory. For an example on how to use this see the `src/test/run-make-fulldeps/staticlib-dylib-linkage/` test.
2023-05-09Rollup merge of #110304 - cchiw:master, r=davidtwcoDylan DPC-0/+50
Add GNU Property Note Fix #103001 Generates the missing property note: ``` Displaying notes found in: .note.gnu.property Owner Data size Description GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 Properties: x86 feature: IBT ```
2023-05-06Rollup merge of #110985 - Amanieu:normalize_asm_spans, r=b-naberMatthias Krüger-3/+9
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-06Fix spans in LLVM-generated inline asm errorsAmanieu d'Antras-3/+9
Previously, incorrect spans were reported if inline assembly contained CRLF (Windows) line endings. Fixes #110885
2023-05-05rewriting match on endiannessCharisee-9/+6
2023-05-05rewriting match on endiannessCharisee-1/+8
2023-05-05Add GNU Property NoteCharisee-11/+15
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-4/+4
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-05-02Rollup merge of #110955 - fee1-dead-contrib:sus-operation, r=compiler-errorsDylan DPC-4/+3
uplift `clippy::clone_double_ref` as `suspicious_double_ref_op` Split from #109842. r? ``@compiler-errors``
2023-04-30Rollup merge of #110586 - ChrisDenton:msvc-oem-output, r=workingjubileeMatthias Krüger-1/+78
Fix Unreadable non-UTF-8 output on localized MSVC Fixes #35785 by converting non UTF-8 linker output to Unicode using the OEM code page. Before: ```text = note: Non-UTF-8 output: LINK : fatal error LNK1181: cannot open input file \'m\x84rchenhaft.obj\'\r\n ``` After: ```text = note: LINK : fatal error LNK1181: cannot open input file 'märchenhaft.obj' ``` The difference is more dramatic if using a non-ascii language pack for Windows.
2023-04-28uplift `clippy::clone_double_ref` as `suspicious_double_ref_op`Deadbeef-4/+3
2023-04-27only error with +whole-archive,+bundle for rlibsBe Wilson-1/+4
Fixes https://github.com/rust-lang/rust/issues/110912 Checking `flavor == RlibFlavor::Normal` was accidentally lost in 601fc8b36b1962285e371cf3c54eeb3b1b9b3a74 https://github.com/rust-lang/rust/pull/105601 That caused combining +whole-archive and +bundle link modifiers on non-rlib crates to fail with a confusing error message saying that combination is unstable for rlibs. In particular, this caused the build to fail when +whole-archive was used on staticlib crates, even though +whole-archive effectively does nothing on non-bin crates because the final linker invocation is left to an external build system.
2023-04-27Abstract `MultiByteToWideChar`Chris Denton-33/+57
2023-04-27Fix Unreadable non-UTF-8 output on localized MSVCChris Denton-1/+54
Fixes #35785 by converting non UTF-8 linker output to Unicode using the OEM code page. Before: ```text = note: Non-UTF-8 output: LINK : fatal error LNK1181: cannot open input file \'m\x84rchenhaft.obj\'\r\n ``` After: ```text = note: LINK : fatal error LNK1181: cannot open input file 'märchenhaft.obj' ``` The difference is more dramatic if using a non-ascii language pack for Visual Studio.
2023-04-25Revert "Remove #[alloc_error_handler] from the compiler and library"Matthias Krüger-1/+1
This reverts commit abc0660118cc95f47445fd33502a11dd448f5968.
2023-04-22Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwcobors-1/+1
Report allocation errors as panics OOM is now reported as a panic but with a custom payload type (`AllocErrorPanicPayload`) which holds the layout that was passed to `handle_alloc_error`. This should be review one commit at a time: - The first commit adds `AllocErrorPanicPayload` and changes allocation errors to always be reported as panics. - The second commit removes `#[alloc_error_handler]` and the `alloc_error_hook` API. ACP: https://github.com/rust-lang/libs-team/issues/192 Closes #51540 Closes #51245
2023-04-22Add GNU Property NoteCharisee-0/+42
2023-04-20Remove WithOptconstParam.Camille GILLOT-1/+1
2023-04-19Support `--print native-static-libs` with rust dylibsbjorn3-5/+70
2023-04-19Recognize AIX style archive kindQiu Chaofan-0/+1
2023-04-17Spelling - compilerJosh Soref-1/+1
* account * achieved * advising * always * ambiguous * analysis * annotations * appropriate * build * candidates * cascading * category * character * clarification * compound * conceptually * constituent * consts * convenience * corresponds * debruijn * debug * debugable * debuggable * deterministic * discriminant * display * documentation * doesn't * ellipsis * erroneous * evaluability * evaluate * evaluation * explicitly * fallible * fulfill * getting * has * highlighting * illustrative * imported * incompatible * infringing * initialized * into * intrinsic * introduced * javascript * liveness * metadata * monomorphization * nonexistent * nontrivial * obligation * obligations * offset * opaque * opportunities * opt-in * outlive * overlapping * paragraph * parentheses * poisson * precisely * predecessors * predicates * preexisting * propagated * really * reentrant * referent * responsibility * rustonomicon * shortcircuit * simplifiable * simplifications * specify * stabilized * structurally * suggestibility * translatable * transmuting * two * unclosed * uninhabited * visibility * volatile * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-16Remove #[alloc_error_handler] from the compiler and libraryAmanieu d'Antras-1/+1
2023-04-12Rollup merge of #110153 - DaniPopes:compiler-typos, r=NilstriebMatthias Krüger-1/+1
Fix typos in compiler I ran [`typos -w compiler`](https://github.com/crate-ci/typos) to fix typos in the `compiler` directory. Refs #110150
2023-04-11Rollup merge of #96971 - zhaixiaojuan:master, r=wesleywiserMichael Goulet-0/+5
Initial support for loongarch64-unknown-linux-gnu Hi, We hope to add a new port in rust for LoongArch. LoongArch intro LoongArch is a RISC style ISA which is independently designed by Loongson Technology in China. It is divided into two versions, the 32-bit version (LA32) and the 64-bit version (LA64). LA64 applications have application-level backward binary compatibility with LA32 applications. LoongArch is composed of a basic part (Loongson Base) and an expanded part. The expansion part includes Loongson Binary Translation (LBT), Loongson VirtualiZation (LVZ), Loongson SIMD EXtension (LSX) and Loongson Advanced SIMD EXtension(LASX). Currently the LA464 processor core supports LoongArch ISA and the Loongson 3A5000 processor integrates 4 64-bit LA464 cores. LA464 is a four-issue 64-bit high-performance processor core. It can be used as a single core for high-end embedded and desktop applications, or as a basic processor core to form an on-chip multi-core system for server and high-performance machine applications. Documentations: ISA: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html ABI: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html More docs can be found at: https://loongson.github.io/LoongArch-Documentation/README-EN.html Since last year, we have locally adapted two versions of rust, rust1.41 and rust1.57, and completed the test locally. I'm not sure if I'm submitting all the patches at once, so I split up the patches and here's one of the commits
2023-04-10Fix typos in compilerDaniPopes-1/+1
2023-04-09Migrate `sess.opts.tests` uses to `sess.is_test_crate()`blyxyas-1/+1
2023-04-08Auto merge of #109971 - WaffleLapkin:yeet_ownership, r=Nilstriebbors-6/+5
Yeet `owning_ref` Based on the discussions from https://github.com/rust-lang/rust/pull/109948 This replaces `owning_ref` with a far simpler & safer abstraction. Fixes #109974
2023-04-06Use `FnOnce` for `slice_owned` instead of `Fn`Maybe Waffle-1/+1
2023-04-05Use `OwnedSlice` instead of `owning_ref`Maybe Waffle-7/+6
2023-04-04loongarch64: calculate the ELF header flagszhaixiaojuan-0/+4
2023-04-04Add loongarch64 to fn create_object_filezhaixiaojuan-0/+1
2023-03-31Preserve, clarify, and extend debug informationJulia Tatz-1/+4
`-Cdebuginfo=1` was never line tables only and can't be due to backwards compatibility issues. This was clarified and an option for line tables only was added. Additionally an option for line info directives only was added, which is well needed for some targets. The debug info options should now behave the same as clang's debug info options.
2023-03-29Auto merge of #108089 - Zoxc:windows-tls, r=bjorn3bors-7/+36
Support TLS access into dylibs on Windows This allows access to `#[thread_local]` in upstream dylibs on Windows by introducing a MIR shim to return the address of the thread local. Accesses that go into an upstream dylib will call the MIR shim to get the address of it. `convert_tls_rvalues` is introduced in `rustc_codegen_ssa` which rewrites MIR TLS accesses to dummy calls which are replaced with calls to the MIR shims when the dummy calls are lowered to backend calls. A new `dll_tls_export` target option enables this behavior with a `false` value which is set for Windows platforms. This fixes https://github.com/rust-lang/rust/issues/84933.
2023-03-29Support TLS access into dylibs on WindowsJohn Kåre Alsaker-7/+36
2023-03-28[fix] don't panic on failure to acquire jobserver tokenDaniil Belov-2/+2
2023-03-27Bless tidyMaybe Waffle-1/+1
2023-03-24Rollup merge of #109515 - bzEq:aix-linker, r=petrochenkovMatthias Krüger-0/+174
Add AixLinker to support linking on AIX AIX linker has a different cli style from other existing linkers. It is documented in https://www.ibm.com/docs/en/aix/7.1?topic=l-ld-command.