about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2023-02-22various: translation resources from cg backendDavid Wood-0/+4
Extend `CodegenBackend` trait with a function returning the translation resources from the codegen backend, which can be added to the complete list of resources provided to the emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22errors: generate typed identifiers in each crateDavid Wood-1/+4
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-30session: diagnostic migration lint on more fnsDavid Wood-5/+6
Apply the diagnostic migration lint to more functions on `Session`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-11-09Port diagnostics created by `Handler`SLASHLogin-1/+4
2022-11-09Port unknown feature diagnostic to the new frameworkSLASHLogin-0/+1
2022-10-31Rewrite implementation of `#[alloc_error_handler]`Amanieu d'Antras-2/+2
The new implementation doesn't use weak lang items and instead changes `#[alloc_error_handler]` to an attribute macro just like `#[global_allocator]`. The attribute will generate the `__rg_oom` function which is called by the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom` function is defined in any crate then the compiler shim will call `__rdl_oom` in the alloc crate which will simply panic. This also fixes link errors with `-C link-dead-code` with `default_alloc_error_handler`: `__rg_oom` was previously defined in the alloc crate and would attempt to reference the `oom` lang item, even if it didn't exist. This worked as long as `__rg_oom` was excluded from linking since it was not called. This is a prerequisite for the stabilization of `default_alloc_error_handler` (#102318).
2022-10-01Remove unused target_cpu and tune_cpu methods from ExtraBackendMethodsbjorn3-6/+0
2022-10-01Remove unused Context assoc type from WriteBackendMethodsbjorn3-1/+0
2022-09-26remove cfg(bootstrap)Pietro Albini-1/+0
2022-09-15Only enable the let_else feature on bootstrapest31-1/+1
On later stages, the feature is already stable. Result of running: rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-01Directly use the `instrument` macro instead of its full pathOli Scherer-0/+2
2022-08-29Revert let_chains stabilizationNilstrieb-0/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. This is the revert against master, the beta revert was already done in #100538.
2022-08-12Adjust cfgsMark Rousskov-1/+0
2022-07-28Introduce an ArchiveBuilderBuilderbjorn3-2/+2
This avoids monomorphizing all linker code for each codegen backend and will allow passing in extra information to the archive builder from the codegen backend.
2022-07-16Stabilize `let_chains`Caio-1/+1
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-1/+1
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-07-13Rollup merge of #99155 - Amanieu:unstable-target-features, r=davidtwcoDylan DPC-2/+2
Keep unstable target features for asm feature checking Inline assembly uses the target features to determine which registers are available on the current target. However it needs to be able to access unstable target features for this. Fixes #99071
2022-07-11Keep unstable target features for asm feature checkingAmanieu d'Antras-2/+2
Inline assembly uses the target features to determine which registers are available on the current target. However it needs to be able to access unstable target features for this. Fixes #99071
2022-06-28Avoid unnecessary string interning for const_strbjorn3-0/+1
2022-06-03Fully stabilize NLLJack Huey-1/+0
2022-05-28Fix documentation of basic stack protectorNikita Popov-2/+2
A stack protector is used for N >= 8, not N > 8.
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-1/+0
2022-05-04Stabilize `bool::then_some`Josh Triplett-1/+0
2022-04-30Merge new_metadata into codegen_allocatorbjorn3-7/+6
2022-04-30Remove config parameter of optimize_fat and avoid interior mutability for modulebjorn3-3/+2
2022-04-30Let LtoModuleCodegen::optimize take self by valuebjorn3-1/+1
2022-04-30Rename run_lto_pass_manager to optimize_fat and remove thin parameterbjorn3-9/+8
2022-03-25Skip needless bitset for debuginfoJubilee Young-0/+1
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-3/+3
2022-03-01Querify `global_backend_features`Simonas Kazlauskas-1/+9
At the very least this serves to deduplicate the diagnostics that are output about unknown target features provided via CLI.
2022-02-25Auto merge of #94290 - Mark-Simulacrum:bump-bootstrap, r=pietroalbinibors-1/+1
Bump bootstrap to 1.60 This bumps the bootstrap compiler to 1.60 and cleans up cfgs and Span's rustc_pass_by_value (enabled by the bootstrap bump).
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1
2022-02-21debuginfo: Simplify TypeMap used during LLVM debuginfo generation.Michael Woerister-0/+4
The previous implementation was written before types were properly normalized for code generation and had to assume a more complicated relationship between types and their debuginfo -- generating separate identifiers for debuginfo nodes that were based on normalized types. Since types are now already normalized, we can use them as identifiers for debuginfo nodes.
2022-02-01add a rustc::query_stability lintlcnr-0/+1
2022-01-18Use let_else in even more placesest31-0/+1
2021-12-16Remove `in_band_lifetimes` from `rustc_codegen_llvm`LegionMammal978-1/+0
See #91867 for more information.
2021-12-15Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcmMatthias Krüger-1/+0
Stabilize `iter::zip` Hello all! As the tracking issue (#83574) for `iter::zip` completed the final commenting period without any concerns being raised, I hereby submit this stabilization PR on the issue. As the pull request that introduced the feature (#82917) states, the `iter::zip` function is a shorter way to zip two iterators. As it's generally a quality-of-life/ergonomic improvement, it has been integrated into the codebase without any trouble, and has been used in many places across the rust compiler and standard library since March without any issues. For more details, I would refer to `@cuviper's` original PR, or the [function's documentation](https://doc.rust-lang.org/std/iter/fn.zip.html).
2021-12-15Rollup merge of #91868 - tmiasko:llvm-time-trace-out, r=oli-obkMatthias Krüger-1/+3
Use `OutputFilenames` to generate output file for `-Zllvm-time-trace` The resulting profile will include the crate name and will be stored in the `--out-dir` directory. This implementation makes it convenient to use LLVM time trace together with cargo, in the contrast to the previous implementation which would overwrite profiles or store them in `.cargo/registry/..`.
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-12-13Stabilize const_cstr_uncheckedKonrad Borowski-1/+0
2021-12-13Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`Tomasz Miąsko-1/+3
The resulting profile will include the crate name and will be stored in the `--out-dir` directory. This implementation makes it convenient to use LLVM time trace together with cargo, in the contrast to the previous implementation which would overwrite profiles or store them in `.cargo/registry/..`.
2021-12-07Use object crate for .rustc metadata generationNikita Popov-8/+0
We already use the object crate for generating uncompressed .rmeta metadata object files. This switches the generation of compressed .rustc object files to use the object crate as well. These have slightly different requirements in that .rmeta should be completely excluded from any final compilation artifacts, while .rustc should be part of shared objects, but not loaded into memory. The primary motivation for this change is #90326: In LLVM 14, the current way of setting section flags (and in particular, preventing the setting of SHF_ALLOC) will no longer work. There are other ways we could work around this, but switching to the object crate seems like the most elegant, as we already use it for .rmeta, and as it makes this independent of the codegen backend. In particular, we don't need separate handling in codegen_llvm and codegen_gcc. codegen_cranelift should be able to reuse the implementation as well, though I have omitted that here, as it is not based on codegen_ssa. This change mostly extracts the existing code for .rmeta handling to allow using it for .rustc as well, and adjust the codegen infrastructure to handle the metadata object file separately: We no longer create a backend-specific module for it, and directly produce the compiled module instead. This does not fix #90326 by itself yet, as .llvmbc will need to be handled separately.
2021-11-22add rustc option for using LLVM stack smash protectionBenjamin A. Bjørnseth-0/+25
LLVM has built-in heuristics for adding stack canaries to functions. These heuristics can be selected with LLVM function attributes. This patch adds a rustc option `-Z stack-protector={none,basic,strong,all}` which controls the use of these attributes. This gives rustc the same stack smash protection support as clang offers through options `-fno-stack-protector`, `-fstack-protector`, `-fstack-protector-strong`, and `-fstack-protector-all`. The protection this can offer is demonstrated in test/ui/abi/stack-protector.rs. This fills a gap in the current list of rustc exploit mitigations (https://doc.rust-lang.org/rustc/exploit-mitigations.html), originally discussed in #15179. Stack smash protection adds runtime overhead and is therefore still off by default, but now users have the option to trade performance for security as they see fit. An example use case is adding Rust code in an existing C/C++ code base compiled with stack smash protection. Without the ability to add stack smash protection to the Rust code, the code base artifacts could be exploitable in ways not possible if the code base remained pure C/C++. Stack smash protection support is present in LLVM for almost all the current tier 1/tier 2 targets: see test/assembly/stack-protector/stack-protector-target-support.rs. The one exception is nvptx64-nvidia-cuda. This patch follows clang's example, and adds a warning message printed if stack smash protection is used with this target (see test/ui/stack-protector/warn-stack-protector-unsupported.rs). Support for tier 3 targets has not been checked. Since the heuristics are applied at the LLVM level, the heuristics are expected to add stack smash protection to a fraction of functions comparable to C/C++. Some experiments demonstrating how Rust code is affected by the different heuristics can be found in test/assembly/stack-protector/stack-protector-heuristics-effect.rs. There is potential for better heuristics using Rust-specific safety information. For example it might be reasonable to skip stack smash protection in functions which transitively only use safe Rust code, or which uses only a subset of functions the user declares safe (such as anything under `std.*`). Such alternative heuristics could be added at a later point. LLVM also offers a "safestack" sanitizer as an alternative way to guard against stack smashing (see #26612). This could possibly also be included as a stack-protection heuristic. An alternative is to add it as a sanitizer (#39699). This is what clang does: safestack is exposed with option `-fsanitize=safe-stack`. The options are only supported by the LLVM backend, but as with other codegen options it is visible in the main codegen option help menu. The heuristic names "basic", "strong", and "all" are hopefully sufficiently generic to be usable in other backends as well. Reviewed-by: Nikita Popov <nikic@php.net> Extra commits during review: - [address-review] make the stack-protector option unstable - [address-review] reduce detail level of stack-protector option help text - [address-review] correct grammar in comment - [address-review] use compiler flag to avoid merging functions in test - [address-review] specify min LLVM version in fortanix stack-protector test Only for Fortanix test, since this target specifically requests the `--x86-experimental-lvi-inline-asm-hardening` flag. - [address-review] specify required LLVM components in stack-protector tests - move stack protector option enum closer to other similar option enums - rustc_interface/tests: sort debug option list in tracking hash test - add an explicit `none` stack-protector option Revert "set LLVM requirements for all stack protector support test revisions" This reverts commit a49b74f92a4e7d701d6f6cf63d207a8aff2e0f68.
2021-11-05Initialize LLVM time trace profiler on each code generation threadTomasz Miąsko-0/+49
In https://reviews.llvm.org/D71059 LLVM 11, the time trace profiler was extended to support multiple threads. `timeTraceProfilerInitialize` creates a thread local profiler instance. When a thread finishes `timeTraceProfilerFinishThread` moves a thread local instance into a global collection of instances. Finally when all codegen work is complete `timeTraceProfilerWrite` writes data from the current thread local instance and the instances in global collection of instances. Previously, the profiler was intialized on a single thread only. Since this thread performs no code generation on its own, the resulting profile was empty. Update LLVM codegen to initialize & finish time trace profiler on each code generation thread.
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-1/+0
2021-10-15allow `potential_query_instability` everywherelcnr-0/+1
2021-10-01Fix clippy lintsGuillaume Gomez-1/+1
2021-10-01Rollup merge of #88820 - hlopko:add_pie_relocation_model, r=petrochenkovManish Goregaokar-3/+10
Add `pie` as another `relocation-model` value MCP: https://github.com/rust-lang/compiler-team/issues/461
2021-10-01Add `pie` as another `relocation-model` valueMarcel Hlopko-3/+10
2021-09-30Move EncodedMetadata to rustc_metadata.Camille GILLOT-1/+1