flake: hack-link libstdc++ statically on Windows. Closes #175

This commit is contained in:
Sebastien Bourdeauducq 2022-01-24 16:54:05 +08:00
parent 8e01a20ac3
commit e891683f2e
1 changed files with 8 additions and 0 deletions

View File

@ -160,6 +160,14 @@
buildInputs = [ pkgs-mingw.zlib ];
configurePhase =
''
# Link libstdc++ statically. As usual with cargo, this is an adventure.
cp --no-preserve=mode,ownership -R $CARGO_HOME/cargo-vendor-dir/llvm-sys-130.0.1/ llvm-sys-130.0.1
substituteInPlace llvm-sys-130.0.1/build.rs --replace "cargo:rustc-link-lib=dylib=" "cargo:rustc-link-lib=static="
substituteInPlace llvm-sys-130.0.1/build.rs --replace "fn main() {" "fn main() { println!(\"cargo:rustc-link-search=native=${pkgs-mingw.stdenv.cc.cc}/x86_64-w64-mingw32/lib\");"
chmod 755 $CARGO_HOME/cargo-vendor-dir
rm $CARGO_HOME/cargo-vendor-dir/llvm-sys-130.0.1
mv llvm-sys-130.0.1 $CARGO_HOME/cargo-vendor-dir/llvm-sys-130.0.1
export PYO3_CONFIG_FILE=${pyo3-mingw-config}
mkdir llvm-cfg