summary refs log tree commit diff
path: root/src/librustc_back
AgeCommit message (Collapse)AuthorLines
2018-03-14Workaround abort(2) on compilation error on FreeBSD.Bryan Drewery-0/+1
Same problem as OpenBSD, tracking bug #43575. Backport from #48494
2018-01-31Rollup merge of #47890 - pftbest:no_trap, r=alexcrichtonkennytm-0/+6
[MSP430] Don't enable trap_unreachable option by default on msp. Since MSP430 doesn't meaningfully support faulting on illegal instructions, LLVM generates a call to abort() function instead of a trap instruction. Such calls are 4 bytes long, and that is too much overhead for such small target. r? @alexcrichton
2018-01-31[MSP430] Don't enable trap_unreachable option by default on msp.Vadzim Dambrouski-0/+6
Since MSP430 doesn't meaningfully support faulting on illegal instructions, LLVM generates a call to abort() function instead of a trap instruction. Such calls are 4 bytes long, and that is too much overhead for such small target.
2018-01-30rustc: Add an option to default hidden visibilityAlex Crichton-0/+10
This commit adds a new option to target specifictions to specify that symbols should be "hidden" visibility by default in LLVM. While there are no existing targets that take advantage of this the `wasm32-unknown-unknown` target will soon start to use this visibility. The LLD linker currently interprets `hidden` as "don't export this from the wasm module" which is what we want for 90% of our functions. While the LLD linker does have a "export this symbol" argument which is what we use for other linkers, it was also somewhat easier to do this change instead which'll involve less arguments flying around. Additionally there's no need for non-`hidden` visibility for most of our symbols! This change should not immediately impact the wasm targets as-is, but rather this is laying the foundations for soon integrating LLD as a linker for wasm code.
2018-01-28rustc: Split Emscripten to a separate codegen backendAlex Crichton-0/+8
This commit introduces a separately compiled backend for Emscripten, avoiding compiling the `JSBackend` target in the main LLVM codegen backend. This builds on the foundation provided by #47671 to create a new codegen backend dedicated solely to Emscripten, removing the `JSBackend` of the main codegen backend in the process. A new field was added to each target for this commit which specifies the backend to use for translation, the default being `llvm` which is the main backend that we use. The Emscripten targets specify an `emscripten` backend instead of the main `llvm` one. There's a whole bunch of consequences of this change, but I'll try to enumerate them here: * A *second* LLVM submodule was added in this commit. The main LLVM submodule will soon start to drift from the Emscripten submodule, but currently they're both at the same revision. * Logic was added to rustbuild to *not* build the Emscripten backend by default. This is gated behind a `--enable-emscripten` flag to the configure script. By default users should neither check out the emscripten submodule nor compile it. * The `init_repo.sh` script was updated to fetch the Emscripten submodule from GitHub the same way we do the main LLVM submodule (a tarball fetch). * The Emscripten backend, turned off by default, is still turned on for a number of targets on CI. We'll only be shipping an Emscripten backend with Tier 1 platforms, though. All cross-compiled platforms will not be receiving an Emscripten backend yet. This commit means that when you download the `rustc` package in Rustup for Tier 1 platforms you'll be receiving two trans backends, one for Emscripten and one that's the general LLVM backend. If you never compile for Emscripten you'll never use the Emscripten backend, so we may update this one day to only download the Emscripten backend when you add the Emscripten target. For now though it's just an extra 10MB gzip'd. Closes #46819
2018-01-28Auto merge of #47663 - malbarbo:mips-crt-static, r=alexcrichtonbors-22/+18
Do not assume dynamic linking for musl/mips[el] targets All musl targets except mips[el] assume static linking by default. This can be [confusing](https://users.rust-lang.org/t/static-cross-compiled-binaries-arent-really-static/6084). When the musl/mips[el] targets was [added](https://github.com/rust-lang/rust/pull/31298), dynamic linking was chosen because of binary size concerns, and probably also because libunwind [didn't](https://users.rust-lang.org/t/static-cross-compiled-binaries-arent-really-static/6084/8) supported mips. Now that we have `crt-static` target-feature (the user can choose dynamic link for musl targets), and libunwind [6.0](https://github.com/llvm-mirror/libunwind/commits/release_60) add support to mips, we do not need to assume dynamic linking.
2018-01-24llvm6: CodeModel::{JIT,}Default no longer existsAlex Crichton-4/+4
LLVM has since removed the `CodeModel::Default` enum value in favor of an `Optional` implementationg throughout LLVM. Let's mirror the same change in Rust and update the various bindings we call accordingly. Removed in llvm-mirror/llvm@9aafb854c
2018-01-23Set crt_static_default = false for musl/mips[el] targetsMarco A L Barbosa-0/+2
2018-01-22Do not assume dynamic linking for musl/mips[el] targetsMarco A L Barbosa-22/+16
All musl targets except mips[el] assume static linking by default. This can be confusing https://users.rust-lang.org/t/static-cross-compiled-binaries-arent-really-static/6084 When the musl/mips[el] targets was [added](https://github.com/rust-lang/rust/pull/31298), dynamic linking was chosen because of binary size concerns, and probably also because libunwind [didn't](https://users.rust-lang.org/t/static-cross-compiled-binaries-arent-really-static/6084/8) supported mips. Now that we have `crt-static` target-feature (the user can choose dynamic link for musl targets), and libunwind [6.0](https://github.com/llvm-mirror/libunwind/commits/release_60) add support to mips, we do not need to assume dynamic linking.
2018-01-19Give TargetOptions::linker a sane default value.Ed Schouten-0/+4
Though some parts of rust use cc-rs to invoke a compiler/linker, Cargo seems to make use of the TargetOptions::linker property. Make the out of the box experience for CloudABI a bit better by using the same compiler name as cc-rs.
2018-01-17Document the mingw -lmsvcrt hack betterSegev Finer-1/+9
2018-01-16Add "-lmsvcrt" twice to get rustc to build with the latest mingw64Segev Finer-0/+1
2018-01-13Rollup merge of #47328 - mbrubeck:fs_read, r=sfacklerkennytm-5/+3
Use the new fs_read_write functions in rustc internals Uses `fs::read` and `fs::write` (added by #45837) where appropriate, to simplify code and dog-food these new APIs. This also improves performance, when combined with #47324.
2018-01-11Add i586-unknown-linux-musl targetMarco A L Barbosa-2/+22
2018-01-10Use the new fs_read_write functions in rustc internalsMatt Brubeck-5/+3
2018-01-07Try to fix a perf regression by updating logMalo Jaffré-1/+1
Upgrade `log` to `0.4` in multiple crates.
2018-01-05Rollup merge of #47110 - EdSchouten:cloudabi-tls, r=kennytmkennytm-0/+12
Use the right TLS model for CloudABI. CloudABI doesn't do dynamic linking. For this reason, there is no need to handle any other TLS model than local-exec. CloudABI's C library doesn't provide a __tls_get_addr() function to do Dynamic TLS. By forcing local-exec to be used here, we ensure that we don't generate function calls to __tls_get_addr().
2018-01-03Explain why local-exec is used by CloudABI.Ed Schouten-0/+11
2018-01-01Use the right TLS model for CloudABI.Ed Schouten-0/+1
CloudABI doesn't do dynamic linking. For this reason, there is no need to handle any other TLS model than local-exec. CloudABI's C library doesn't provide a __tls_get_addr() function to do Dynamic TLS. By forcing local-exec to be used here, we ensure that we don't generate function calls to __tls_get_addr().
2018-01-01Fix docs for future pulldown migrationMalo Jaffré-1/+1
2017-12-31Don't announce CloudABI as being UNIX.Ed Schouten-1/+1
This was originally brought in, because the definitions are based on those of FreeBSD, Linux, etc. Even though CloudABI is based on POSIX, it uses a subset that is so small that it's not reasonable to call it POSIX. Now that I'm porting libstd, I'm running into some spots where I have to explicitly disable code paths that were enabled by cfg(unix).
2017-12-26Add armv4t-unknown-linux-gnueabi targetMarco A L Barbosa-5/+38
2017-12-22Add support for CloudABI targets to the rustc backend.Ed Schouten-0/+174
CloudABI is a sandboxed UNIX-like runtime environment. It is a programming environment that uses a capability-based security model. In practice this means that many POSIX interfaces are present, except for ones that try to access resources out of thin air. For example, open() is gone, but openat() is present. Right now I'm at the point where I can compile very basic CloudABI applications on all four supported architectures (ARM and x86, 32 and 64 bits). The next step will be to get libstd to work. Patches for that are outside the scope of this change. More info: https://nuxi.nl/cloudabi/ https://github.com/NuxiNL/cloudlibc/
2017-12-05Auto merge of #46305 - irinagpopa:backstory, r=alexcrichton,eddybbors-426/+0
Move rustc_back modules where they belong.
2017-12-04rustc_back: replace tempdir with crates.io version.Irina-Gabriela Popa-115/+0
2017-12-04rustc_back: move dynamic_lib to rustc_metadata.Irina-Gabriela Popa-291/+0
2017-12-04rustc_back: remove slice module in favor of std::slice::from_ref.Irina-Gabriela Popa-20/+0
2017-12-03Add an i128_lowering flag in TargetOptionsScott McMurray-0/+5
Not actually enabled by default anywhere yet.
2017-12-01Auto merge of #46211 - snipsco:master, r=pnkfelixbors-0/+4
disable jemalloc on executables for ios targets This is a (temporary ?) workaround for issue #45262
2017-11-30explanatory note for the workaroundMathieu Poumeyrol-0/+3
2017-11-26make OpenBSD to use libc++ instead of (e)stdc++Sébastien Marie-0/+1
2017-11-23disable jemalloc on exectuable for ios targetsMathieu Poumeyrol-0/+1
2017-11-19std: Add a new wasm32-unknown-unknown targetAlex Crichton-0/+131
This commit adds a new target to the compiler: wasm32-unknown-unknown. This target is a reimagining of what it looks like to generate WebAssembly code from Rust. Instead of using Emscripten which can bring with it a weighty runtime this instead is a target which uses only the LLVM backend for WebAssembly and a "custom linker" for now which will hopefully one day be direct calls to lld. Notable features of this target include: * There is zero runtime footprint. The target assumes nothing exists other than the wasm32 instruction set. * There is zero toolchain footprint beyond adding the target. No custom linker is needed, rustc contains everything. * Very small wasm modules can be generated directly from Rust code using this target. * Most of the standard library is stubbed out to return an error, but anything related to allocation works (aka `HashMap`, `Vec`, etc). * Naturally, any `#[no_std]` crate should be 100% compatible with this new target. This target is currently somewhat janky due to how linking works. The "linking" is currently unconditional whole program LTO (aka LLVM is being used as a linker). Naturally that means compiling programs is pretty slow! Eventually though this target should have a linker. This target is also intended to be quite experimental. I'm hoping that this can act as a catalyst for further experimentation in Rust with WebAssembly. Breaking changes are very likely to land to this target, so it's not recommended to rely on it in any critical capacity yet. We'll let you know when it's "production ready". --- Currently testing-wise this target is looking pretty good but isn't complete. I've got almost the entire `run-pass` test suite working with this target (lots of tests ignored, but many passing as well). The `core` test suite is still getting LLVM bugs fixed to get that working and will take some time. Relatively simple programs all seem to work though! --- It's worth nothing that you may not immediately see the "smallest possible wasm module" for the input you feed to rustc. For various reasons it's very difficult to get rid of the final "bloat" in vanilla rustc (again, a real linker should fix all this). For now what you'll have to do is: cargo install --git https://github.com/alexcrichton/wasm-gc wasm-gc foo.wasm bar.wasm And then `bar.wasm` should be the smallest we can get it! --- In any case for now I'd love feedback on this, particularly on the various integration points if you've got better ideas of how to approach them!
2017-11-11Control LLVM's TrapUnreachable feature through rustc's TargetOptions.Dan Gohman-0/+7
2017-11-08std: Remove `rand` crate and moduleAlex Crichton-3/+3
This commit removes the `rand` crate from the standard library facade as well as the `__rand` module in the standard library. Neither of these were used in any meaningful way in the standard library itself. The only need for randomness in libstd is to initialize the thread-local keys of a `HashMap`, and that unconditionally used `OsRng` defined in the standard library anyway. The cruft of the `rand` crate and the extra `rand` support in the standard library makes libstd slightly more difficult to port to new platforms, namely WebAssembly which doesn't have any randomness at all (without interfacing with JS). The purpose of this commit is to clarify and streamline randomness in libstd, focusing on how it's only required in one location, hashmap seeds. Note that the `rand` crate out of tree has almost always been a drop-in replacement for the `rand` crate in-tree, so any usage (accidental or purposeful) of the crate in-tree should switch to the `rand` crate on crates.io. This then also has the further benefit of avoiding duplication (mostly) between the two crates!
2017-11-03Fix error message for invalid code/reloc modelsAmanieu d'Antras-0/+6
2017-10-25Disable jemalloc for sparcv9-sun-solarisbgermann-0/+1
Similar to #36994, rust programs segfault on SPARC64 Solaris machines.
2017-10-15Auto merge of #45224 - malbarbo:x32, r=alexcrichtonbors-0/+36
Add x86_64-unknown-linux-gnux32 target This adds X32 ABI support for Linux on X86_64. Let's package and dist it so we can star testing libc, libstd, etc. Fixes https://github.com/rust-lang/rfcs/issues/1339
2017-10-14Auto merge of #45102 - petrochenkov:noar, r=alexcrichtonbors-41/+0
cleanup: rustc doesn't use an external archiver cc https://github.com/rust-lang/rust/pull/45090 r? @alexcrichton
2017-10-11Add x86_64-unknown-linux-gnux32 targetMarco A L Barbosa-0/+36
2017-10-09rustc: Allow target-specific default cgusAlex Crichton-0/+11
Some targets, like msp430 and nvptx, don't work with multiple codegen units right now for bugs or fundamental reasons. To expose this allow targets to express a default. Closes #45000
2017-10-09cleanup: rustc doesn't use an external archiverVadim Petrochenkov-41/+0
2017-10-09Auto merge of #45041 - est31:master, r=alexcrichtonbors-52/+0
Remove support for the PNaCl target (le32-unknown-nacl) This removes support for the `le32-unknown-nacl` target which is currently supported by rustc on tier 3. Despite the "nacl" in the name, the target doesn't output native code (x86, ARM, MIPS), instead it outputs binaries in the PNaCl format. There are two reasons for the removal: * Google [has announced](https://blog.chromium.org/2017/05/goodbye-pnacl-hello-webassembly.html) deprecation of the PNaCl format. The suggestion is to migrate to wasm. Happens we already have a wasm backend! * Our PNaCl LLVM backend is provided by the fastcomp patch set that the LLVM fork used by rustc contains in addition to vanilla LLVM (`src/llvm/lib/Target/JSBackend/NaCl`). Upstream LLVM doesn't have PNaCl support. Removing PNaCl support will enable us to move away from fastcomp (#44006) and have a lighter set of patches on top of upstream LLVM inside our LLVM fork. This will help distribution packagers of Rust. Fixes #42420
2017-10-08Rollup merge of #45094 - japaric:strict-align, r=alexcrichtonkennytm-5/+5
enable strict alignment (+strict-align) on ARMv6 As discovered in #44538 ARMv6 devices may or may not support unaligned memory accesses. ARMv6 Linux *seems* to have no problem with unaligned accesses but this is because the kernel is stepping in to fix each unaligned memory access -- this incurs in a performance penalty. This commit enforces aligned memory accesses on all our in-tree ARM targets that may be used with ARMv6 devices. This should improve performance of Rust programs on ARMv6 devices. For the record, clang also applies this attribute when targeting ARMv6 devices that are not running Darwin or NetBSD. closes #44538 r? @alexcrichton
2017-10-07enable strict alignment (+strict-align) on ARMv6Jorge Aparicio-5/+5
As discovered in #44538 ARMv6 devices may or may not support unaligned memory accesses. ARMv6 Linux *seems* to have no problem with unaligned accesses but this is because the kernel is stepping in to fix each unaligned memory access -- this incurs in a performance penalty. This commit enforces aligned memory accesses on all our in-tree ARM targets that may be used with ARMv6 devices. This should improve performance of Rust programs on ARMv6 devices. For the record, clang also applies this attribute when targeting ARMv6 devices that are not running Darwin or NetBSD.
2017-10-05Remove nacl from librustc_backest31-52/+0
2017-10-02Allow atomic operations up to 32 bitsJames Munns-2/+6
The ARMv5te platform does not have instruction-level support for atomics, however the kernel provides [user space helpers](https://www.kernel.org/doc/Documentation/arm/kernel_user_helpers.txt) which can be used to perform atomic operations. When linked with `libc`, the atomic symbols needed by Rust will be provided, rather than CPU level intrinsics. As this target is specifically `linux` and `gnueabi`, it is reasonable to assume the Linux Kernel and libc will be available for the target. There is a large performance penalty, as we are not using CPU level intrinsics, however this penalty is likely preferable to not having the target at all. I have used this change in a custom target (along with `xargo`) to build `std`, as well as a number of higher level crates.
2017-09-30rustc: Use 16bit c_int for msp430Daniel Klauer-1/+1
Fix regression from c2fe69b9, where main() signature was changed from using 16bit isize to 32bit c_int for argc parameter/result.
2017-09-30rustc: Specify c_int width for each targetDaniel Klauer-0/+75
(all i32 for now, as in liblibc)
2017-09-23add aarch64-unknown-linux-musl targetBen Cressey-0/+37
Signed-off-by: Ben Cressey <bcressey@amazon.com> Signed-off-by: Tom Kirchner <tjk@amazon.com>