Skip to content

Commit 7a1b62f

Browse files
authored
Merge pull request #71 from blas-lapack-rs/vcpkgfix
x86-windows-static-md triplet for vcpkg
2 parents 3d06dc3 + 2c5e1cd commit 7a1b62f

File tree

3 files changed

+44
-16
lines changed

3 files changed

+44
-16
lines changed

.github/workflows/openblas-src.yml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
feature:
16-
- system
17-
- "system,static"
15+
triple:
16+
- x64-windows
17+
- x64-windows-static
18+
- x64-windows-static-md
1819
steps:
1920
- uses: actions/checkout@v1
2021
- uses: actions/cache@v2
@@ -26,22 +27,37 @@ jobs:
2627
git clone https://github.com/Microsoft/vcpkg.git --depth 1
2728
cd vcpkg
2829
./bootstrap-vcpkg.bat
29-
- name: Install static OpenBLAS by vcpkg
30-
run: |
31-
./vcpkg/vcpkg.exe install openblas:x64-windows-static
32-
if: ${{ matrix.feature == 'system,static' }}
3330
- name: Install OpenBLAS by vcpkg
3431
run: |
35-
./vcpkg/vcpkg.exe install openblas:x64-windows
36-
if: ${{ matrix.feature == 'system' }}
32+
./vcpkg/vcpkg.exe install openblas:${{ matrix.triple }}
33+
3734
- uses: actions-rs/cargo@v1
35+
name: Test features=system
3836
with:
3937
command: test
40-
args: >
41-
--features=${{ matrix.feature }}
42-
--manifest-path=openblas-src/Cargo.toml
38+
args: --features=system --manifest-path=openblas-src/Cargo.toml
39+
env:
40+
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
41+
if: ${{ matrix.triple == 'x64-windows' }}
42+
43+
- uses: actions-rs/cargo@v1
44+
name: Test features=system,static
45+
with:
46+
command: test
47+
args: --features=system,static --manifest-path=openblas-src/Cargo.toml
48+
env:
49+
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
50+
if: ${{ matrix.triple == 'x64-windows-static-md' }}
51+
52+
- uses: actions-rs/cargo@v1
53+
name: Test features=system,static with crt-static
54+
with:
55+
command: test
56+
args: --features=system,static --manifest-path=openblas-src/Cargo.toml
4357
env:
4458
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
59+
RUSTFLAGS: "-C target-feature=+crt-static"
60+
if: ${{ matrix.triple == 'x64-windows-static' }}
4561

4662
macos:
4763
runs-on: macos-10.15

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,26 @@ toolchain, install `openblas` for the `x64-windows` triplet:
3939
vcpkg install openblas --triplet x64-windows
4040
```
4141

42-
To link statically, install `openblas` for the `x64-windows-static` triplet:
42+
To link OpenBLAS statically, install `openblas` for the `x64-windows-static-md` triplet:
43+
44+
```sh
45+
vcpkg install openblas --triplet x64-windows-static-md
46+
```
47+
48+
To link OpenBLAS and C Runtime (CRT) statically, install `openblas` for the `x64-windows-static` triplet:
4349

4450
```sh
4551
vcpkg install openblas --triplet x64-windows-static
4652
```
4753

54+
and build with `+crt-static` option
55+
56+
```
57+
RUSTFLAGS='-C target-feature=+crt-static' cargo build --target x86_64-pc-windows-msvc
58+
```
59+
60+
Please see the ["Static and dynamic C runtimes" in The Rust reference](https://doc.rust-lang.org/reference/linkage.html#static-and-dynamic-c-runtimes) for detail.
61+
4862
## Cross Compilation
4963

5064
Apart from providing the `--target` option to `cargo build`, one also has to

openblas-src/build.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ fn windows_gnu_system() {
3131

3232
/// Use vcpkg for msvc "system" feature
3333
fn windows_msvc_system() {
34-
if feature_enabled("static") {
35-
env::set_var("CARGO_CFG_TARGET_FEATURE", "crt-static");
36-
} else {
34+
if !feature_enabled("static") {
3735
env::set_var("VCPKGRS_DYNAMIC", "1");
3836
}
3937
#[cfg(target_env = "msvc")]

0 commit comments

Comments
 (0)