Commit graph

678 commits

Author SHA1 Message Date
bors
a4fa23a5bb Auto merge of #46305 - irinagpopa:backstory, r=alexcrichton,eddyb
Move rustc_back modules where they belong.
2017-12-05 00:21:59 +00:00
Irina-Gabriela Popa
2c175df013 rustc_back: replace tempdir with crates.io version. 2017-12-04 18:25:31 +02:00
Irina-Gabriela Popa
dda924ab6a rustc_back: move dynamic_lib to rustc_metadata. 2017-12-04 18:25:29 +02:00
Irina-Gabriela Popa
d6f70359dc rustc_back: remove slice module in favor of std::slice::from_ref. 2017-12-04 18:25:06 +02:00
Scott McMurray
1bc402fd80 Add an i128_lowering flag in TargetOptions
Not actually enabled by default anywhere yet.
2017-12-03 21:53:48 -08:00
bors
315fbf7518 Auto merge of #46211 - snipsco:master, r=pnkfelix
disable jemalloc on executables for ios targets

This is a (temporary ?) workaround for issue #45262
2017-12-01 08:44:42 +00:00
Mathieu Poumeyrol
3b18e29d2c explanatory note for the workaround 2017-11-30 23:14:29 +01:00
Sébastien Marie
3ef39d3cb6 make OpenBSD to use libc++ instead of (e)stdc++ 2017-11-26 10:08:25 +01:00
Mathieu Poumeyrol
a42f6fa50e disable jemalloc on exectuable for ios targets 2017-11-23 17:22:22 +01:00
Alex Crichton
80ff0f74b0 std: Add a new wasm32-unknown-unknown target
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-19 21:07:41 -08:00
Dan Gohman
7b6b764917 Control LLVM's TrapUnreachable feature through rustc's TargetOptions. 2017-11-11 12:15:43 -08:00
Alex Crichton
6bc8f164b0 std: Remove rand crate and module
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-08 20:41:17 -08:00
Amanieu d'Antras
37b015fb91 Fix error message for invalid code/reloc models 2017-11-03 00:28:50 +00:00
bgermann
7bab5dabdd Disable jemalloc for sparcv9-sun-solaris
Similar to #36994, rust programs segfault on SPARC64 Solaris machines.
2017-10-25 00:52:56 +02:00
bors
6c0d50f9fa Auto merge of #45224 - malbarbo:x32, r=alexcrichton
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-15 06:12:13 +00:00
bors
83922feec3 Auto merge of #45102 - petrochenkov:noar, r=alexcrichton
cleanup: rustc doesn't use an external archiver

cc https://github.com/rust-lang/rust/pull/45090
r? @alexcrichton
2017-10-14 01:43:42 +00:00
Marco A L Barbosa
a6cfdd2b98 Add x86_64-unknown-linux-gnux32 target 2017-10-11 16:26:37 -03:00
Alex Crichton
5187763cff rustc: Allow target-specific default cgus
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-09 13:45:30 -07:00
Vadim Petrochenkov
b434c84bab cleanup: rustc doesn't use an external archiver 2017-10-09 22:36:08 +03:00
bors
b2f67c8d56 Auto merge of #45041 - est31:master, r=alexcrichton
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-09 04:59:02 +00:00
kennytm
7914e6fbc0 Rollup merge of #45094 - japaric:strict-align, r=alexcrichton
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-08 13:39:06 +08:00
Jorge Aparicio
2b8f190d63 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.
2017-10-07 20:48:25 +02:00
est31
b8fad2d219 Remove nacl from librustc_back 2017-10-05 05:01:19 +02:00
James Munns
1e26094bdd Allow atomic operations up to 32 bits
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-10-02 16:53:43 +02:00
Daniel Klauer
12a8bc6eb9 rustc: Use 16bit c_int for msp430
Fix regression from c2fe69b9, where main() signature was changed from
using 16bit isize to 32bit c_int for argc parameter/result.
2017-09-30 16:30:12 +02:00
Daniel Klauer
a204c193ca rustc: Specify c_int width for each target
(all i32 for now, as in liblibc)
2017-09-30 15:54:08 +02:00
Ben Cressey
f94bd36fd1 add aarch64-unknown-linux-musl target
Signed-off-by: Ben Cressey <bcressey@amazon.com>
Signed-off-by: Tom Kirchner <tjk@amazon.com>
2017-09-23 14:46:33 -07:00
Niko Matsakis
44e45d9fea rework the README.md for rustc and add other readmes
This takes way longer than I thought it would. =)
2017-09-19 09:00:59 -04:00
Makoto Kato
07494ecf78 Require +thumb-mode to generate thumb2 code for Android/armv7-a 2017-09-15 14:42:03 +09:00
Josh Stone
95a5a0ed16 Add TargetOptions::min_global_align, with s390x at 16-bit
The SystemZ `LALR` instruction provides PC-relative addressing for
globals, but only to *even* addresses, so other compilers make sure that
such globals are always 2-byte aligned.  In Clang, this is modeled with
`TargetInfo::MinGlobalAlign`, and `TargetOptions::min_global_align` now
serves the same purpose for rustc.

In Clang, the only targets that set this are SystemZ, Lanai, and NVPTX,
and the latter two don't have targets in rust master.
2017-09-08 14:49:51 -07:00
Corey Farwell
502a11d53e Rollup merge of #44091 - kallisti5:haiku-fix, r=eddyb
haiku/librustc_back: Remove incorrect no_integrated_as

* Makes rust bootstrap incorrectly search for xxx.s vs xxx.0.s
* Not needed or incorrect fix for another issue.
2017-08-26 06:46:37 -07:00
Alexander von Gluck IV
6ca124bc9e haiku/librustc_back: Remove incorrect no_integrated_as
* Makes rust bootstrap incorrectly search for xxx.s vs xxx.0.s
* Not needed or incorrect fix for another issue.
2017-08-25 17:12:20 -05:00
Tamir Duberstein
b3f50caee0
*: remove crate_{name,type} attributes
Fixes #41701.
2017-08-25 16:18:21 -04:00
bors
af6298d590 Auto merge of #44011 - TobiasSchaffner:improved_target_spec_clean, r=alexcrichton
L4Re Target: Add the needed Libraries and locate them

Add the libraries and objects that have to be linked to a get working L4Re Binary using pre- and post-link-args. Additionaly some ld commands had to be passed.

* L4Re libraries and objects will be located by an environment variable.
* gcc libraries and objects will be located using a gcc call.

GCC is mandatory for this target, that might need documentation somewhere. As soon as something mandatory cannot be found, the compiler will panic. This is intended, because the functions involved don't allow the usage of a Result type. libgcc_eh is now passed using `-l` and crtbeginT.o and crtend.o are now located using `gcc -print-filename`.
2017-08-24 12:43:13 +00:00
Samuel Holland
565a863bc2 Support dynamic linking for musl-based targets
Note that this commit does not affect mips-musl targets, as they do not
inherit from linux_musl_base.
2017-08-22 16:24:29 -05:00
Samuel Holland
12ceed013c Introduce target feature crt_static_allows_dylibs
Most UNIX-like platforms do not allow shared libraries to statically
link their own libc, as libc expects to have consistent process-global
state. On those platforms, when we do not have a shared libc available,
we must not attempt to link dylibs or cdylibs. On Windows, however, it
is expected to statically link the CRT into dynamic libraries.

This feature is only relevant for targets that support both fully-static
and fully-dynamic linkage, such as musl on Linux.
2017-08-22 16:24:29 -05:00
Samuel Holland
beb8abe9a5 Introduce temporary target feature crt_static_respected
This feature allows targets to opt in to full support of the crt-static
feature. Currently, crt-static is allowed on all targets, even those
that really can't or really shouldn't support it. This works because it
is very loose in the specification of its effects. Changing the behavior
of crt-static to be more strict in how it chooses libraries and links
executables would likely cause compilation to fail on these platforms.

To avoid breaking existing uses of crt-static, whitelist targets that
support the new, stricter behavior. For all other targets, this changes
crt-static from being "mostly a no-op" to "explicitly a no-op".
2017-08-22 16:24:29 -05:00
Tobias Schaffner
c60fc4bd58 Return L4Re TargetOptions as a Result type instead of panic
If the environment variable L4RE_LIBDIR ist not set an Error will be
returned wrapped in a result type instead of a panic.
2017-08-22 18:05:08 +02:00
Sebastian Humenda
beedf4e7d8 L4Re Target: Add the needed Libraries and locate them
Add the libraries and objects that have to be linked to a get working L4Re
Binary using pre- and post-link-args. Additionaly some ld commands had to
be passed.

* L4Re libraries and objects will be located by an environment variable.
* gcc libraries and objects will be located using a gcc call.

GCC is mandatory for this target, that might need documentation somewhere.
As soon as something mandatory cannot be found, the compiler will panic.
This is intended, because the functions involved don't allow the usage of
a Result type. libgcc_eh is now passed using `-l` and crtbeginT.o and
crtend.o are now located using `gcc -print-filename`.

Co-authored-by: TobiasSchaffner <tobiasschaffner@outlook.com>
2017-08-22 13:54:32 +02:00
Vadim Petrochenkov
de4dbe5789 rustc: Remove some dead code 2017-08-19 13:27:16 +03:00
Ian Douglas Scott
872f532641
Enable unwinding panics on Redox 2017-08-16 17:21:50 -07:00
Zack M. Davis
1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
Tobias Schaffner
c151220a84 Add L4Re Support in librustc_back
Add support for x86_64-unknown-l4re-uclibc target, which covers
the L4 Runtime Environment.
2017-08-04 08:59:01 +02:00
Alex Crichton
02219642bc rustc: Add some build scripts for librustc crates
This commit adds some "boilerplate" build scripts to librustc/libsyntax crates
to declare dependencies on various environment variables that are configured
throughout the build. Cargo recently gained the ability to depend on environment
variables in build scripts which can help trigger recompilation of a crate.

This should fix weird bugs where after you make a commit or a few days later
you'll get weird "not built with the same compiler" errors hopefully.
2017-07-22 22:04:13 -07:00
Thomas Lively
6a3e32267e Pass debugging arguments to emcc
Tells emcc to enable assertions and debugging information for
wasm32-experimental-emscripten. This makes the codegen issues caused by
LLVM bug 33824 manifest more frequently at runtime and improves the wasm
debugging experience.
2017-07-19 10:55:12 -07:00
Johannes Löthberg
2161fb25ca Implement FromStr for RelroLevel rather than duplicating the match
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
2017-07-18 01:27:55 +02:00
Johannes Löthberg
ecf3f6d4de Make partial RELRO default on ppc64 due to segfault
On at least RHEL6 there is a segfault caused by the older ld.so version
when BIND_NOW is used, so use partial RELRO by default on ppc64
architectures for now.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
2017-07-14 22:19:20 +02:00
Johannes Löthberg
94b9cc90fb Support both partial and full RELRO
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
2017-07-14 22:01:37 +02:00
Johannes Löthberg
230668765d Add support for full RELRO
This commit adds support for full RELRO, and enables it for the
platforms I know have support for it.

Full RELRO makes the PLT+GOT data read-only on startup, preventing it
from being overwritten.

http://tk-blog.blogspot.com/2009/02/relro-not-so-well-known-memory.html

Fixes rust-lang/rust#29877.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
2017-07-11 14:22:12 +02:00
bors
c0ec385cac Auto merge of #43099 - japaric:msp430, r=alexcrichton
add a built-in MSP430 target

the MSP430 backend has been enabled for a while but no target was added to rustc
to encourage out of tree experimentation.

We believe the out of tree (custom) target has been iterated long enough and is
stable enough for inclusion in the compiler. Kudos to @pftbest and @awygle for
fixing several LLVM / codegen bugs this target had!

The target name chosen is a slight variation of the triple gcc uses, which is
simply `msp430-elf`. We picked `msp430-none-elf` to leave room for custom
targets that target some embedded OS running on MSP430 devices. (cf. the
custom `thumbv7m-tockos-eabi` target TockOS uses vs the built-in
`thumbv7m-none-eabi`).

There's one expected change in the specification of the proposed target: the
`asm_args` and `no_integrated_as` fields will change to their default values.
Once the LLVM backend gains the ability to directly produce MSP430 object files
we can stop depending on `msp430-elf-gcc` for producing object files; when that
occurs the `asm` related fields will change. This change won't break existing
user code.

r? @alexcrichton
cc @brson
2017-07-07 15:27:49 +00:00