about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
AgeCommit message (Collapse)AuthorLines
2021-05-17Adjust linker_is_gnu branches for cases that don't work on windows.Luqman Aden-7/+16
2021-05-17Auto merge of #85178 - cjgillot:local-crate, r=oli-obkbors-31/+24
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-17rustc_codegen_ssa: append blocks to functions w/o creating a builder.Eduard-Mihai Burtescu-15/+25
2021-05-17rustc_codegen_ssa: only create backend `BasicBlock`s as-needed.Eduard-Mihai Burtescu-40/+41
2021-05-16Auto merge of #85290 - Amanieu:asm_const_int, r=nagisabors-2/+0
Remove support for floating-point constants in asm! Floating-point constants aren't very useful anyways and this simplifies the code since the type check can now be done in typeck. cc `@rust-lang/wg-inline-asm` r? `@nagisa`
2021-05-16Auto merge of #85316 - eddyb:cg-ssa-on-demand-cleanuppad, r=nagisabors-112/+109
rustc_codegen_ssa: generate MSVC cleanup pads on demand, like GNU landing pads. This unblocks #84993 in terms of codegen tests, as it brings the MSVC-style (`cleanup_pad`) EH (LLVM) block order in line with the GNU-style (`landing_pad`) EH (LLVM) block order, by having both of them be on-demand (instead of MSVC-style being eager and GNU-style lazy/on-demand). It also unifies the two implementations a bit, similar to #84699, but in the opposite direction (as that attempt made both kinds of EH pads eagerly built). ~~Opening as draft because I haven't done enough Windows testing just yet, of both this PR, and of #84993 rebased on it.~~ (**EDIT**: seems to be working as expected) r? `@nagisa`
2021-05-15Rollup merge of #85215 - richkadel:ice-fixes-minus-dead-blocks, r=tmandryGuillaume Gomez-3/+3
coverage bug fixes and some refactoring This replaces the relevant commits (2 and 3) from PR #85082, and also corrects an error querying for coverageinfo. 1. `coverageinfo` query needs to use the same MIR as codegen I ran into an error trying to fix dead block coverage and realized the `coverageinfo` query is getting a different MIR compared to the codegenned MIR, which can sometimes be a problem during mapgen. I changed that query to use the `InstandeDef` (which includes the generic parameter substitutions, prosibly specific to const params) instead of the `DefId` (without unknown/default const substitutions). 2. Simplified body_span and filtered span code Some code cleanup extracted from future (but unfinished) commit to fix coverage in attr macro functions. 3. Spanview needs the relevant body_span used for coverage The coverage body_span doesn't always match the function body_span. r? ```@tmandry```
2021-05-15rustc_codegen_ssa: generate MSVC cleanup pads on demand, like GNU landing pads.Eduard-Mihai Burtescu-112/+109
2021-05-14Remove support for floating-point constants in asm!Amanieu d'Antras-2/+0
Floating-point constants aren't very useful anyways and this simplifies the code since the type check can now be done in typeck.
2021-05-14Auto merge of #83640 - bjorn3:shared_metadata_reader, r=nagisabors-0/+77
Use the object crate for metadata reading This allows sharing the metadata reader between cg_llvm, cg_clif and other codegen backends. This is not currently useful for rlib reading with cg_spirv ([rust-gpu](https://github.com/EmbarkStudios/rust-gpu/)) as it uses tar rather than ar as .rlib format, but it is useful for dylib reading required for loading proc macros. (cc `@eddyb)` The object crate is already trusted as dependency of libstd through backtrace. As far as I know it supports reading all object file formats used by targets for which we support rust dylibs with crate metadata, but I am not certain. If this happens to not be the case, I could keep using LLVM for reading dylib metadata. Marked as WIP for a perf run and as it is based on #83637.
2021-05-14Auto merge of #85190 - mati865:update-cc, r=Mark-Simulacrumbors-1/+1
Update cc crate To pull in this fix: https://github.com/alexcrichton/cc-rs/commit/801a87bf2f31ad1ad8bd7e8fa4f5a52b0e2b4c00
2021-05-13Only pass --[no-]gc-sections if linker is GNU ld.Luqman Aden-4/+2
LinkerFlavor::Gcc does not always mean GNU ld specifically. And in the case of at least the solaris ld in illumos, that flag is unrecognized and will cause the linking step to fail.
2021-05-13Add support for const operands and options to global_asm!Amanieu d'Antras-36/+83
On x86, the default syntax is also switched to Intel to match asm!
2021-05-12`coverageinfo` query needs to use the same MIR as codegenRich Kadel-3/+3
I ran into an error trying to fix dead block coverage and realized the `coverageinfo` query is getting a different MIR compared to the codegenned MIR, which can sometimes be a problem during mapgen. I changed that query to use the `InstandeDef` (which includes the generic parameter substitutions, prosibly specific to const params) instead of the `DefId` (without unknown/default const substitutions).
2021-05-12entirely remove rustc_args_required_const attributeRalf Jung-4/+0
2021-05-12Use () for codegen queries.Camille GILLOT-9/+7
2021-05-12Use () for lang items.Camille GILLOT-1/+1
2021-05-12Use () for proc_macro_decls_static.Camille GILLOT-2/+2
2021-05-12Use () for plugin_registrar_fn.Camille GILLOT-2/+2
2021-05-12Use () for entry_fn.Camille GILLOT-6/+5
2021-05-12Use () in reachable_set.Camille GILLOT-8/+4
2021-05-12Use () in dependency_formats.Camille GILLOT-3/+3
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-1/+1
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-12Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillotbors-35/+53
rustc_driver cleanup Best reviewed one commit at a time.
2021-05-12update cc crateMateusz Mikuła-1/+1
To pull in this fix: https://github.com/alexcrichton/cc-rs/commit/801a87bf2f31ad1ad8bd7e8fa4f5a52b0e2b4c00
2021-05-10Adjust target search algorithm for rustlib pathSimonas Kazlauskas-1/+1
With this the concerns expressed in #83800 should be addressed.
2021-05-10Better error messagesbjorn3-8/+14
2021-05-10Auto merge of #84507 - crlf0710:codegen_nonlocal_main_wrapper, r=nagisabors-14/+3
Add primary marker on codegen unit and generate main wrapper on primary codegen. This is the codegen part of changes extracted from #84062. This add a marker called `primary` on each codegen units, where exactly one codegen unit will be `primary = true` at a time. This specific codegen unit will take charge of generating `main` wrapper when `main` is imported from a foreign crate after the implementation of RFC 1260. cc #28937 I'm not sure who should i ask for review for codegen changes, so feel free to reassign. r? `@nagisa`
2021-05-09Add primary marker on codegen unit to take charge of main_wrapper for ↵Charles Lew-14/+3
non-local cases.
2021-05-08Support -C passes in NewPMNikita Popov-2/+2
And report an error if parsing the additional pass pipeline fails. Threading through the error accounts for most of the changes here.
2021-05-08Explicitly register GCOV profiling pass as wellNikita Popov-13/+9
2021-05-08Explicitly register instrprof passNikita Popov-6/+2
Don't use "passes" for this purpose, explicitly insert it into the correct place in the pipeline instead.
2021-05-08Make -Z new-llvm-pass-manager an Option<bool>Nikita Popov-1/+1
To allow it to have an LLVM version dependent default.
2021-05-08Rollup merge of #85044 - ChrisDenton:file-exists, r=jackh726Dylan DPC-1/+1
Use `path.exists()` instead of `fs::metadata(path).is_ok()` It's more explicit and potentially allows platforms to optimize the existence check.
2021-05-07Disable wasm feature of object in cg_ssabjorn3-1/+5
The version 1 resolver unifies enabled features across the whole workspace. This includes libstd which isn't allowed to depend on wasmparser.
2021-05-07Use the object crate for metadata readingbjorn3-0/+67
2021-05-07Use `path.exists()` instead of `fs::metadata(path).is_ok()`Chris Denton-1/+1
It's more explicit and allows platforms to optimize the existence check.
2021-05-07Rollup merge of #84866 - petrochenkov:wholesome, r=Mark-SimulacrumDylan DPC-2/+0
linker: Avoid library duplication with `/WHOLEARCHIVE` Looks like in #72785 I misinterpreted how the `link.exe`'s `/WHOLEARCHIVE` flag works. It's not necessary to write `mylib /WHOLEARCHIVE:mylib` to mark `mylib` as whole archive, `/WHOLEARCHIVE:mylib` alone is enough. https://docs.microsoft.com/en-us/cpp/build/reference/wholearchive-include-all-library-object-files?view=msvc-160
2021-05-06illumos should put libc last in library search orderJoshua M. Clulow-0/+8
Under some conditions, the toolchain will produce a sequence of linker arguments that result in a NEEDED list that puts libc before libgcc_s; e.g., [0] NEEDED 0x2046ba libc.so.1 [1] NEEDED 0x204723 libm.so.2 [2] NEEDED 0x204736 libsocket.so.1 [3] NEEDED 0x20478b libumem.so.1 [4] NEEDED 0x204763 libgcc_s.so.1 Both libc and libgcc_s provide an unwinder implementation, but libgcc_s provides some extra symbols upon which Rust directly depends. If libc is first in the NEEDED list we will find some of those symbols in libc but others in libgcc_s, resulting in undefined behaviour as the two implementations do not use compatible interior data structures. This solution is not perfect, but is the simplest way to produce correct binaries on illumos for now.
2021-05-06linker: Avoid library duplication with `/WHOLEARCHIVE`Vadim Petrochenkov-2/+0
2021-05-06Rollup merge of #83507 - luqmana:native-link-modifiers, r=petrochenkovDylan DPC-66/+150
Implement RFC 2951: Native link modifiers A first attempt at implementing https://github.com/rust-lang/rfcs/pull/2951 / https://github.com/rust-lang/compiler-team/issues/356. Tracking Issue: https://github.com/rust-lang/rust/issues/81490 Introduces feature flags for the general syntax (`native_link_modifiers`) and each modifier (`native_link_modifiers_{as_needed,bundle,verbatim,whole_archive}`). r? `@petrochenkov`
2021-05-06Auto merge of #84468 - iladin:iladin/fix-84467, r=petrochenkovbors-2/+4
Fix#84467 linker_args with --target=sparcv9-sun-solaris Trying to cross-compile for sparcv9-sun-solaris getting a error message for -zignore Introduced when -z -ignore was seperated here 22d0ab0 No formatting done Reproduce ``` bash rustup target add sparcv9-sun-solaris cargo new --bin hello && cd hello && cargo run --target=sparcv9-sun-solaris ``` config.toml [target.sparcv9-sun-solaris] linker = "gcc"
2021-05-05Implement RFC 2951: Native link modifiersLuqman Aden-66/+150
This commit implements both the native linking modifiers infrastructure as well as an initial attempt at the individual modifiers from the RFC. It also introduces a feature flag for the general syntax along with individual feature flags for each modifier.
2021-05-05Use local and remapped paths where appropriateAndy Wang-1/+1
2021-05-02Move wasm_import_module_map provider to cg_ssabjorn3-0/+29
2021-05-02Pass target_cpu to LinkerInfo::new instead of link_binarybjorn3-35/+24
This is one step towards separating the linking code from codegen backends
2021-05-01Deduplicate native libs before they are passed to the linkerChris Denton-0/+8
2021-04-30Fix linker_args with --target=sparcv9-sun-solarisDaniel Silverman-2/+4
Moved -z ignore to add_as_needed Trying to cross-compile for sparcv9-sun-solaris getting an error message for -zignore Introduced when -z -ignore was separated here 22d0ab0 No formatting done Reproduce ``` bash rustup target add sparcv9-sun-solaris cargo new --bin hello && cd hello && cargo run --target=sparcv9-sun-solaris ``` config.toml [target.sparcv9-sun-solaris] linker = "gcc"
2021-04-30Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkovbors-5/+22
Implement RFC 1260 with feature_name `imported_main`. This is the second extraction part of #84062 plus additional adjustments. This (mostly) implements RFC 1260. However there's still one test case failure in the extern crate case. Maybe `LocalDefId` doesn't work here? I'm not sure. cc https://github.com/rust-lang/rust/issues/28937 r? `@petrochenkov`
2021-04-29Implement RFC 1260 with feature_name `imported_main`.Charles Lew-5/+22