about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/back
AgeCommit message (Collapse)AuthorLines
2021-05-18Don't pass -pie to linker on windows targets.Luqman Aden-2/+5
2021-05-18Undo unnecessary changes.Luqman Aden-13/+4
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-23/+17
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-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-12Use () for codegen queries.Camille GILLOT-8/+6
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-1/+1
2021-05-12Use () in reachable_set.Camille GILLOT-8/+4
2021-05-12Use () in dependency_formats.Camille GILLOT-1/+1
2021-05-12Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillotbors-33/+49
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-08Support -C passes in NewPMNikita Popov-1/+1
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-65/+148
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-65/+148
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-02Move wasm_import_module_map provider to cg_ssabjorn3-0/+29
2021-05-02Pass target_cpu to LinkerInfo::new instead of link_binarybjorn3-33/+20
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-14Fix typos in rustc_codegen_ssa/src/back/write.rs.Edd Barrett-2/+2
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-8/+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-1/+1
wasm64 support There is still some upstream llvm work needed before this can land.
2021-04-04wasm64Gus Caplan-1/+1
2021-04-03Remove attribute `#[link_args]`Vadim Petrochenkov-8/+3
2021-04-03Auto merge of #83682 - bjorn3:mmap_wrapper, r=cjgillotbors-2/+4
Add an Mmap wrapper to rustc_data_structures This wrapper implements StableAddress and falls back to directly reading the file on wasm32. Taken from #83640, which I will close due to the perf regression.
2021-04-03rm target specific logic in link_sanitizer_runtimeSimonas Kazlauskas-22/+14
2021-04-03Move SanitizerSet to rustc_targetSimonas Kazlauskas-5/+6
2021-03-30Add an Mmap wrapper to rustc_data_structuresbjorn3-2/+4
This wrapper implements StableAddress and falls back to directly reading the file on wasm32
2021-03-28linker: Use data execution prevention options by default when linker ↵Vadim Petrochenkov-0/+17
supports them
2021-03-28linker: Use `--as-needed` by default when linker supports itVadim Petrochenkov-0/+13
2021-03-19coverage bug fixes and optimization supportRich Kadel-5/+3
Adjusted LLVM codegen for code compiled with `-Zinstrument-coverage` to address multiple, somewhat related issues. Fixed a significant flaw in prior coverage solution: Every counter generated a new counter variable, but there should have only been one counter variable per function. This appears to have bloated .profraw files significantly. (For a small program, it increased the size by about 40%. I have not tested large programs, but there is anecdotal evidence that profraw files were way too large. This is a good fix, regardless, but hopefully it also addresses related issues. Fixes: #82144 Invalid LLVM coverage data produced when compiled with -C opt-level=1 Existing tests now work up to at least `opt-level=3`. This required a detailed analysis of the LLVM IR, comparisons with Clang C++ LLVM IR when compiled with coverage, and a lot of trial and error with codegen adjustments. The biggest hurdle was figuring out how to continue to support coverage results for unused functions and generics. Rust's coverage results have three advantages over Clang's coverage results: 1. Rust's coverage map does not include any overlapping code regions, making coverage counting unambiguous. 2. Rust generates coverage results (showing zero counts) for all unused functions, including generics. (Clang does not generate coverage for uninstantiated template functions.) 3. Rust's unused functions produce minimal stubbed functions in LLVM IR, sufficient for including in the coverage results; while Clang must generate the complete LLVM IR for each unused function, even though it will never be called. This PR removes the previous hack of attempting to inject coverage into some other existing function instance, and generates dedicated instances for each unused function. This change, and a few other adjustments (similar to what is required for `-C link-dead-code`, but with lower impact), makes it possible to support LLVM optimizations. Fixes: #79651 Coverage report: "Unexecuted instantiation:..." for a generic function from multiple crates Fixed by removing the aforementioned hack. Some "Unexecuted instantiation" notices are unavoidable, as explained in the `used_crate.rs` test, but `-Zinstrument-coverage` has new options to back off support for either unused generics, or all unused functions, which avoids the notice, at the cost of less coverage of unused functions. Fixes: #82875 Invalid LLVM coverage data produced with crate brotli_decompressor Fixed by disabling the LLVM function attribute that forces inlining, if `-Z instrument-coverage` is enabled. This attribute is applied to Rust functions with `#[inline(always)], and in some cases, the forced inlining breaks coverage instrumentation and reports.
2021-03-18Upgrade memmap to memmap2 in other crates.Camille GILLOT-2/+2
2021-03-11Adjust some `#[cfg]`s to take non-Unix non-Windows operating systems into ↵hyd-dev-2/+7
account
2021-03-09Remove hir::Crate::attrs.Camille GILLOT-6/+4
2021-03-09Use FromStr trait for number option parsingTomasz Miąsko-1/+1
Replace `parse_uint` with generic `parse_number` based on `FromStr`. Use it for parsing inlining threshold to avoid casting later.