about summary refs log tree commit diff
path: root/src/librustc_codegen_ssa/back
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-6371/+0
2020-08-17Rollup merge of #75603 - mati865:mingw-out-implib-compat, r=oli-obkTyler Mandry-1/+1
Use more compatible out-implib style When calling `rust-lld` directly it accepts only `--out-implib {}` or `--out-implib={}` not `--out-implib,{}`.
2020-08-16Use more compatible out-implib styleMateusz Mikuła-1/+1
2020-08-16Use LocalDefId instead of HirId for reachable_set elements.Eduard-Mihai Burtescu-5/+3
2020-08-15Auto merge of #74576 - myfreeweb:freebsd-sanitizers, r=oli-obkbors-0/+1
Add sanitizer support on FreeBSD Restarting #47337. Everything is better now, no more weird llvm problems, well not everything: Unfortunately, the sanitizers don't have proper support for versioned symbols (https://github.com/google/sanitizers/issues/628), so `libc`'s usage of `stat@FBSD_1.0` and so on explodes, e.g. in calling `std::fs::metadata`. Building std (now easy thanks to cargo `-Zbuild-std`) and libc with `freebsd12/13` config via the `LIBC_CI=1` env variable is a good workaround… ``` LIBC_CI=1 RUSTFLAGS="-Z sanitizer=address" cargo +san-test -Zbuild-std run --target x86_64-unknown-freebsd --verbose ``` …*except* std won't build because there's no `st_lspare` in the ino64 version of the struct, so an std patch is required: ```diff --- i/src/libstd/os/freebsd/fs.rs +++ w/src/libstd/os/freebsd/fs.rs @@ -66,8 +66,6 @@ pub trait MetadataExt { fn st_flags(&self) -> u32; #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_gen(&self) -> u32; - #[stable(feature = "metadata_ext2", since = "1.8.0")] - fn st_lspare(&self) -> u32; } #[stable(feature = "metadata_ext", since = "1.1.0")] @@ -136,7 +134,4 @@ impl MetadataExt for Metadata { fn st_flags(&self) -> u32 { self.as_inner().as_inner().st_flags as u32 } - fn st_lspare(&self) -> u32 { - self.as_inner().as_inner().st_lspare as u32 - } } ``` I guess std could like.. detect that `libc` isn't built for the old ABI, and replace the implementation of `st_lspare` with a panic?
2020-08-14Rollup merge of #75448 - lcnr:rn-as_local_hir_id, r=davidtwcoTyler Mandry-1/+1
merge `as_local_hir_id` with `local_def_id_to_hir_id` `as_local_hir_id` was defined as just calling `local_def_id_to_hir_id` and I think that having two different ways to call the same method is somewhat confusing. Don't really care about which of these 2 methods we want to keep. Does this require an MCP, considering that these methods are fairly frequently used?
2020-08-15Auto merge of #73851 - matthewjasper:serialize-not-special, r=oli-obkbors-1/+1
Remove most specialization use in serialization Switching from specialization to min_specialization in the compiler made the unsoundness of how we used these traits pretty clear. This changes how the `Encodable` and `Decodable` traits work to be more friendly for types need a `TyCtxt` to deserialize. The alternative design of having both `Encodable` and `TyEncodable` traits was considered, but doesn't really work because the following impls would conflict: ``` impl<E: Ecodable> TyEncodable for Encodable impl<E: TyEcodable> TyEncodable for [E] ``` ## How-to guide - `Rustc(De|En)codable` is now spelled `Ty(De|En)coable` in `rustc_middle`, `Metadata(En|De)codable` in `rustc_metadata` where needed, and `(De|En)codable` everywhere else. - Manual implementations of `(De|En)codable` shouldn't be much different. - If you're adding a new interned type that needs to be en/decodable then the simplest thing way to handle this is: - Have the type be a wrapper around a reference to the interned data (i.e. do what `ty::Predicate` does, and not what all of the other interned types do) - Derive `Ty(En|De)codable` on the inner type - Implement `Encodable<impl TyEncoder>` by forwarding to the inner type. - Implement `Decodable<impl TyDecoder>` by decoding the inner type and then creating the wrapper around that (using the `tcx` from the decoder as needed). cc @rust-lang/compiler for opinions on this change r? @oli-obk
2020-08-14Rework `rustc_serialize`Matthew Jasper-1/+1
- Move the type parameter from `encode` and `decode` methods to the trait. - Remove `UseSpecialized(En|De)codable` traits. - Remove blanket impls for references. - Add `RefDecodable` trait to allow deserializing to arena-allocated references safely. - Remove ability to (de)serialize HIR. - Create proc-macros `(Ty)?(En|De)codable` to help implement these new traits.
2020-08-14Auto merge of #75416 - richkadel:llvm-coverage-map-gen-5.3, r=richkadelbors-12/+3
LLVM IR coverage encoding aligns closer to Clang's I found some areas for improvement while attempting to debug the SegFault issue when running rust programs compiled using MSVC, with coverage instrumentation. I discovered that LLVM's coverage writer was generating incomplete function name variable names (that's not a typo: the name of the variable that holds a function name). The existing implementation used one-up numbers to distinguish variables, and correcting the names did not fix the MSVC coverage bug, but the fix in this PR makes the names and resulting LLVM IR easier to follow and more consistent with Clang's implementation. I also changed the way the `-Zinstrument-coverage` option is supported in symbol_export.rs. The original implementation was incorrect, and the corrected version matches the handling for `-Zprofile-generate`, as it turns out. (An argument could be made that maybe `-Zinstrument-coverage` should automatically enable `-Cprofile-generate`. In fact, if `-Cprofile-generate` is analagous to Clang's `-fprofile-generate`, as some documentation implies, Clang always requires this flag for its implementation of source-based code coverage. This would require a little more validation, and if implemented, would probably require updating some of the user-facing messages related to `-Cprofile-generate` to not be so specific to the PGO use case.) None of these changes fixed the MSVC coverage problems, but they should still be welcome improvements. Lastly, I added some additional FIXME comments in instrument_coverage.rs describing issues I found with the generated LLVM IR that would be resolved if the coverage instrumentation is injected with a `Statement` instead of as a new `BasicBlock`. I describe seven advantages of this change, but it requires some discussion before making a change like this. r? @tmandry
2020-08-14LLVM IR coverage encoding aligns closer to Clang'sRich Kadel-12/+3
I found some areas for improvement while attempting to debug the SegFault issue when running rust programs compiled using MSVC, with coverage instrumentation. I discovered that LLVM's coverage writer was generating incomplete function name variable names (that's not a typo: the name of the variable that holds a function name). The existing implementation used one-up numbers to distinguish variables, and correcting the names did not fix the MSVC coverage bug, but the fix in this PR makes the names and resulting LLVM IR easier to follow and more consistent with Clang's implementation. I also changed the way the `-Zinstrument-coverage` option is supported in symbol_export.rs. The original implementation was incorrect, and the corrected version matches the handling for `-Zprofile-generate`, as it turns out. (An argument could be made that maybe `-Zinstrument-coverage` should automatically enable `-Cprofile-generate`. In fact, if `-Cprofile-generate` is analagous to Clang's `-fprofile-generate`, as some documentation implies, Clang always requires this flag for its implementation of source-based code coverage. This would require a little more validation, and if implemented, would probably require updating some of the user-facing messages related to `-Cprofile-generate` to not be so specific to the PGO use case.) None of these changes fixed the MSVC coverage problems, but they should still be welcome improvements. Lastly, I added some additional FIXME comments in instrument_coverage.rs describing issues I found with the generated LLVM IR that would be resolved if the coverage instrumentation is injected with a `Statement` instead of as a new `BasicBlock`. I describe seven advantages of this change, but it requires some discussion before making a change like this.
2020-08-13merge `as_local_hir_id` with `local_def_id_to_hir_id`Bastian Kauschke-1/+1
2020-08-13Link sanitizers when creating dynamic libraries on macOSTomasz Miąsko-1/+14
2020-08-11Rollup merge of #75315 - Mark-Simulacrum:save-temps, r=ecstatic-morseDylan DPC-24/+15
Avoid deleting temporary files on error Previously if the compiler error'd, fatally, then temporary directories which should be preserved by -Csave-temps would be deleted due to fatal compiler errors being implemented as panics. cc @infinity0 (Hopefully) fixes #75275, but I haven't tested
2020-08-10Auto merge of #74410 - mati865:mingw-no-self-contained-when-cross-compiling, ↵bors-1/+3
r=petrochenkov MinGW: disable self-contained mode when cross compiling When cross compiling users have to provide own linker and libraries anyway. Using rust provided MinGW crt objects is harmful here and has no benefits. cc https://github.com/rust-lang/rust/issues/68887
2020-08-09Add sanitizer support on FreeBSDGreg V-0/+1
2020-08-09Avoid deleting temporary files on errorMark Rousskov-24/+15
Previously if the compiler error'd, fatally, then temporary directories which should be preserved by -Csave-temps would be deleted due to fatal compiler errors being implemented as panics.
2020-08-08Auto merge of #74932 - nnethercote:rm-ast-session-globals, r=petrochenkovbors-5/+5
Remove `librustc_ast` session globals By moving the data onto `Session`. r? @petrochenkov
2020-08-08Eliminate the `SessionGlobals` from `librustc_ast`.Nicholas Nethercote-5/+5
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This means they are accessed via the `Session`, rather than via TLS. A few `Attr` methods and `librustc_ast` functions are now methods of `Session`. All of this required passing a `Session` to lots of functions that didn't already have one. Some of these functions also had arguments removed, because those arguments could be accessed directly via the `Session` argument. `contains_feature_attr()` was dead, and is removed. Some functions were moved from `librustc_ast` elsewhere because they now need to access `Session`, which isn't available in that crate. - `entry_point_type()` --> `librustc_builtin_macros` - `global_allocator_spans()` --> `librustc_metadata` - `is_proc_macro_attr()` --> `Session`
2020-08-08fix clippy::map_clone: use .cloned() instead of .map(|x| x.clone())Matthias Krüger-1/+1
2020-07-29Auto merge of #72049 - mati865:mingw-lld, r=petrochenkovbors-4/+23
MinGW: enable dllexport/dllimport Fixes (only when using LLD) https://github.com/rust-lang/rust/issues/50176 Fixes https://github.com/rust-lang/rust/issues/72319 This makes `windows-gnu` on pair with `windows-msvc` when it comes to symbol exporting. For MinGW it means both good things like correctly working dllimport/dllexport, ability to link with LLD and bad things like https://github.com/rust-lang/rust/issues/27438. Not sure but maybe this should land behind unstable compiler option (`-Z`) or environment variable?
2020-07-29MinGW: emit dllexport/dllimport by rustcMateusz Mikuła-4/+23
This fixes various cases where LD could not guess dllexport correctly and greatly improves compatibility with LLD which is not going to support linker scripts anytime soon
2020-07-22Rollup merge of #74631 - petrochenkov:ehdr2, r=jonas-schievinkManish Goregaokar-8/+4
rustc_target: Add a target spec option for disabling `--eh-frame-hdr` Disable `--eh-frame-hdr` for targets that use an `ld`-like linker, but don't support that option. Do it through a target spec option rather than through hard-coding in `linker.rs`. The option is still enabled by default though. cc https://github.com/rust-lang/rust/pull/73564 Fixes https://github.com/rust-lang/rust/pull/73564#issuecomment-657011004 Fixes https://github.com/rust-lang/rust/pull/74625 Fixes https://github.com/rust-embedded/msp430-rt/issues/12
2020-07-22Rollup merge of #73893 - ajpaverd:cfguard-stabilize, r=nikomatsakisManish Goregaokar-1/+1
Stabilize control-flow-guard codegen option This is the stabilization PR discussed in #68793. It converts the `-Z control-flow-guard` debugging option into a codegen option (`-C control-flow-guard`), and changes the associated tests.
2020-07-22rustc_target: Add a target spec option for disabling `--eh-frame-hdr`Vadim Petrochenkov-8/+4
2020-07-19Auto merge of #74091 - richkadel:llvm-coverage-map-gen-4, r=tmandrybors-2/+13
Generating the coverage map @tmandry @wesleywiser rustc now generates the coverage map and can support (limited) coverage report generation, at the function level. Example commands to generate a coverage report: ```shell $ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu $ $BUILD/stage1/bin/rustc -Zinstrument-coverage \ $HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs $ LLVM_PROFILE_FILE="main.profraw" ./main called $ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata $ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main ``` ![rust coverage report only 20200706](https://user-images.githubusercontent.com/3827298/86697299-1cbe8f80-bfc3-11ea-8955-451b48626991.png) r? @wesleywiser Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
2020-07-18Rollup merge of #74478 - rust-lang:revert-74416-linker-locale-utf8, ↵Manish Goregaokar-3/+1
r=Mark-Simulacrum Revert "Use an UTF-8 locale for the linker." Reverts rust-lang/rust#74416 This is suspected to have caused significant compile time regressions: https://perf.rust-lang.org/compare.html?start=39d5a61f2e4e237123837f5162cc275c2fd7e625&end=d3df8512d2c2afc6d2e7d8b5b951dd7f2ad77b02&stat=instructions:u
2020-07-18Revert "Use an UTF-8 locale for the linker."Jonas Schievink-3/+1
2020-07-17Rollup merge of #74464 - FedericoPonzi:fix-#67108, r=ManishearthManish Goregaokar-31/+2
Use pathdiff crate I wanted to tackle a simple issue, and stumbled upon #67108: this pr removes the function which was exported to the external crate as required in the todo/issue. I've tested it with: ``` ./x.py build --stage 1 --keep-stage 1 src/librustc_codegen_ssa ``` And it looks like it's compiling
2020-07-17Run fmtManish Goregaokar-1/+1
2020-07-18fixes #67108 by using the external crateFederico Ponzi-31/+2
2020-07-17Generating the coverage mapRich Kadel-2/+13
rustc now generates the coverage map and can support (limited) coverage report generation, at the function level. Example: $ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu $ $BUILD/stage1/bin/rustc -Zinstrument-coverage \ $HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs $ LLVM_PROFILE_FILE="main.profraw" ./main called $ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata $ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main 1| 1|pub fn will_be_called() { 2| 1| println!("called"); 3| 1|} 4| | 5| 0|pub fn will_not_be_called() { 6| 0| println!("should not have been called"); 7| 0|} 8| | 9| 1|fn main() { 10| 1| let less = 1; 11| 1| let more = 100; 12| 1| 13| 1| if less < more { 14| 1| will_be_called(); 15| 1| } else { 16| 1| will_not_be_called(); 17| 1| } 18| 1|}
2020-07-17Use an UTF-8 locale for the linker.Jakub Kądziołka-1/+3
2020-07-16MinGW: disable self-contained mode when cross compilingMateusz Mikuła-1/+3
When cross compiling users have to provide own linker and libraries anyway. Using rust provided MinGW crt objects is harmful here and has no benefits.
2020-07-15Auto merge of #74113 - lcnr:type-dependent-consts-2, r=eddybbors-2/+2
Support const args in type dependent paths (Take 2) once more, except it is sound this time :smiling_face_with_three_hearts: previously #71154 ----- ```rust #![feature(const_generics)] struct A; impl A { fn foo<const N: usize>(&self) -> usize { N } } struct B; impl B { fn foo<const N: usize>(&self) -> usize { 42 } } fn main() { let a = A; a.foo::<7>(); } ``` When calling `type_of` for generic const arguments, we now use the `TypeckTables` of the surrounding body to get the expected type. This alone causes cycle errors though, as we now have `typeck_tables_of(main)` -> `...` -> `type_of(main_ANON0 := 7)` -> `typeck_tables_of(main)` :zap: (see https://github.com/rust-lang/rust/issues/68400#issuecomment-611760290) To prevent this we must not call `type_of(const_arg)` during `typeck_tables_of`. This is achieved by calling `type_of(param_def_id)` instead. We have to somehow remember the `DefId` of the param through all of typeck, which is done using the struct `ty::WithOptConstParam<DefId>`, which replaces `DefId` where needed and contains an `Option<DefId>` to be able to store the const parameter in case it exists. Queries which are currently cached on disk are split into two variants: `query_name`(cached) and `query_name_(of|for)_const_arg`(not cached), with `query_name_of_const_arg` taking a pair `(did, param_did): (LocalDefId, DefId)`. For some queries a method `query_name_of_opt_const_arg` is added to `TyCtxt` which takes a `ty::WithOptConstParam` and either calls `query_name` or `query_name_of_const_arg` depending on the value of `const_param_did`. r? @eddyb @varkor
2020-07-15InstanceDef::ItemBastian Kauschke-2/+2
2020-07-15Change `SymbolName::name` to a `&str`.Nicholas Nethercote-9/+8
This eliminates a bunch of `Symbol::intern()` and `Symbol::as_str()` calls, which is good, because they require locking the interner. Note that the unsafety in `from_cycle_error()` is identical to the unsafety on other adjacent impls.
2020-07-15Add and use more static symbols.Nicholas Nethercote-8/+8
Note that the output of `unpretty-debug.stdout` has changed. In that test the hash values are normalized from a symbol numbers to small numbers like "0#0" and "0#1". The increase in the number of static symbols must have caused the original numbers to contain more digits, resulting in different pretty-printing prior to normalization.
2020-07-14Stabilize control-flow-guard codegen optionAndrew Paverd-1/+1
2020-07-11Rollup merge of #74167 - jclulow:illumos-linker-eh-frame-hdr-fix, r=petrochenkovManish Goregaokar-1/+1
linker: illumos ld does not support --eh-frame-hdr As of rust-lang/rust#73564, the --eh-frame-hdr flag is unconditionally passed to linkers on many platforms. The illumos link editor does not currently support this flag. The linker machinery in the Rust toolchain currently seems to use the (potentially cross-compiled) target to choose linker flags, rather than looking at what might be running on the build system. Disabling the flag for all illumos/Solaris targets seems like the best we can do for now without more serious surgery.
2020-07-10Rollup merge of #74127 - tamird:allowlist, r=oli-obkManish Goregaokar-4/+4
Avoid "whitelist" Other terms are more inclusive and precise.
2020-07-10Rollup merge of #74103 - ajpaverd:cfguard-msvc-only, r=nikomatsakisManish Goregaokar-12/+4
Only add CFGuard on `windows-msvc` targets As @ollie27 pointed out in #73893, the `cfguard` module flag causes incorrect behavior on `windows-gnu` targets. This patch restricts rustc to only add this flag for `windows-msvc` targets (this may need to be changed if other linkers gain support for CFGuard).
2020-07-10Avoid "whitelist"Tamir Duberstein-4/+4
Other terms are more inclusive and precise.
2020-07-10Only add cfguard module flag on windows-msvcAndrew Paverd-12/+4
2020-07-08linker: illumos ld does not support --eh-frame-hdrJoshua M. Clulow-1/+1
As of rust-lang/rust#73564, the --eh-frame-hdr flag is unconditionally passed to linkers on many platforms. The illumos link editor does not currently support this flag. The linker machinery in the Rust toolchain currently seems to use the (potentially cross-compiled) target to choose linker flags, rather than looking at what might be running on the build system. Disabling the flag for all illumos/Solaris targets seems like the best we can do for now without more serious surgery.
2020-07-05Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>.Eduard-Mihai Burtescu-4/+4
2020-06-27linker: Create GNU_EH_FRAME header by default when producing ELFsVadim Petrochenkov-0/+17
2020-06-25Rollup merge of #72738 - mati865:self-contained-option, r=petrochenkovManish Goregaokar-26/+54
Self contained linking option With objects moved to self-contained directory by https://github.com/rust-lang/rust/pull/72999 we can now add option to control whether to use self-contained on native linkage mode.
2020-06-25Rename remaining `fallback` to `self_contained`Mateusz Mikuła-12/+20
2020-06-25Rename get_self_contained_lib_pathMateusz Mikuła-2/+2
2020-06-25Add unstable rustc option to control self-contained linkage modeMateusz Mikuła-17/+37