* Detect and use `sccache` via `RUSTC_WRAPPER`
If no other C/C++ caching tool is found by inspecting `CC` and `CXX`,
`RUSTC_WRAPPER` is tested to see if an output-caching wrapper for
`rustc` is in use. If that is the case and it is a wrapper known to also
support C/C++ caching, use it.
(Also correct/clarify a misnamed variable that caused me some confusion
looking over the code.)
* Support RUSTC_WRAPPER on Windows and with absolute paths
When checking for possible `RUSTC_WRAPPER`s that we can use to cache
C/C++ output, allow for filename extensions (e.g. `sccache.exe`) and
absolute paths (e.g. `/usr/local/bin/sccache`).
Closes#473
Some test cases check that a compiler flag is not present. But
cc::Build loads additional flags from the CFLAGS and CXXFLAGS
environment variables. If these are set, they might interfere with the
test cases.
Therefore we clear the CFLAGS and CXXFLAGS environment variables before
running a test that requires an absent flag.
With rust-lang/rust#62281, rust compiles in mcmodel=medium mode
which is equivalent to GCC medany. This prevents linker relocation
errors code is placed outside the range `-0x80000000..0x7ffffffff`.
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.