about summary refs log tree commit diff
path: root/src/librustc_codegen_ssa/back/write.rs
AgeCommit message (Collapse)AuthorLines
2020-05-04Auto merge of #71754 - alexcrichton:no-bitcode-in-cache, r=nnethercotebors-21/+6
Don't copy bytecode files into the incr. comp. cache. It's no longer necessary now that bitcode is embedded into object files. This change meant that `WorkProductFileKind::Bytecode` is no longer necessary, which means that type is no longer necessary, which allowed several places in the code to become simpler. This commit was written by @nnethercote in https://github.com/rust-lang/rust/pull/70458 but that didn't land. In the meantime though we managed to land it in https://github.com/rust-lang/rust/pull/71528 and that doesn't seem to be causing too many fires, so I'm re-sending this patch!
2020-05-02cleanup: `config::CrateType` -> `CrateType`Vadim Petrochenkov-7/+6
2020-05-01Rename `bitcode-in-rlib` option to `embed-bitcode`Alex Crichton-2/+2
This commit finishes work first pioneered in #70458 and started in #71528. The `-C bitcode-in-rlib` option, which has not yet reached stable, is renamed to `-C embed-bitcode` since that more accurately reflects what it does now anyway. Various tests and such are updated along the way as well. This'll also need to be backported to the beta channel to ensure we don't accidentally stabilize `-Cbitcode-in-rlib` as well.
2020-05-01Don't copy bytecode files into the incr. comp. cache.Nicholas Nethercote-21/+6
It's no longer necessary now that bitcode is embedded into object files. This change meant that `WorkProductFileKind::Bytecode` is no longer necessary, which means that type is no longer necessary, which allowed several places in the code to become simpler.
2020-04-30Auto merge of #70175 - Amanieu:remove_nlp, r=pnkfelixbors-2/+2
Remove -Z no-landing-pads flag Since #67502, `-Z no-landing-pads` will cause all attempted unwinds to abort since we don't generate a `try` / `catch`. This previously worked because `__rust_try` was located in libpanic_unwind which is always compiled with `-C panic=unwind`, but `__rust_try` is now directly inline into the crate that uses `catch_unwind`. As such, `-Z no-landing-pads` is now mostly useless and people should use `-C panic=abort` instead.
2020-04-29Auto merge of #71528 - alexcrichton:no-more-bitcode, r=nnethercotebors-29/+3
Store LLVM bitcode in object files, not compressed This commit is an attempted resurrection of #70458 where LLVM bitcode emitted by rustc into rlibs is stored into object file sections rather than in a separate file. The main rationale for doing this is that when rustc emits bitcode it will no longer use a custom compression scheme which makes it both easier to interoperate with existing tools and also cuts down on compile time since this compression isn't happening. The blocker for this in #70458 turned out to be that native linkers didn't handle the new sections well, causing the sections to either trigger bugs in the linker or actually end up in the final linked artifact. This commit attempts to address these issues by ensuring that native linkers ignore the new sections by inserting custom flags with module-level inline assembly. Note that this does not currently change the API of the compiler at all. The pre-existing `-C bitcode-in-rlib` flag is co-opted to indicate whether the bitcode should be present in the object file or not. Finally, note that an important consequence of this commit, which is also one of its primary purposes, is to enable rustc's `-Clto` bitcode loading to load rlibs produced with `-Clinker-plugin-lto`. The goal here is that when you're building with LTO Cargo will tell rustc to skip codegen of all intermediate crates and only generate LLVM IR. Today rustc will generate both object code and LLVM IR, but the object code is later simply thrown away, wastefully.
2020-04-29Store LLVM bitcode in object files, not compressedAlex Crichton-29/+3
This commit is an attempted resurrection of #70458 where LLVM bitcode emitted by rustc into rlibs is stored into object file sections rather than in a separate file. The main rationale for doing this is that when rustc emits bitcode it will no longer use a custom compression scheme which makes it both easier to interoperate with existing tools and also cuts down on compile time since this compression isn't happening. The blocker for this in #70458 turned out to be that native linkers didn't handle the new sections well, causing the sections to either trigger bugs in the linker or actually end up in the final linked artifact. This commit attempts to address these issues by ensuring that native linkers ignore the new sections by inserting custom flags with module-level inline assembly. Note that this does not currently change the API of the compiler at all. The pre-existing `-C bitcode-in-rlib` flag is co-opted to indicate whether the bitcode should be present in the object file or not. Finally, note that an important consequence of this commit, which is also one of its primary purposes, is to enable rustc's `-Clto` bitcode loading to load rlibs produced with `-Clinker-plugin-lto`. The goal here is that when you're building with LTO Cargo will tell rustc to skip codegen of all intermediate crates and only generate LLVM IR. Today rustc will generate both object code and LLVM IR, but the object code is later simply thrown away, wastefully.
2020-04-29Remove Session::no_landing_pads()Amanieu d'Antras-2/+2
2020-04-26codegen_llvm: Simplify logic for relaxing PIC into PIEVadim Petrochenkov-1/+1
2020-04-25Rollup merge of #71364 - Amanieu:zprofile_compiler_builtins, r=cramertjDylan DPC-5/+18
Ignore -Zprofile when building compiler_builtins #70846 made the `compiler_builtins` crate ignore the default codegen-units setting and instead always split each function into a different codegen unit. This unfortunately breaks `-Zprofile` which requires a single codegen unit per crate (see #71283). You can notice this when building with `cargo -Zbuild-std` and `RUSTFLAGS` containing `-Zprofile`. This PR works around this issue by just ignoring `-Zprofile` for the `compiler-builtins` crate.
2020-04-22Add a new option `-Cbitcode-in-rlib`.Nicholas Nethercote-1/+2
It defaults to true, but Cargo will set this to false whenever it can to reduce compile times.
2020-04-20Ignore -Zprofile when building compiler_builtinsAmanieu d'Antras-5/+18
2020-04-19Replace uses of `parse_opt_*` with `parse_*` where possible.Nicholas Nethercote-1/+1
This lets us specify the default at the options declaration point, instead of using `.unwrap(default)` or `None | Some(default)` at some use point far away. It also makes the code more concise.
2020-04-11Rollup merge of #70644 - nnethercote:clean-up-ModuleConfig-init, ↵Dylan DPC-162/+140
r=Mark-Simulacrum Clean up `ModuleConfig` initialization Because it's currently a mess. r? @Mark-Simulacrum
2020-04-07Use assoc integer constants in librustc_*Linus Färnstrand-1/+1
2020-04-01Rename `modules_config` as `regular_config`.Nicholas Nethercote-4/+4
That way it matches `ModuleKind::Regular`.
2020-04-01Improve `ModuleConfig` initialization.Nicholas Nethercote-152/+137
There are three `ModuleConfigs`, one for each `ModuleKind`. The code to initialized them is spaghetti imperative code that sets each field to a default value and then modifies many fields in complicated ways. This makes it very hard to tell what value ends up in each field in each config. For example, the `modules_config.emit_pre_lto_bc` field is set twice, which means it can be set to true and then incorrectly set back to false. (This probably hasn't been noticed because it happens in a very obscure case.) This commit changes the code to a declarative style in which `ModuleConfig::new` initializes all fields and then they are never changed again. This is slightly more concise and much easier to read. (And it fixes the abovementioned `emit_pre_lto_bc` error as well.)
2020-04-01Remove some dead code.Nicholas Nethercote-7/+0
The condition checks if `sess.opts.output_types` doesn't contain `OutputType::Assembly` within a match arm that is only reached if `sess.opts.output_types` contains `OutputType::Assembly`.
2020-03-30rustc -> rustc_middle part 3 (rustfmt)Mazdak Farrokhzad-4/+4
2020-03-30rustc -> rustc_middle part 2Mazdak Farrokhzad-4/+4
2020-03-27Remove `no_integrated_as` mode.Nicholas Nethercote-65/+1
Specifically, remove both `-Z no_integrated_as` and `TargetOptions::no_integrated_as`. The latter was only used for the `msp430_none_elf` platform, for which it's no longer required.
2020-03-26Introduce `EmitObj`.Nicholas Nethercote-32/+49
Currently, there are three fields in `ModuleConfig` that dictate how object files are emitted: `emit_obj`, `obj_is_bitcode`, and `embed_bitcode`. Some of the combinations of these fields are nonsensical, in particular having both `obj_is_bitcode` and `embed_bitcode` true at the same time. Also, currently: - we needlessly emit and then delete a bytecode file if `obj_is_bitcode` is true but `emit_obj` is false; - we needlessly embed bitcode in the LLVM module if `embed_bitcode` is true and `emit_obj` is false. This commit combines the three fields into one, with a new type `EmitObj` (and the auxiliary `BitcodeSection`) which can encode five different possibilities. In the old code, `set_flags` would set `obj_is_bitcode` and `embed_bitcode` on all three of the configs (`modules`, `allocator`, `metadata`) if the relevant other conditions were met, even if no object code needed to be emitted for one or more of them. Whereas `start_async_codegen` would set `emit_obj`, but only for those configs that need it. In the new code, `start_async_codegen` does all the work of setting `emit_obj`, and it only does that for the configs that need it. `set_flags` no longer sets anything related to object file emission.
2020-03-25Remove `TargetOptions::embed_bitcode`.Nicholas Nethercote-9/+8
It's unused by any existing targets, and soon we'll be embedding full bitcode by default anyway.
2020-03-24Rollup merge of #70289 - nnethercote:refactor-codegen, r=eddybMazdak Farrokhzad-17/+22
Refactor `codegen` `codegen` in `src/librustc_codegen_llvm/back/write.rs` is long and has complex control flow. These commits refactor it and make it easier to understand.
2020-03-23Combine `ModuleConfig::embed_bitcode{,_marker}`.Nicholas Nethercote-14/+22
Because the `(true, true)` combination isn't valid.
2020-03-22don't create variable bindings just to return the bound value immediately ↵Matthias Krüger-4/+2
(clippy::let_and_return)
2020-03-19Remove unused `ModuleConfig::emit_lto_bc` field.Nicholas Nethercote-3/+0
2020-03-16use direct imports for `rustc::{lint, session}`.Mazdak Farrokhzad-4/+4
2020-03-14Update `krate_attrs` and `get_module`John Kåre Alsaker-2/+2
2020-03-06fix various typosMatthias Krüger-1/+1
2020-03-04Don't use "if let" bindings to only check a value and not actually bind ↵Matthias Krüger-1/+1
anything. For example: `if let Some(_) = foo() {}` can be reduced to `if foo().is_some() {}` (clippy::redundant_pattern_matching)
2020-02-29Rename `syntax` to `rustc_ast` in source codeVadim Petrochenkov-1/+1
2020-02-28simplify condition in start_executing_work()Matthias Krüger-5/+5
2020-02-28use is_empty() instead of len() == x to determine if structs are empty.Matthias Krüger-6/+6
2020-02-12Add support for new pass managerNikita Popov-0/+3
The new pass manager can be enabled using -Z new-llvm-pass-manager=on.
2020-02-10self-profile: Support arguments for generic_activities.Michael Woerister-6/+13
2020-01-23Make ExportedSymbols type more local because it's not supposed to beMichael Woerister-1/+5
used outside of the LLVM backend.
2020-01-20Make sure that all upstream generics get re-exported from Rust dylibs.Michael Woerister-2/+2
2020-01-11Auto merge of #67458 - ↵bors-8/+18
pnkfelix:fix-66530-by-propagating-fatal-error-from-worker, r=matthewjasper When a codegen worker has a FatalError, propagate it instead of ICE'ing. Fix #66530
2020-01-09Label unmarked timeJohn Kåre Alsaker-2/+7
2020-01-09Change -Z time event naming scheme and make them generic activitiesJohn Kåre Alsaker-1/+1
2020-01-08Remove `-Z continue-parse-after-error`Vadim Petrochenkov-1/+0
2020-01-05Remove rustc_hir reexports in rustc::hir.Mazdak Farrokhzad-1/+1
2020-01-05Use self profile infrastructure for -Z time and -Z time-passesJohn Kåre Alsaker-32/+19
2020-01-04canonicalize FxHash{Map,Set} importsMazdak Farrokhzad-1/+1
2020-01-01Rename `syntax_pos` to `rustc_span` in source codeVadim Petrochenkov-3/+3
2019-12-30When a codegen worker has a FatalError, propagate it instead of ICE'ing.Felix S. Klock II-8/+18
2019-12-22Format the worldMark Rousskov-292/+275
2019-12-03Move cgu_reuse_tracker to librustc_sessionMark Rousskov-1/+1
2019-12-03Decouple CguReuseTracker from SessionMark Rousskov-1/+1