Is there a way to statically link libunwind on x86-64-pc-windows-gnullvm?

⚓ rust    📅 2025-06-09    👤 surdeus    👁️ 1      

surdeus

I have been using x86-64-pc-windows-gnullvm since it got promoted to Tier 2 with Mingw-w64 CLANG C toolchain. However sometime earlier this year I noticed that the std library also got a dependency: libunwind.dll.

I don't know what std used instead before to generate completely stand-alone executables. Now I need libunwind.dll to be shipped with them. It is not the end of the world but now I need to adjust my build pipelines to discover the path of libunwind.dll and package it.

Mingw-w64 CLANG64 actually ships the statically linked libunwind.a variant (which I can link to the C/C++ programs). Is it possible to somehow guide rustc to use a statically linked variant too? I tried changing my $CARGO_HOME/config.toml as below but since std dynamically links libunwind.dll, I think this doesn't work:

[target.x86_64-pc-windows-gnullvm]
linker = "T:/msys2/clang64/bin/clang.exe"
rustflags = [
    "-Clink-arg=T:/msys2/clang64/lib/libunwind.a"
]

The other alternative I tried:

[target.x86_64-pc-windows-gnullvm]
linker = "T:/msys2/clang64/bin/clang.exe"
rustflags = [
    "-Clink-arg=-Wl,-Bstatic",
    "-Clink-arg=-Wl,-lunwind",
    "-Clink-arg=-Wl,-Bdynamic",
]

Here are the screenshots from the DLL dependencies from the latest stable (1.87) and the version I used to use 1.83. Something has changed and now there is an external dependency on libunwind.dll:

Untitled

1 post - 1 participant

Read full topic

🏷️ rust_feed