Skip to content

Commit df2a6ed

Browse files
authored
ci: +crt-static flag on Windows (#3)
1 parent 9ed58d7 commit df2a6ed

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ jobs:
174174
yarn install
175175
176176
- name: Install wasi-sdk
177+
if: ${{ matrix.settings.target == 'wasm32-wasip1-threads' }}
177178
run: |
178179
mkdir -p $HOME/wasi-sdk
179180
curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz | tar -xzf - -C $HOME/wasi-sdk --strip-components=1
@@ -195,3 +196,9 @@ jobs:
195196
yarn build --target ${{ matrix.settings.target }}
196197
yarn build --target ${{ matrix.settings.target }} --release
197198
fi
199+
- name: Build with static CRT
200+
if: ${{ matrix.settings.target == 'x86_64-pc-windows-msvc' }}
201+
working-directory: example
202+
run: yarn build --target ${{ matrix.settings.target }} --release
203+
env:
204+
RUSTFLAGS: "-C target-feature=+crt-static -C link-arg=/FORCE:MULTIPLE"

libmimalloc-sys/build.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,15 @@ fn main() {
8383
cmake_config
8484
.define("MI_USE_CXX", "ON")
8585
.define("MI_WIN_USE_FIXED_TLS", "ON");
86-
if profile == "debug" {
87-
println!("cargo:rustc-link-lib=ucrtd");
88-
} else {
89-
println!("cargo:rustc-link-lib=ucrt");
86+
if !std::env::var("CARGO_CFG_TARGET_FEATURE")
87+
.map(|s| s.contains("+crt-static"))
88+
.unwrap_or(false)
89+
{
90+
if profile == "debug" {
91+
println!("cargo:rustc-link-lib=ucrtd");
92+
} else {
93+
println!("cargo:rustc-link-lib=ucrt");
94+
}
9095
}
9196
}
9297

0 commit comments

Comments
 (0)