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);
```
Tests that modify environment variables (e.g. CFLAGS and CXXFLAGS) can
cause tests to fail when run in parallel because they change a shared
context.
This change moves the problematic tests into separate modules. Since
each `tests/*.rs` is compiled as a separate crate, these tests are not
run in parallel with other tests.
If CFLAGS/CXXFLAGS is defined in the environment, then presumably the consumer has already determined the set of warnings flags to pass to the compiler, so we shouldn't enable warnings by default in that case.
Right now we add them before, and we add -Wall by default. This allows
users to manually turn off specific warnings, without having to resort
to a dance of:
```
.warnings(false)
.flag("-Wall")
.flag("-Wno-foo")
```
This strikes a good balance of keeping -Wall on by default, while
minimising the surprising experience observed in
https://github.com/alexcrichton/cc-rs/issues/235.
These were accepted in https://github.com/alexcrichton/gcc-rs/pull/212, but never actually worked and weren't being tested. This fixes the logic errors that prevented the new style from working, and also updates the tests to use the new style.
It allows one to add a flag to the compiler on the condition that the
compiler supports it.
We check if the compiler supports the flag by trying to compile a
simple executable. If there is some output on stderr we consider that
the compiler failed and the flag is not supported.
This adds two configuration options to optionally enable or disable
the `-shared` and `-static` flags. If omitted, musl targets enable
`-static` by default.