about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
AgeCommit message (Collapse)AuthorLines
2021-05-14Auto merge of #83640 - bjorn3:shared_metadata_reader, r=nagisabors-0/+72
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-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-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-07Use the object crate for metadata readingbjorn3-0/+66
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-29Implement RFC 1260 with feature_name `imported_main`.Charles Lew-5/+22
2021-04-28Update list of allowed aarch64 featuresAdam Gemmell-2/+75
These features were recently added to std_detect. Features not supported by LLVM 9, the current minimum version for Rust, are commented.
2021-04-21rustc: Use LLVM's new saturating float-to-int intrinsicsAlex Crichton-133/+36
This commit updates rustc, with an applicable LLVM version, to use LLVM's new `llvm.fpto{u,s}i.sat.*.*` intrinsics to implement saturating floating-point-to-int conversions. This results in a little bit tighter codegen for x86/x86_64, but the main purpose of this is to prepare for upcoming changes to the WebAssembly backend in LLVM where wasm's saturating float-to-int instructions will now be implemented with these intrinsics. This change allows simplifying a good deal of surrounding code, namely removing a lot of wasm-specific behavior. WebAssembly no longer has any special-casing of saturating arithmetic instructions and the need for `fptoint_may_trap` is gone and all handling code for that is now removed. This means that the only wasm-specific logic is in the `fpto{s,u}i` instructions which only get used for "out of bounds is undefined behavior". This does mean that for the WebAssembly target specifically the Rust compiler will no longer be 100% compatible with pre-LLVM 12 versions, but it seems like that's unlikely to be relied on by too many folks. Note that this change does immediately regress the codegen of saturating float-to-int casts on WebAssembly due to the specialization of the LLVM intrinsic not being present in our LLVM fork just yet. I'll be following up with an LLVM update to pull in those patches, but affects a few other SIMD things in flight for WebAssembly so I wanted to separate this change. Eventually the entire `cast_float_to_int` function can be removed when LLVM 12 is the minimum version, but that will require sinking the complexity of it into other backends such as Cranelfit.
2021-04-14Fix typos in rustc_codegen_ssa/src/back/write.rs.Edd Barrett-2/+2
2021-04-08Fix closed over variables not available in debuginfo for Windows MSVCWesley Wiser-15/+51
The issue was that the resulting debuginfo was too complex for LLVM to translate into CodeView records correctly. As a result, it simply ignored the debuginfo which meant Windows debuggers could not display any closed over variables when stepping inside a closure. This fixes that by spilling additional variables to the stack so that the resulting debuginfo is simple (just `*my_variable.dbg.spill`) and LLVM can generate the correct CV records.
2021-04-07Rollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkovDylan DPC-34/+30
Use AnonConst for asm! constants This replaces the old system which used explicit promotion. See #83169 for more background. The syntax for `const` operands is still the same as before: `const <expr>`. Fixes #83169 Because the implementation is heavily based on inline consts, we suffer from the same issues: - We lose the ability to use expressions derived from generics. See the deleted tests in `src/test/ui/asm/const.rs`. - We are hitting the same ICEs as inline consts, for example #78174. It is unlikely that we will be able to stabilize this before inline consts are stabilized.
2021-04-06Use AnonConst for asm! constantsAmanieu d'Antras-34/+30
2021-04-05Rollup merge of #82483 - tmiasko:option-from-str, r=matthewjasperDylan DPC-1/+1
Use FromStr trait for number option parsing Replace `parse_uint` with generic `parse_number` based on `FromStr`. Use it for parsing inlining threshold to avoid casting later.
2021-04-05Rollup merge of #83820 - petrochenkov:nolinkargs, r=nagisaDylan DPC-10/+3
Remove attribute `#[link_args]` Closes https://github.com/rust-lang/rust/issues/29596 The attribute could always be replaced with `-C link-arg`, but cargo didn't provide a reasonable way to pass such flags to rustc. Now cargo supports `cargo:rustc-link-arg*` directives in build scripts (https://doc.rust-lang.org/cargo/reference/unstable.html#extra-link-arg), so this attribute can be removed.
2021-04-05Rollup merge of #80525 - devsnek:wasm64, r=nagisaDylan DPC-2/+2
wasm64 support There is still some upstream llvm work needed before this can land.
2021-04-04wasm64Gus Caplan-2/+2
2021-04-03Auto merge of #83811 - JohnTitor:rollup-hnw1xwz, r=JohnTitorbors-0/+1
Rollup of 7 pull requests Successful merges: - #82487 (Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6`) - #83756 (rustdoc: Rename internal uses of `spotlight`) - #83780 (Document "standard" conventions for error messages) - #83787 (Monomorphization doc fix) - #83803 (add fp-armv8 for ARM_ALLOWED_FEATURES) - #83804 (Remove nightly features in rustc_type_ir) - #83810 (Fix rustc_lint_defs documentation typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-04-03Remove attribute `#[link_args]`Vadim Petrochenkov-10/+3
2021-04-04Rollup merge of #83803 - surechen:add_target_feature, r=petrochenkovYuki Okushi-0/+1
add fp-armv8 for ARM_ALLOWED_FEATURES For fixing err in https://github.com/rust-lang/stdarch/pull/1105.