about summary refs log tree commit diff
path: root/src/librustc_trans
AgeCommit message (Collapse)AuthorLines
2018-03-06Rename exported_symbol_ids query to something more explicit and document ↵Michael Woerister-7/+12
what it is doing.
2018-03-06Rollup merge of #48573 - Amanieu:bitreverse2, r=sfacklerkennytm-2/+12
Add functions for reversing the bit pattern in an integer I'm reviving PR #32798 now that the LLVM issues have been resolved. > This adds the bitreverse intrinsic and adds a reverse_bits function to all integer types.
2018-03-04Fixed #48425Pramod Bisht-2/+2
2018-03-03rustc: Tweak default linker selectionAlex Crichton-67/+53
This commit refactors how the path to the linker that we're going to invoke is selected. Previously all targets listed *both* a `LinkerFlavor` and a `linker` (path) option, but this meant that whenever you changed one you had to change the other. The purpose of this commit is to avoid coupling these where possible. Target specifications now only unconditionally define the *flavor* of the linker that they're using by default. If not otherwise specified each flavor now implies a particular default linker to run. As a result, this means that if you'd like to test out `ld` for example you should be able to do: rustc -Z linker-flavor=ld foo.rs whereas previously you had to do rustc -Z linker-flavor=ld -C linker=ld foo.rs This will hopefully make it a bit easier to tinker around with variants that should otherwise be well known to work, for example with LLD, `ld` on OSX, etc.
2018-03-03rust: Import LLD for linking wasm objectsAlex Crichton-131/+143
This commit imports the LLD project from LLVM to serve as the default linker for the `wasm32-unknown-unknown` target. The `binaryen` submoule is consequently removed along with "binaryen linker" support in rustc. Moving to LLD brings with it a number of benefits for wasm code: * LLD is itself an actual linker, so there's no need to compile all wasm code with LTO any more. As a result builds should be *much* speedier as LTO is no longer forcibly enabled for all builds of the wasm target. * LLD is quickly becoming an "official solution" for linking wasm code together. This, I believe at least, is intended to be the main supported linker for native code and wasm moving forward. Picking up support early on should help ensure that we can help LLD identify bugs and otherwise prove that it works great for all our use cases! * Improvements to the wasm toolchain are currently primarily focused around LLVM and LLD (from what I can tell at least), so it's in general much better to be on this bandwagon for bugfixes and new features. * Historical "hacks" like `wasm-gc` will soon no longer be necessary, LLD will [natively implement][gc] `--gc-sections` (better than `wasm-gc`!) which means a postprocessor is no longer needed to show off Rust's "small wasm binary size". LLD is added in a pretty standard way to rustc right now. A new rustbuild target was defined for building LLD, and this is executed when a compiler's sysroot is being assembled. LLD is compiled against the LLVM that we've got in tree, which means we're currently on the `release_60` branch, but this may get upgraded in the near future! LLD is placed into rustc's sysroot in a `bin` directory. This is similar to where `gcc.exe` can be found on Windows. This directory is automatically added to `PATH` whenever rustc executes the linker, allowing us to define a `WasmLd` linker which implements the interface that `wasm-ld`, LLD's frontend, expects. Like Emscripten the LLD target is currently only enabled for Tier 1 platforms, notably OSX/Windows/Linux, and will need to be installed manually for compiling to wasm on other platforms. LLD is by default turned off in rustbuild, and requires a `config.toml` option to be enabled to turn it on. Finally the unstable `#![wasm_import_memory]` attribute was also removed as LLD has a native option for controlling this. [gc]: https://reviews.llvm.org/D42511
2018-03-02Replace Rc with Lrc for shared dataJohn Kåre Alsaker-10/+10
2018-03-01Rollup merge of #48570 - Amanieu:aarch64_features, r=alexcrichtonkennytm-9/+17
Add AArch64 features to whitelist
2018-03-01Rollup merge of #48572 - alexcrichton:noexcept-msvc2, r=eddybManish Goregaokar-6/+54
rustc: Tweak funclet cleanups of ffi functions This commit is targeted at addressing #48251 by specifically fixing a case where a longjmp over Rust frames on MSVC runs cleanups, accidentally running the "abort the program" cleanup as well. Added in #46833 `extern` ABI functions in Rust will abort the process if Rust panics, and currently this is modeled as a normal cleanup like all other destructors. Unfortunately it turns out that `longjmp` on MSVC is implemented with SEH, the same mechanism used to implement panics in Rust. This means that `longjmp` over Rust frames will run Rust cleanups (even though we don't necessarily want it to). Notably this means that if you `longjmp` over a Rust stack frame then that probably means you'll abort the program because one of the cleanups will abort the process. After some discussion on IRC it turns out that `longjmp` doesn't run cleanups for *caught* exceptions, it only runs cleanups for cleanup pads. Using this information this commit tweaks the codegen for an `extern` function to a catch-all clause for exceptions instead of a cleanup block. This catch-all is equivalent to the C++ code: try { foo(); } catch (...) { bar(); } and in fact our codegen here is designed to match exactly what clang emits for that C++ code! With this tweak a longjmp over Rust code will no longer abort the process. A longjmp will continue to "accidentally" run Rust cleanups (destructors) on MSVC. Other non-MSVC platforms will not rust destructors with a longjmp, so we'll probably still recommend "don't have destructors on the stack", but in any case this is a more surgical fix than #48567 and should help us stick to standard personality functions a bit longer.
2018-02-28rustc: Tweak funclet cleanups of ffi functionsAlex Crichton-6/+54
This commit is targeted at addressing #48251 by specifically fixing a case where a longjmp over Rust frames on MSVC runs cleanups, accidentally running the "abort the program" cleanup as well. Added in #46833 `extern` ABI functions in Rust will abort the process if Rust panics, and currently this is modeled as a normal cleanup like all other destructors. Unfortunately it turns out that `longjmp` on MSVC is implemented with SEH, the same mechanism used to implement panics in Rust. This means that `longjmp` over Rust frames will run Rust cleanups (even though we don't necessarily want it to). Notably this means that if you `longjmp` over a Rust stack frame then that probably means you'll abort the program because one of the cleanups will abort the process. After some discussion on IRC it turns out that `longjmp` doesn't run cleanups for *caught* exceptions, it only runs cleanups for cleanup pads. Using this information this commit tweaks the codegen for an `extern` function to a catch-all clause for exceptions instead of a cleanup block. This catch-all is equivalent to the C++ code: try { foo(); } catch (...) { bar(); } and in fact our codegen here is designed to match exactly what clang emits for that C++ code! With this tweak a longjmp over Rust code will no longer abort the process. A longjmp will continue to "accidentally" run Rust cleanups (destructors) on MSVC. Other non-MSVC platforms will not rust destructors with a longjmp, so we'll probably still recommend "don't have destructors on the stack", but in any case this is a more surgical fix than #48567 and should help us stick to standard personality functions a bit longer.
2018-02-28Add bitreverse intrinsicAmanieu d'Antras-2/+12
2018-02-28Add AArch64 featuresAmanieu d'Antras-9/+17
2018-02-28Remove the v7 feature from AArch64Amanieu d'Antras-1/+1
It isn't a valid LLVM feature for this architecture.
2018-02-28Rollup merge of #48565 - alexcrichton:rename-bmi, r=cramertjkennytm-1/+2
rustc: Rename `bmi` feature to `bmi1` This is what [Intel calls it][bmi1] and will [remove a special case][stdsimd] when verifying intrinsics in stdsimd. [bmi1]: https://software.intel.com/sites/landingpage/IntrinsicsGuide/#othertechs=BMI1 [stdsimd]: https://github.com/rust-lang-nursery/stdsimd/blob/bed25b2a9f3b28e6ea80de6d87842f739a2e2d58/crates/stdsimd-verify/tests/x86-intel.rs#L252-L258
2018-02-28Rollup merge of #48560 - bdrewery:freebsd-struct-abi, r=estebankkennytm-2/+1
Fix FreeBSD struct returning ABI. FreeBSD has had a patch similar to this for a while. See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223047. This reworks 6774e7a to be more specific about what `compute_abi_info` is checking for per target.
2018-02-26rustc: Rename `bmi` feature to `bmi1`Alex Crichton-1/+2
This is what [Intel calls it][bmi1] and will [remove a special case][stdsimd] when verifying intrinsics in stdsimd. [bmi1]: https://software.intel.com/sites/landingpage/IntrinsicsGuide/#othertechs=BMI1 [stdsimd]: https://github.com/rust-lang-nursery/stdsimd/blob/bed25b2a9f3b28e6ea80de6d87842f739a2e2d58/crates/stdsimd-verify/tests/x86-intel.rs#L252-L258
2018-02-26Add specific target option for returning struct as an integer.Bryan Drewery-2/+1
2018-02-26Encode linker arguments as UTF-16 on MSVC platformsMark Simulacrum-1/+13
2018-02-25Rollup merge of #48369 - newpavlov:rdrand, r=nagisakennytm-15/+15
Rename rdrnd target feature to rdrand Plus minor cleanup. Related stdsimd [issue](https://github.com/rust-lang-nursery/stdsimd/issues/325).
2018-02-25Rollup merge of #48076 - canarysnort01:fix_pie, r=alexcrichtonkennytm-12/+62
pass correct pie args to gcc linker When linking with gcc, run gcc -v to see if --enable-default-pie is compiled in. If it is, pass -no-pie when necessary to disable pie. Otherwise, pass -pie when necessary to enable it. Fixes #48032 and fixes #35061
2018-02-25Rollup merge of #47964 - jcowgill:mips64-abi, r=eddybkennytm-76/+188
rustc_trans: rewrite mips64 ABI code This PR rewrites the ABI handling code for 64-bit MIPS and should fix various FFI issues including #47290. To accomodate the 64-bit ABI I have had to add a new `CastTarget` variant which I've called `Chunked` (though maybe this isn't the best name). This allows an ABI to cast to some arbitrary structure of `Reg` types. This is required on MIPS which might need to cast to a structure containing a mixture of `i64` and `f64` types.
2018-02-24Rollup merge of #48452 - varkor:unpacked-kind, r=eddybManish Goregaokar-3/+2
Introduce UnpackedKind This adds an `UnpackedKind` type as a typesafe counterpart to `Kind`. This should make future changes to kinds (such as const generics!) more resilient, as the type-checker will be able to catch more potential issues. r? @eddyb cc @yodaldevoid
2018-02-24Rollup merge of #48353 - michaelwoerister:monoitem-static-defid, r=eddybManish Goregaokar-66/+66
Allow for instantiating statics from upstream crates This PR makes the infrastructure around translating statics a bit more flexible so that it can also instantiate statics from upstream crates if the need arises. This is preparatory work for a MIR-only RLIBs prototype, where the instantiation of a `static` may be deferred until a leaf crate. r? @eddyb (feel free to assign to someone else if you're busy)
2018-02-23Rollup merge of #48219 - andjo403:export_symbol, r=michaelwoeristerManish Goregaokar-10/+24
lookup exported symbols only when needed. reduces the time to compile small file with no optimization by half.
2018-02-23Introduce UnpackedKindvarkor-3/+2
This adds an `UnpackedKind` type as a typesafe counterpart to `Kind`. This should make future changes to kinds (such as const generics!) more resilient, as the type-checker should catch more potential issues.
2018-02-21typo fixArtyom Pavlov-1/+1
2018-02-20stage0 cfg cleanupMark Simulacrum-2/+0
2018-02-20features in alphabetic ordernewpavlov-12/+11
2018-02-20added rdrand feature and removed rdrnd featurenewpavlov-4/+5
2018-02-19Allow for instantiating statics from upstream crates.Michael Woerister-28/+27
2018-02-19Rename is_translated_fn query to is_translated_item and make it support statics.Michael Woerister-3/+4
2018-02-19Use DefId instead of NodeId in MonoItem::Static.Michael Woerister-20/+34
2018-02-19Use DefId instead of NodeId while generating debuginfo for statics.Michael Woerister-28/+14
2018-02-17fix more typos found by codespell.Matthias Krüger-4/+4
2018-02-16lookup exported symbols only when needed.andjo403-10/+24
reduces the time to emit dep-info and metadata.
2018-02-14rustc_trans: adjust mips64 abi to use new CastTargetJames Cowgill-9/+15
2018-02-14rustc_trans: add chunked prefix fields to CastTargetJames Cowgill-87/+53
2018-02-14rustc_trans: rewrite mips64 abiJames Cowgill-23/+127
2018-02-14Rollup merge of #48163 - alexcrichton:persistent-linker, r=rkruppekennytm-8/+32
rustc: Persist LLVM's `Linker` in Fat LTO This commit updates our Fat LTO logic to tweak our custom wrapper around LLVM's "link modules" functionality. Previously whenever the `LLVMRustLinkInExternalBitcode` function was called it would call LLVM's `Linker::linkModules` wrapper. Internally this would crate an instance of a `Linker` which internally creates an instance of an `IRMover`. Unfortunately for us the creation of `IRMover` is somewhat O(n) with the input module. This means that every time we linked a module it was O(n) with respect to the entire module we had built up! Now the modules we build up during LTO are quite large, so this quickly started creating an O(n^2) problem for us! Discovered in #48025 it turns out this has always been a problem and we just haven't noticed it. It became particularly worse recently though due to most libraries having 16x more object files than they previously did (1 -> 16). This commit fixes this performance issue by preserving the `Linker` instance across all links into the main LLVM module. This means we only create one `IRMover` and allows LTO to progress much speedier. From the `cargo-cache` project in #48025 a **full build** locally went from 5m15s to 2m24s. Looking at the timing logs each object file was linked in in single-digit millisecond rather than hundreds, clearly being a nice improvement! Closes #48025
2018-02-14Rollup merge of #48126 - newpavlov:patch-1, r=alexcrichtonkennytm-37/+42
Whitelist pclmulqdq x86 feature flag Relevant `stdsimd` [issue](https://github.com/rust-lang-nursery/stdsimd/issues/318).
2018-02-13only pass -no-pie if linker_is_gnuJimmy Brush-2/+8
2018-02-13handle -no-pie error from clangJimmy Brush-5/+7
2018-02-13verify passed -no-pie arg before retrying failed linkJimmy Brush-1/+7
2018-02-13pass correct pie args to gcc linker 2Jimmy Brush-43/+23
Recent versions of gcc default to creating a position independent executable and must be explicitly told not to with the -no-pie argument. Old versions of gcc don't understand -no-pie and will throw an error. Check for that case and retry without -no-pie. This is safe because these old versions of gcc should never default to creating a position independent executable.
2018-02-13pass correct pie args to gcc linkerJimmy Brush-10/+66
When linking with gcc, run gcc -v to see if --enable-default-pie is compiled in. If it is, pass -no-pie when necessary to disable pie. Otherwise, pass -pie when necessary to enable it. Fixes #48032 and fixes #35061
2018-02-13rustc_trans: add abi::CastTarget::ChunkedPrefixJames Cowgill-2/+38
2018-02-12rustc: Persist LLVM's `Linker` in Fat LTOAlex Crichton-8/+32
This commit updates our Fat LTO logic to tweak our custom wrapper around LLVM's "link modules" functionality. Previously whenever the `LLVMRustLinkInExternalBitcode` function was called it would call LLVM's `Linker::linkModules` wrapper. Internally this would crate an instance of a `Linker` which internally creates an instance of an `IRMover`. Unfortunately for us the creation of `IRMover` is somewhat O(n) with the input module. This means that every time we linked a module it was O(n) with respect to the entire module we had built up! Now the modules we build up during LTO are quite large, so this quickly started creating an O(n^2) problem for us! Discovered in #48025 it turns out this has always been a problem and we just haven't noticed it. It became particularly worse recently though due to most libraries having 16x more object files than they previously did (1 -> 16). This commit fixes this performance issue by preserving the `Linker` instance across all links into the main LLVM module. This means we only create one `IRMover` and allows LTO to progress much speedier. From the `cargo-cache` project in #48025 a **full build** locally when from 5m15s to 2m24s. Looking at the timing logs each object file was linked in in single-digit millisecond rather than hundreds, clearly being a nice improvement! Closes #48025
2018-02-12rustc: Add the ability to not run dsymutilAlex Crichton-3/+55
This commit adds the ability for rustc to not run `dsymutil` by default on OSX. A new codegen option, `-Z run-dsymutil=no`, was added to specify that `dsymutil` should *not* run and instead the compiler should unconditionally keep the object files around in a compilation if necessary for debug information. cc #47240
2018-02-11Auto merge of #47614 - dotdash:x86_64_sysv_ffi, r=eddybbors-6/+7
Fix oversized loads on x86_64 SysV FFI calls The x86_64 SysV ABI should use exact sizes for small structs passed in registers, i.e. a struct that occupies 3 bytes should use an i24, instead of the i32 it currently uses. Refs #45543
2018-02-11Dangling pointer fixArtyom Pavlov-2/+2
2018-02-11fixed errorsАртём Павлов [Artyom Pavlov]-4/+4