Commit graph

32 commits

Author SHA1 Message Date
Tim Neumann 43a51b78b8 link agains relocatable libstdc++ 2017-03-21 20:37:50 +01:00
Tim Neumann 1f65610675 ci/netbsd: use the "official" cross compiler 2017-03-21 20:37:50 +01:00
Vadim Petrochenkov f2187093f8 Add/remove rerun-if-changed when necessary 2017-03-04 21:38:26 +03:00
Alex Crichton 77c3bfa742 std: Remove cfg(cargobuild) annotations
These are all now no longer needed that we've only got rustbuild in tree.
2017-02-06 08:42:54 -08:00
Jorge Aparicio 18d49288d5 PTX support
- `--emit=asm --target=nvptx64-nvidia-cuda` can be used to turn a crate
  into a PTX module (a `.s` file).

- intrinsics like `__syncthreads` and `blockIdx.x` are exposed as
  `"platform-intrinsics"`.

- "cabi" has been implemented for the nvptx and nvptx64 architectures.
  i.e. `extern "C"` works.

- a new ABI, `"ptx-kernel"`. That can be used to generate "global"
  functions. Example: `extern "ptx-kernel" fn kernel() { .. }`. All
  other functions are "device" functions.
2016-12-26 21:06:23 -05:00
bors b7e5148bbd Auto merge of #38314 - japaric:do-not-delete-enable-llvm-backend, r=alexcrichton
initial SPARC support

### UPDATE

Can now compile `no_std` executables with:

```
$ cargo new --bin app && cd $_

$ edit Cargo.toml && tail -n2 $_
[dependencies]
core = { path = "/path/to/rust/src/libcore" }

$ edit src/main.rs && cat $_
#![feature(lang_items)]
#![no_std]
#![no_main]

#[no_mangle]
pub fn _start() -> ! {
    loop {}
}

#[lang = "panic_fmt"]
fn panic_fmt() -> ! {
    loop {}
}

$ edit sparc-none-elf.json && cat $_
{
  "arch": "sparc",
  "data-layout": "E-m:e-p:32:32-i64:64-f128:64-n32-S64",
  "executables": true,
  "llvm-target": "sparc",
  "os": "none",
  "panic-strategy": "abort",
  "target-endian": "big",
  "target-pointer-width": "32"
}

$ cargo rustc --target sparc-none-elf -- -C linker=sparc-unknown-elf-gcc -C link-args=-nostartfiles

$ file target/sparc-none-elf/debug/app
app: ELF 32-bit MSB executable, SPARC, version 1 (SYSV), statically linked, not stripped

$ sparc-unknown-elf-readelf -h target/sparc-none-elf/debug/app
ELF Header:
  Magic:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Sparc
  Version:                           0x1
  Entry point address:               0x10074
  Start of program headers:          52 (bytes into file)
  Start of section headers:          1188 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         2
  Size of section headers:           40 (bytes)
  Number of section headers:         14
  Section header string table index: 11

$ sparc-unknown-elf-objdump -Cd target/sparc-none-elf/debug/app

target/sparc-none-elf/debug/app:     file format elf32-sparc

Disassembly of section .text:

00010074 <_start>:
   10074:       9d e3 bf 98     save  %sp, -104, %sp
   10078:       10 80 00 02     b  10080 <_start+0xc>
   1007c:       01 00 00 00     nop
   10080:       10 80 00 02     b  10088 <_start+0x14>
   10084:       01 00 00 00     nop
   10088:       10 80 00 00     b  10088 <_start+0x14>
   1008c:       01 00 00 00     nop
```

---

Someone wants to attempt launching some Rust [into space](https://www.reddit.com/r/rust/comments/5h76oa/c_interop/) but their platform is based on the SPARCv8 architecture. Let's not block them by enabling LLVM's SPARC backend.

Something very important that they'll also need is the "cabi" stuff as they'll be embedding some Rust code into a bigger C application (i.e. heavy use of `extern "C"`). The question there is what name(s) should we use for "target_arch" as the "cabi" implementation [varies according to that parameter](https://github.com/rust-lang/rust/blob/1.13.0/src/librustc_trans/abi.rs#L498-L523).

AFAICT, SPARCv8 is a 32-bit architecture and SPARCv9 is a 64-bit architecture. And, LLVM uses `sparc`, `sparcv9` and `sparcel` for [the architecture triple](ac1c94226e/include/llvm/ADT/Triple.h (L67-L69)) so perhaps we should use `target_arch = "sparc"` (32-bit) and `target_arch = "sparcv9"` (64-bit) as well.

r? @alexcrichton This PR only enables this LLVM backend when rustbuild is used. Do I also need to implement this for the old Makefile-based build system? Or are all our nightlies now being generated using rustbuild?

cc @brson
2016-12-26 20:48:43 +00:00
Jorge Aparicio 3ae912ac5d fix tidy 2016-12-19 12:23:56 -05:00
Jorge Aparicio bea6ab23f9 enable LLVM's SPARC backend 2016-12-19 12:23:37 -05:00
Sébastien Marie 2c39ee12a9 OpenBSD has two stdc++ libraries: use the newer
stdc++ is from base, and is an old library (GCC 4.2)
estdc++ is from ports, and is a recent library (GCC 4.9 currently)

as LLVM requires the newer version, use it if under OpenBSD.
2016-12-18 18:43:05 +01:00
bors 0bd2ce62b2 Auto merge of #37831 - rkruppe:llvm-attr-fwdcompat, r=eddyb
[LLVM 4.0] Use llvm::Attribute APIs instead of "raw value" APIs

The latter will be removed in LLVM 4.0 (see 4a6fc8bacf).

The librustc_llvm API remains mostly unchanged, except that llvm::Attribute is no longer a bitflag but represents only a *single* attribute.
The ability to store many attributes in a small number of bits and modify them without interacting with LLVM is only used in rustc_trans::abi and closely related modules, and only attributes for function arguments are considered there.
Thus rustc_trans::abi now has its own bit-packed representation of argument attributes, which are translated to rustc_llvm::Attribute when applying the attributes.

cc #37609
2016-11-19 16:39:25 -06:00
Josh Stone f3240377e6 rustbuild: update the llvm link logic further
There are now four static/shared scenarios that can happen for the
supported LLVM versions:

- 3.9+: By default use `llvm-config --link-static`
- 3.9+ and `--enable-llvm-link-shared`: Use `--link-shared` instead.
- 3.8: Use `llvm-config --shared-mode` and go with its answer.
- 3.7: Just assume static, maintaining the status quo.
2016-11-17 21:50:59 -08:00
Josh Stone f13391a603 rustbuild: allow dynamically linking LLVM
The makefiles and `mklldeps.py` called `llvm-config --shared-mode` to
find out if LLVM defaulted to shared or static libraries, and just went
with that.  But under rustbuild, `librustc_llvm/build.rs` was assuming
that LLVM should be static, and even forcing `--link-static` for 3.9+.

Now that build script also uses `--shared-mode` to learn the default,
which should work better for pre-3.9 configured for dynamic linking, as
it wasn't possible back then to choose differently via `llvm-config`.

Further, the configure script now has a new `--enable-llvm-link-shared`
option, which allows one to manually override `--link-shared` on 3.9+
instead of forcing static.
2016-11-16 23:28:14 -08:00
Robin Kruppe 5887ee5018 Rebuild rustc_llvm when the rustllvm source files change 2016-11-16 23:34:15 +01:00
Jorge Aparicio f5a05adb25 enable the MSP430 LLVM backend
to let people experiment with this target out of tree.

The MSP430 architecture is used in 16-bit microcontrollers commonly used
in Digital Signal Processing applications.
2016-11-12 17:33:35 -05:00
Alex Crichton cc2c812701 rustc_llvm: Require 3.9 for --link-static
Apparently stock Ubuntu 16.04 includes LLVM 3.8 which doesn't have this flag.
2016-11-09 09:12:38 -08:00
pweyck bcfbbd8645 Force static linking of LLVM
Run llvm-config with "--link-static" if available, to force static linking of LLVM.
This option was added in LLVM 3.8.

Fixes #36854
See also: #36996
2016-11-06 16:33:34 +01:00
Srinivas Reddy Thatiparthy 9972d17ecf
run rustfmt on librustc_llvm folder 2016-10-22 18:37:35 +05:30
Brian Anderson 37abec06e5 Tidy 2016-09-30 14:02:51 -07:00
Jan-Erik Rediger cb3f5799f4 Make the jsbackend an optional component 2016-09-30 14:02:41 -07:00
Jake Goulding cc8727e675 Report which required build-time environment variable is not set 2016-09-25 12:18:09 -04:00
Jorge Aparicio 027eab2f87 initial support for s390x
A new target, `s390x-unknown-linux-gnu`, has been added to the compiler
and can be used to build no_core/no_std Rust programs.

Known limitations:

- librustc_trans/cabi_s390x.rs is missing. This means no support for
  `extern "C" fn`.
- No support for this arch in libc. This means std can be cross compiled
  for this target.
2016-08-26 21:05:50 -05:00
Cameron Hart cbb88faad7 Merge branch 'master' into issue-30961 2016-08-06 15:50:48 +10:00
Ariel Ben-Yehuda 81df89fc2d remove the ExecutionEngine binding
the code has no tests and will just bitrot by itself.

this is a [breaking-change]
2016-08-03 15:08:47 +03:00
Cameron Hart fc210a8994 Make rust build pass LLVM_RUSTLLVM to C++ compiler 2016-07-29 23:09:32 +10:00
Alex Crichton 0509be1f6b Update parsing llvm-config output
Now it prints full paths on MSVC, but we're only interested in path names
2016-07-29 10:29:59 +02:00
Zack M. Davis d37edef9dd prefer if let to match with None => {} arm in some places
This is a spiritual succesor to #34268/8531d581, in which we replaced a
number of matches of None to the unit value with `if let` conditionals
where it was judged that this made for clearer/simpler code (as would be
recommended by Manishearth/rust-clippy's `single_match` lint). The same
rationale applies to matches of None to the empty block.
2016-07-03 16:27:02 -07:00
Srinivas Reddy Thatiparthy 593e1567ca run rustfmt on librustc_llvm folder 2016-05-29 14:57:34 +05:30
Andrea Canciani c883463e94 Implement feature extraction from TargetMachine
Add the `LLVMRustHasFeature` function to check whether a
`TargetMachine` has a given feature.
2016-04-09 00:39:04 +02:00
Alex Crichton 6ccf03c843 rustbuild: Fix 32-bit Windows build
Unfortunately on i686-pc-windows-gnu LLVM's answer to `--host-target` is
`x86_64-pc-windows-gnu` even though we're building in a 32-bit shell as well as
compiling 32-bit libraries. For now use Cargo's `HOST` environment variable to
determine whether we're doing a cross compilation or not.
2016-03-14 14:56:48 -07:00
Alex Crichton 526640668d rustbuild: Enable cross-compiling LLVM
Currently all multi-host builds assume the the build platform can run the
`llvm-config` binary generated for each host platform we're creating a compiler
for. Unfortunately this assumption isn't always true when cross compiling, so we
need to handle this case.

This commit alters the build script of `rustc_llvm` to understand when it's
running an `llvm-config` which is different than the platform we're targeting for.
2016-02-28 10:50:13 -08:00
Alex Crichton eac0a8bc30 bootstrap: Add directives to not double-link libs
Have all Cargo-built crates pass `--cfg cargobuild` and then add appropriate
`#[cfg]` definitions to all crates to avoid linking anything if this is passed.
This should help allow libstd to compile with both the makefiles and with Cargo.
2016-02-11 11:12:32 -08:00
Alex Crichton 4da4970767 bootstrap: Add build scripts for crates
This commits adds build scripts to the necessary Rust crates for all the native
dependencies. This is currently a duplication of the support found in mk/rt.mk
and is my best effort at representing the logic twice, but there may be some
unfortunate-and-inevitable divergence.

As a summary:

* alloc_jemalloc - build script to compile jemallocal
* flate - build script to compile miniz.c
* rustc_llvm - build script to run llvm-config and learn about how to link it.
  Note that this crucially (and will not ever) compile LLVM as that would take
  far too long.
* rustdoc - build script to compile hoedown
* std - script to determine lots of libraries/linkages as well as compile
  libbacktrace
2016-02-11 11:12:32 -08:00