We almost never use it anyway and it's an extra dependency that
complicates the build process of rust-lang/rust. Let's just stick to a
smaller default in the case that we're running entirely outside of a
Cargo context, which should be pretty rare anyway.
This commit reimplements parallel compilation support with a few goals
in mind:
* Primarily the `jobserver` crate is now used to limit parallelism
across build scripts
* The `rayon` crate is no longer used to ensure this is a pretty
lightweight dependency crate.
It's hoped that after this bakes for a bit we may be able to turn this
on by default!
Tested building https://github.com/trolleyman/cuda-macros with this (the `cuda-macros-test` crate) and it builds & links correctly. Haven't had a chance to test that this runs yet, but will in the morning.
I wasn't sure that this way is the most elegant, but this seemed like the way that did the least amount of changes. I am also not sure that this is the correct way of doing this, especially regarding cross-compiling, but it gets it up and running at least.
To test you can do a `cargo build` in the root of the repo linked above. The build stuff is a bit hacky, but essentially it generates the CUDA function below & calls it.
```c
extern "C" __global__ void hello(int32_t* x, int32_t y) {
printf("Hello from block %d, thread %d (y=%d)\n", blockIdx.x, threadIdx.x, y);
*x = 2;
}
```
```rust
extern "C" unsafe fn hello(x: *mut i32, y: i32);
```
If it isn't set, fallback to the previous setting of `-miphoneos-version-min=7.0` for real devices and `mios-simulator-version-min=7.0` for simulators.
Pick the correct softfloat mode based on bitness:
- `-mabi=lp64` for 64 bit RISC-V
- `-mabi=ilp32` for 32-bit RISC-V
Currently it fails for rv32 due to a conflict between the ABI and arch:
cc1: error: ABI requires -march=rv64
Rust's linker cannot currently handle gcc's fPIC compilation units
for RISC-V targets:
= note: rust-lld: error:
.got section detected in the input files. Dynamic relocations are not
supported. If you are linking to C code compiled using the `gcc` crate
then modify your build script to compile the C code _without_ the
-fPIC flag. See the documentation of the `gcc::Config.fpic` method for
details.
So disable PIC by default for now for `riscv` targets.
Automatically choose the most common name for the toolchain, and add the
command-line arguments to generate code that is compatible with the
chosen architecture.
Fixes#397.