summary refs log tree commit diff
path: root/src/librustc_codegen_ssa/back
AgeCommit message (Collapse)AuthorLines
2020-04-20Auto merge of #70729 - nnethercote:a-big-options-clean-up, r=petrochenkovbors-19/+6
A big options clean-up Lots of improvements here. r? @Centril
2020-04-19Dogfood more or_patterns in the compilerJosh Stone-3/+5
2020-04-19Replace uses of `parse_opt_*` with `parse_*` where possible.Nicholas Nethercote-19/+6
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-16Rollup merge of #71145 - pfmooney:illumos-triple, r=nagisaDylan DPC-1/+1
Add illumos triple This fixes rust-lang/rust#55553 and adds support for `illumos` as a `target_os` on `x86_64`. In addition to the compile spec and libstd additions, several library dependencies have been bumped in order to permit working builds of cargo and rustup for the new target. Work originally started by @jasonbking, with subsequent additions by @pfmooney and @jclulow.
2020-04-14Add illumos triplePatrick Mooney-1/+1
Co-Authored-By: Jason King <jason.brian.king@gmail.com> Co-Authored-By: Joshua M. Clulow <jmc@oxide.computer>
2020-04-13linker: Pass `/NODEFAULTLIB` in a more regular wayVadim Petrochenkov-16/+3
2020-04-13rustc_target: Make sure lld-link is treated as link.exe by defaultVadim Petrochenkov-2/+4
The differences if they are discovered will need to be explicitly documented
2020-04-11Auto merge of #71031 - Dylan-DPC:rollup-zr8hh86, r=Dylan-DPCbors-162/+140
Rollup of 5 pull requests Successful merges: - #70644 (Clean up `ModuleConfig` initialization) - #70937 (Fix staticlib name for *-pc-windows-gnu targets) - #70996 (Add or_insert_with_key to Entry of HashMap/BTreeMap) - #71020 (Store UNICODE_VERSION as a tuple) - #71021 (Use write!-style syntax for MIR assert terminator) Failed merges: r? @ghost
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-11Auto merge of #70161 - cjgillot:query-arena, r=nikomatsakisbors-4/+3
Allocate some query results on an arena This avoids a cloning few `Lrc` and `Vec`s in the queries.
2020-04-09Rollup merge of #70868 - petrochenkov:linkorder, r=nagisa,mati865Mazdak Farrokhzad-261/+413
rustc_codegen_ssa: Refactor construction of linker arguments And add comments. This PR doesn't reorder any linker arguments and therefore shouldn't contain any observable changes. The next goal here is to - Factor out order-independent linker arguments in the compiler code and in target specifications and pass them together. Such arguments generally apply to the whole linking session or the produced linking result rather to individual object files or libraries. - Figure out where exactly among the remaining order-dependent arguments we should place customization points like `-C link-args` and `-Z pre-link-args`. - Possibly provide command line opt-outs for options that are currently passed unconditionally (like CRT objects or arguments defined by the target spec). - Document and stabilize the customization points that are not yet stable (https://github.com/rust-lang/rust/pull/70505).
2020-04-07linker: Some minor code cleanupVadim Petrochenkov-58/+38
2020-04-07Use assoc integer constants in librustc_*Linus Färnstrand-1/+1
2020-04-07linker: Factor out more parts of `linker_with_args` and add some docsVadim Petrochenkov-121/+183
2020-04-07linker: Add more markup and comments to code producing linker argumentsVadim Petrochenkov-23/+61
2020-04-07linker: Factor out addition of pre-, post- and late link argsVadim Petrochenkov-35/+82
2020-04-07linker: Factor out linking of pre- and post-link objectsVadim Petrochenkov-23/+37
2020-04-07linker: Combine argument building into a single functionVadim Petrochenkov-115/+118
2020-04-07linker: Make argument building interface in `trait Linker` richerVadim Petrochenkov-24/+32
by redirecting everything to `Command`
2020-04-05Remove Arcs in queries.Camille GILLOT-4/+3
2020-04-04Do not lose or reorder user-provided linker argumentsVadim Petrochenkov-16/+8
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-15/+17
2020-03-30rustc -> rustc_middle part 2Mazdak Farrokhzad-17/+17
2020-03-28Auto merge of #70095 - jsgf:link-native, r=nagisabors-3/+10
Implement -Zlink-native-libraries This implements a flag `-Zlink-native-libraries=yes/no`. If set to true/yes, or unspecified, then native libraries referenced via `#[link]` attributes will be put on the linker line (ie, unchanged behaviour). If `-Zlink-native-libraries=no` is specified then rustc will not add the native libraries to the link line. The assumption is that the outer build system driving the build already knows about the native libraries and will specify them to the linker directly (for example via `-Clink-arg=`). Addresses issue #70093
2020-03-27Rollup merge of #70345 - nnethercote:rm-no_integrated_as, r=alexcrichtonMazdak Farrokhzad-65/+1
Remove `no_integrated_as` mode. 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. r? @alexcrichton
2020-03-27Implement -Zlink-native-librariesJeremy Fitzhardinge-3/+10
This implements a flag `-Zlink-native-libraries=yes/no`. If set to true/yes, or unspecified, then native libraries referenced via `#[link]` attributes will be put on the linker line (ie, unchanged behaviour). If `-Zlink-native-libraries=no` is specified then rustc will not add the native libraries to the link line. The assumption is that the outer build system driving the build already knows about the native libraries and will specify them to the linker directly (for example via `-Clink-arg=`). Addresses issue #70093
2020-03-27Rollup merge of #70068 - jclulow:illumos-gcc, r=cramertjDylan DPC-1/+13
use "gcc" instead of "cc" on *-sun-solaris systems when linking On illumos and Solaris systems, Rust will use GCC as the link editor. Rust does this by invoking "cc", which on many (Linux and perhaps BSD) systems is generally either GCC or a GCC-compatible front-end. On historical Solaris systems, "cc" was often the Sun Studio compiler. This history casts a long shadow, and as such, even most modern illumos-based operating systems tend to install GCC as "gcc", without also making it available as "cc". We should invoke GCC as "gcc" on such systems to ensure we get the right compiler driver.
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-7/+3
(clippy::let_and_return)
2020-03-21Rollup merge of #69965 - mark-i-m:codegen-utils, r=eddybMazdak Farrokhzad-14/+16
Refactorings to get rid of rustc_codegen_utils r? @eddyb cc #45276 After this, the only modules left in `rustc_codegen_utils` are - `link`: a bunch of linking-related functions (many dealing with file names). These are mostly consumed by save analysis, rustc_driver, rustc_interface, and of course codegen. I assume they live here because we don't want a dependency of save analysis on codegen... Perhaps they can be moved to librustc? - ~`symbol_names` and `symbol_names_test`: honestly it seems odd that `symbol_names_test` is not a submodule of `symbol_names`. It seems like these could honestly live in their own crate or move to librustc. Already name mangling is exported as the `symbol_name` query.~ (move it to its own crate) I don't mind doing either of the above as part of this PR or a followup if you want.
2020-03-20remove redundant returns (clippy::needless_return)Matthias Krüger-1/+1
2020-03-19Refactorings to begin getting rid of rustc_codegen_utilsMark Mansi-14/+16
2020-03-19Remove unused `ModuleConfig::emit_lto_bc` field.Nicholas Nethercote-3/+0
2020-03-18Rollup merge of #69920 - Centril:hir-cleanup, r=ZoxcMazdak Farrokhzad-15/+15
Remove some imports to the rustc crate - When we have `NestedVisitorMap::None`, we use `type Map = dyn intravisit::Map<'v>;` instead of the actual map. This doesn't actually result in dynamic dispatch (in the future we may want to use an associated type default to simplify the code). - Use `rustc_session::` imports instead of `rustc::{session, lint}`. r? @Zoxc
2020-03-17review feedback: add a comment describing the situationJoshua M. Clulow-0/+6
2020-03-17Auto merge of #69519 - 12101111:remove-proc-macro-check, r=nagisabors-5/+6
Don't use static crt by default when build proc-macro Don't check value of `crt-static` when build proc-macro crates, since they are always built dynamically. For more information, see https://github.com/rust-lang/cargo/issues/7563#issuecomment-591965320 I hope this will fix issues about compiling `proc_macro` crates on musl host without bring more issues. Fix https://github.com/rust-lang/cargo/issues/7563
2020-03-16use "gcc" instead of "cc" on *-sun-solaris systems when linkingJoshua M. Clulow-1/+7
On illumos and Solaris systems, Rust will use GCC as the link editor. Rust does this by invoking "cc", which on many (Linux and perhaps BSD) systems is generally either GCC or a GCC-compatible front-end. On historical Solaris systems, "cc" was often the Sun Studio compiler. This history casts a long shadow, and as such, even most modern illumos-based operating systems tend to install GCC as "gcc", without also making it available as "cc". We should invoke GCC as "gcc" on such systems to ensure we get the right compiler driver.
2020-03-16use direct imports for `rustc::{lint, session}`.Mazdak Farrokhzad-15/+15
2020-03-15More Method->Fn renamingMark Mansi-1/+1
2020-03-14Update `krate_attrs` and `get_module`John Kåre Alsaker-2/+2
2020-03-13Auto merge of #67502 - Mark-Simulacrum:opt-catch, r=Mark-Simulacrumbors-0/+14
Optimize catch_unwind to match C++ try/catch This refactors the implementation of catching unwinds to allow LLVM to inline the "try" closure directly into the happy path, avoiding indirection. This means that the catch_unwind implementation is (after this PR) zero-cost unless a panic is thrown. https://rust.godbolt.org/z/cZcUSB is an example of the current codegen in a simple case. Notably, the codegen is *exactly the same* if `-Cpanic=abort` is passed, which is clearly not great. This PR, on the other hand, generates the following assembly: ```asm # -Cpanic=unwind: push rbx mov ebx,0x2a call QWORD PTR [rip+0x1c53c] # <happy> mov eax,ebx pop rbx ret mov rdi,rax call QWORD PTR [rip+0x1c537] # cleanup function call call QWORD PTR [rip+0x1c539] # <unfortunate> mov ebx,0xd mov eax,ebx pop rbx ret # -Cpanic=abort: push rax call QWORD PTR [rip+0x20a1] # <happy> mov eax,0x2a pop rcx ret ``` Fixes #64224, and resolves #64222.
2020-03-06fix various typosMatthias Krüger-1/+1
2020-03-05Link to libgcc dynamically on windows-gnu when using dylib cratesAmanieu d'Antras-0/+14