Looking for help with build on Windows

There’s an error when I try to link a static library produced by Rust with a Haskell program on Windows (I think it’s version 11 already, will provide more precise details as needed). It’s either symbols not found or duplicate symbols. As far as I was able to research the problem, it might be related to UCRT support in Haskell. Rust added UCRT support quite awhile ago. And as I read in the issues on GHC gitlab, UCRT is supported by GHC too. For example, here:

The issue with more details and some logs is here:

And there’s a small repo if you want a quick way to reproduce the build error:

Any help is welcome, as this issue seems to be beyond my powers to solve.

1 Like

To offload the recent topic with release announcement, topping this up. The help is still much appreciated. Some of the ideas we’ve tested so far can be found in the comments for the linked discussion. In case someone wants to test it out, the minimal repo is the same, future-hs

The issue is not merely agreeing to link UCRT over msvcrt, the issue is that the Haskell toolchain is MingW (Clang, with libclang_rt.*), the Rust toolchain is MSVC, and the Rust GNU toolchain is MingW (GCC, with libgcc).

On another note, I looked again and found: *-pc-windows-gnullvm - The rustc book

Try targeting this one and pointing to the MingW of GHC.

But it says on the page that it doesn’t come with std compiled, you will need to build it with Cargo. Or recompile Rustc with the Haskell toolchain. Or recompile GHC with the Rust (GNU) toolchain.

This is a step forward! I thought that it’s an issue related to UCRT, but now you helped to clarify it, thank you for this research!

In perfect scenario I’d like to see both compilers use the same toolchain, MSVC in this case. But until that happens, x86_64-pc-windows-gnullvm Rust target might be a good option. I’m not sure about std, the platform page says this target has std built. And also:

The easiest way to obtain these targets is cross-compilation

So it might be possible to build for this target using the default Rust compiler.

And on top of that, I’ve just managed to compile MicroHS, which uses MSVC toolchain. This makes me curious how far can it compile this UI project (iced-hs I mean). Still, having two options is better than having none.

After you mentioned it, I’ve quickly searched through GHC issues and found this one: