Commit Graph

96 Commits

Author SHA1 Message Date
Alex Crichton 0129b01a41 rustc: Tweak default linker selection
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-03 20:21:35 -08:00
Alex Crichton d69b24805b rust: Import LLD for linking wasm objects
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-03 20:21:35 -08:00
John Paul Adrian Glaubitz 88de279dca bootstrap: Add openssl configuration for powerpc-unknown-linux-gnuspe 2018-02-26 02:07:24 +01:00
kennytm 266386a10e
Rollup merge of #48489 - glaubitz:x32-linux, r=alexcrichton
bootstrap: Add openssl configuration for x86_64-unknown-linux-gnux32

OpenSSL provides a native configuration for x86_64-unknown-linux-gnux32:

> https://github.com/openssl/openssl/blob/master/Configurations/10-main.conf#L810

Let's use it.
2018-02-25 21:30:47 +08:00
kennytm b571155631
Rollup merge of #48297 - glaubitz:sparc-linux, r=estebank
Add missing pieces for sparc-linux-gnu support

I noticed that while Rust has CABI support for 32-bit SPARC, there are still some pieces missing to be able to use Rust on a 32-Bit SPARC system like Gentoo which still defaults to a 32-bit port unlike Debian's sparc64 port.

This PR is an attempt to add the missing pieces. I will send the necessary changes for libc in a separate PR.

CC @jrtc27
2018-02-25 15:54:45 +08:00
kennytm 3e2072e51d
Rollup merge of #48281 - jakllsch:netbsd-powerpc, r=alexcrichton
Add powerpc-unknown-netbsd target
2018-02-25 15:54:44 +08:00
Vadim Petrochenkov aafebbcba9 Remove directory `src/rt` 2018-02-24 16:45:39 +03:00
John Paul Adrian Glaubitz 0b6583ed97 bootstrap: Add openssl configuration for x86_64-unknown-linux-gnux32 2018-02-24 01:08:02 +01:00
John Paul Adrian Glaubitz 871e82e7a4 bootstrap: Add openssl configuration for sparc-unknown-linux-gnu 2018-02-23 11:20:23 +01:00
Jonathan A. Kollasch ebec5e3906 Add powerpc-unknown-netbsd target 2018-02-16 14:29:24 -06:00
bors 1670a532dd Auto merge of #48203 - kennytm:rollup, r=kennytm
Rollup of 23 pull requests

- Successful merges: #47784, #47806, #47846, #48005, #48033, #48065, #48087, #48114, #48126, #48130, #48133, #48151, #48154, #48156, #48162, #48163, #48165, #48167, #48181, #48186, #48195, #48035, #48210
- Failed merges:
2018-02-15 13:35:20 +00:00
kennytm 2be44ceaa2
Rollup merge of #47846 - roblabla:bugfix-ocaml, r=kennytm
Work around LLVM OCAML binding installation failure

Hello,

I have OCaml installed on my machine, and compiling rust systematically fails when LLVM attempts installing the OCaml bindings in `/usr/lib/ocaml`, which is write-protected. Here are the logs: https://gist.github.com/roblabla/3f147914c5df627c9d97ab311ba133ad

Some digging around the issue reveals:

- The code that finds if OCaml is installed, and sets the bindings to be compiled/installed: b24a45d2e9/cmake/config-ix.cmake (L612)
- b24a45d2e9/bindings/ocaml/llvm/CMakeLists.txt Some code that does the installation.

The problem seems to be that `LLVM_OCAML_INSTALL_PATH` is set to `OCAML_STDLIB_PATH` by default, which is in `/usr/lib/ocaml`, instead of the prefix.

This PR "fixes" the issue by setting `LLVM_OCAML_INSTALL_PATH` to `usr/lib/ocaml`. I haven't found a way to make LLVM not build OCaml, which would probably be a superior fix.
2018-02-14 16:14:29 +08:00
Mark Simulacrum f104b12059 Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."

For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.

However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).

Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 10:03:16 -07:00
roblabla 3c01dea03e Add comment about the problem, and use provided path if available 2018-02-10 21:29:10 +01:00
Alex Crichton 6b7b6b63a9 rustc: Upgrade to LLVM 6
The following submodules have been updated for a new version of LLVM:

- `src/llvm`
- `src/libcompiler_builtins` - transitively contains compiler-rt
- `src/dlmalloc`

This also updates the docker container for dist-i686-freebsd as the old 16.04
container is no longer capable of building LLVM. The
compiler-rt/compiler-builtins and dlmalloc updates are pretty routine without
much interesting happening, but the LLVM update here is of particular note.
Unlike previous updates I haven't cherry-picked all existing patches we had on
top of our LLVM branch as we have a [huge amount][patches4] and have at this
point forgotten what most of them are for. Instead I started from the current
`release_60` branch in LLVM and only applied patches that were necessary to get
our tests working and building.

The current set of custom rustc-specific patches included in this LLVM update are:

* rust-lang/llvm@1187443 - this is how we actually implement
  `cfg(target_feature)` for now and continues to not be upstreamed. While a
  hazard for SIMD stabilization this commit is otherwise keeping the status
  quo of a small rustc-specific feature.
* rust-lang/llvm@013f2ec - this is a rustc-specific optimization that we haven't
  upstreamed, notably teaching LLVM about our allocation-related routines (which
  aren't malloc/free). Once we stabilize the global allocator routines we will
  likely want to upstream this patch, but for now it seems reasonable to keep it
  on our fork.
* rust-lang/llvm@a65bbfd - I found this necessary to fix compilation of LLVM in
  our 32-bit linux container. I'm not really sure why it's necessary but my
  guess is that it's because of the absolutely ancient glibc that we're using.
  In any case it's only updating pieces we're not actually using in LLVM so I'm
  hoping it'll turn out alright. This doesn't seem like something we'll want to
  upstream.c
* rust-lang/llvm@77ab1f0 - this is what's actually enabling LLVM to build in our
  i686-freebsd container, I'm not really sure what's going on but we for sure
  probably don't want to upstream this and otherwise it seems not too bad for
  now at least.
* rust-lang/llvm@9eb9267 - we currently suffer on MSVC from an [upstream bug]
  which although diagnosed to a particular revision isn't currently fixed
  upstream (and the bug itself doesn't seem too active). This commit is a
  partial revert of the suspected cause of this regression (found via a
  bisection). I'm sort of hoping that this eventually gets fixed upstream with a
  similar fix (which we can replace in our branch), but for now I'm also hoping
  it's a relatively harmless change to have.

After applying these patches (plus one [backport] which should be [backported
upstream][llvm-back]) I believe we should have all tests working on all
platforms in our current test suite. I'm like 99% sure that we'll need some more
backports as issues are reported for LLVM 6 when this propagates through
nightlies, but that's sort of just par for the course nowadays!

In any case though some extra scrutiny of the patches here would definitely be
welcome, along with scrutiny of the "missing patches" like a [change to pass
manager order](rust-lang/llvm@2717444753), [another change to pass manager
order](rust-lang/llvm@c782febb7b), some [compile fixes for
sparc](rust-lang/llvm@1a83de63c4), and some [fixes for
solaris](rust-lang/llvm@c2bfe0abb).

[patches4]: https://github.com/rust-lang/llvm/compare/5401fdf23...rust-llvm-release-4-0-1
[backport]: https://github.com/rust-lang/llvm/commit/5c54c252db
[llvm-back]: https://bugs.llvm.org/show_bug.cgi?id=36114
[upstream bug]: https://bugs.llvm.org/show_bug.cgi?id=36096

---

The update to LLVM 6 is desirable for a number of reasons, notably:

* This'll allow us to keep up with the upstream wasm backend, picking up new
  features as they start landing.
* Upstream LLVM has fixed a number of SIMD-related compilation errors,
  especially around AVX-512 and such.
* There's a few assorted known bugs which are fixed in LLVM 5 and aren't fixed
  in the LLVM 4 branch we're using.
* Overall it's not a great idea to stagnate with our codegen backend!

This update is mostly powered by #47730 which is allowing us to update LLVM
*independent* of the version of LLVM that Emscripten is locked to. This means
that when compiling code for Emscripten we'll still be using the old LLVM 4
backend, but when compiling code for any other target we'll be using the new
LLVM 6 target. Once Emscripten updates we may no longer need this distinction,
but we're not sure when that will happen!

Closes #43370
Closes #43418
Closes #47015
Closes #47683
Closes rust-lang-nursery/stdsimd#157
Closes rust-lang-nursery/rust-wasm#3
2018-02-09 17:13:14 -08:00
roblabla c04d86deeb Work around LLVM OCAML binding installation failure 2018-01-29 11:07:11 +01:00
Alex Crichton c6daea7c9a rustc: Split Emscripten to a separate codegen backend
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-28 18:32:45 -08:00
Alex Crichton 884715c654 rustc: Load the `rustc_trans` crate at runtime
Building on the work of # 45684 this commit updates the compiler to
unconditionally load the `rustc_trans` crate at runtime instead of linking to it
at compile time. The end goal of this work is to implement # 46819 where rustc
will have multiple backends available to it to load.

This commit starts off by removing the `extern crate rustc_trans` from the
driver. This involved moving some miscellaneous functionality into the
`TransCrate` trait and also required an implementation of how to locate and load
the trans backend. This ended up being a little tricky because the sysroot isn't
always the right location (for example `--sysroot` arguments) so some extra code
was added as well to probe a directory relative to the current dll (the
rustc_driver dll).

Rustbuild has been updated accordingly as well to have a separate compilation
invocation for the `rustc_trans` crate and assembly it accordingly into the
sysroot. Finally, the distribution logic for the `rustc` package was also
updated to slurp up the trans backends folder.

A number of assorted fallout changes were included here as well to ensure tests
pass and such, and they should all be commented inline.
2018-01-27 19:16:21 -08:00
Marco A L Barbosa 882cd3cf0b Add i586-unknown-linux-musl target 2018-01-11 15:57:28 -02:00
Tamir Duberstein 94d02b896c
*: strip calls to cc::Build::compile
The documentation states: "The name output should be the name of the
library." and this is already done in more recently-added callers.
2017-11-28 18:15:30 -05:00
Alex Crichton 48996f9e75 rustbuild: Enable WebAssembly backend by default
This commit alters how we compile LLVM by default enabling the WebAssembly
backend. This then also adds the wasm32-unknown-unknown target to get compiled
on the `cross` builder and distributed through rustup. Tests are not yet enabled
for this target but that should hopefully be coming soon!
2017-11-25 06:44:35 -08:00
Alex Crichton c11ac9441a rustbuild: Update the OpenSSL version to link
This updates the OpenSSL tarball download to reflect OpenSSL's newest release.
2017-11-04 08:05:46 -07:00
Michael Neumann aa4726cd37 Support Dragonfly when building Openssl 2017-10-29 18:42:04 +01:00
John Paul Adrian Glaubitz 929a8bc13f bootstrap: Add openssl configuration for sparc64-unknown-linux-gnu 2017-10-24 08:53:22 +02:00
Josh Stone 6f33108e4d bootstrap: update and enable the LLVM version-check
While the `config.toml.example` comments say "we automatically check the
version by default," we actually didn't.  That check was badly out of
date, only allowing 3.5, 3.6, or 3.7.  This it now updated to the new
3.9 minimum requirement, and truly enabled by default.
2017-10-16 13:10:16 -07:00
Vadim Petrochenkov 9e0fc5ccd0 rustbuild: Support specifying archiver and linker explicitly 2017-10-15 22:10:07 +03:00
kennytm 90d58a362a
rustbuild: Make openssl download more reliable.
1. Add -f flag to curl, so when the server returns 403 or 500 it will fail
   immediately.
2. Moved the checksum part into the retry loop, assuming checksum failure
   is due to broken download that can be fixed by downloading again.
2017-10-12 01:20:55 +08:00
Mark Simulacrum 20f892f549 Rollup merge of #44320 - jakllsch:jakllsch-caf2c3d2-c939-4c4d-8c68-1aecbd570fab, r=Mark-Simulacrum
Fix extended bootstrap issues with OpenSSL on NetBSD build hosts
2017-09-29 17:58:53 -06:00
bors 688a858391 Auto merge of #44785 - alexcrichton:update-cargo, r=nikomatsakis
Update some minor dependencies

* run `cargo update`
* Update cargo submodule
* Update to the `cc` crate from `gcc`
2017-09-28 16:19:58 +00:00
Alex Crichton 7694ca419b Update to the `cc` crate
This is the name the `gcc` crate has moved to
2017-09-28 07:45:50 -07:00
Jonathan A. Kollasch 90aa66bfc2 bootstrap: use tar -z on extract
Some tar(1) programs—such as NetBSD's—do not automatically decompress.
2017-09-27 11:17:42 -05:00
Jonathan A. Kollasch b53b853129 bootstrap: use shasum(1) on NetBSD build hosts
NetBSD doesn't ship with sha256sum.  The openssl build will probably
try to use perl anyway, so using perl's shasum is reasonable.
2017-09-27 11:17:42 -05: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
Alex Crichton 5cfee9b854 ci: Upload/download from a new S3 bucket
Moving buckets from us-east-1 to us-west-1 because us-west-1 is where
rust-central-station itself runs and in general is where we have all our other
buckets.
2017-09-16 08:35:47 -07:00
Corey Farwell 76799d1ea3 Rollup merge of #44131 - smaeul:openssl-perl, r=Mark-Simulacrum
Explicitly run perl for OpenSSL Configure

OpenSSL's Configure script is missing a shebang. On some platforms,
execve falls back to execution with the shell. Some other platforms,
like musl, will fail with an exec format error. Avoid this by calling
perl explicitly (since it's a perl script).
2017-09-14 22:32:31 -04:00
Mark Simulacrum 48dcebd586 Rollup merge of #44354 - jakllsch:jakllsch-85453197-a0cc-43f6-8c55-7bce6c4a4ebf, r=Mark-Simulacrum
bootstrap: openssl for NetBSD/sparc64 in extended build

r? @Mark-Simulacrum
2017-09-06 18:28:05 -06:00
Jonathan A. Kollasch 847d1ffbe9 bootstrap: avoid m4 -B for NetBSD-built sparc64 OpenSSL 2017-09-05 16:31:14 -05:00
Jonathan A. Kollasch 2047a0d083 bootstrap: add openssl config for sparc64-unknown-netbsd 2017-09-05 16:31:14 -05:00
Ralf Jung 13cf229037 disable gcc warnings 2017-09-05 18:46:26 +02:00
Ralf Jung 12d84cc009 update gcc crate
Use gcc::Build rather than deprecated gcc::Config.
Fixes #43973
2017-09-02 21:51:18 +02:00
Jonathan A. Kollasch 0c2a9d6917 bootstrap: add openssl configuration mapping for i686-unknown-netbsd 2017-08-30 18:22:46 -05:00
Samuel Holland adfebed9db Explicitly run perl for OpenSSL Configure
OpenSSL's Configure script is missing a shebang. On some platforms,
execve falls back to execution with the shell. Some other platforms,
like musl, will fail with an exec format error. Avoid this by calling
perl explicitly (since it's a perl script).
2017-08-28 11:22:11 -05:00
Fourchaux c7104be1a3 Fix typos & us spellings 2017-08-15 21:56:30 +02:00
bjorn3 e152a1620b
Build support for no llvm 2017-08-11 10:38:29 +02:00
Josh Stone 6c46f4f11c Use LLVM_LINK_LLVM_DYLIB only on linux-gnu and apple-darwin 2017-08-04 00:13:11 -07:00
Josh Stone ced1fda565 Exclude Windows from LLVM_LINK_LLVM_DYLIB 2017-08-03 15:42:05 -07:00
Josh Stone 1636a2cf41 Link LLVM tools dynamically
Set `LLVM_LINK_LLVM_DYLIB=ON` -- "If enabled, tools will be linked with
the libLLVM shared library."  Rust doesn't ship any of the LLVM tools,
and only needs a few at all for some test cases, so statically linking
the tools is just a waste of space.  I've also had memory issues on
slower machines with LLVM debuginfo enabled, when several tools start
linking in parallel consuming several GBs each.

With the default configuration, `build/x86_64-unknown-linux-gnu/llvm`
was 1.5GB before, now down to 731MB.  The difference is more drastic
with `--enable-llvm-release-debuginfo`, from 28GB to "only" 13GB.

This does not change the linking behavior of `rustc_llvm`.
2017-07-31 15:34:05 -07:00
Alex Crichton eb1c44b6ed rustbuild: Remove `--enable-llvm-clean-rebuild`
This was intended for bots back in the day where we'd persist caches of LLVM
builds across runs, but nowadays we don't do that on any of the bots so this
option is no longer necessary
2017-07-30 13:50:19 -07:00
Alex Crichton ad1f19479c rustbuild: Enable building LLVM
I use this from time to time debugging LLVM builds, useful to have!
2017-07-29 13:39:43 -07:00
Alex Crichton 069a1b3c8f rustbuild: Tweak how we cross-compile LLVM
In preparation for upgrading to LLVM 5.0 it looks like we need to tweak how we
cross compile LLVM slightly. It's using `CMAKE_SYSTEM_NAME` to infer whether to
build libFuzzer which only works on some platforms, and then once we configure
that it needs to apparently reach into the host build area to try to compile
`llvm-config` as well. Once these are both configured, though, it looks like we
can successfully cross-compile LLVM.
2017-07-28 12:20:47 -07:00