Rust cross compilation to Windows with C dependency

I am trying to cross-compile a Rust crate with a C dependency. Here is a small example to reproduce the issue: GitHub - uulm-janbaudisch/nix-rust-windows

To build the crate, I use a toolchain from fenix with buildRustPackage. For the cross-compilation I create the rust environment with pkgs.pkgsCross.mingwW64.makeRustPlatform. It seems to work, but I was a bit confused as to whether I should have used crossSystem when importing nixpkgs instead. It seems this is not necessary, is that correct?

For the actual issue: When not including the C dependency (mimalloc in this case), the build works fine. But when including it, the build fails due to undefined references:

       [...]
       >    Compiling hello v0.1.0 (/build/2v29kwfsp13jjyg1ilb88mgyknrpwrry-source)
       > error: linking with `/nix/store/n3jds91918kpfibspiwaaafsg255aqgm-x86_64-w64-mingw32-gcc-wrapper-13.2.0/bin/x86_64-w64-mingw32-cc` failed: exit status: 1
       [...]
       >   = note: /nix/store/04l771kck5lwdc9qqwr1pbwb57y9i0fk-x86_64-w64-mingw32-binutils-2.41/bin/x86_64-w64-mingw32-ld: /nix/store/hzmc7pyrq4f35hbih0fvmxnzs0102cqs-x86_64-w64-mingw32-gcc-13.2.0/lib/gcc/x86_64-w64-mingw32/13.2.0/libgcc_eh.a(emutls.o):(.text+0x72): undefined reference to `_MCF_thread_self'
       >           /nix/store/04l771kck5lwdc9qqwr1pbwb57y9i0fk-x86_64-w64-mingw32-binutils-2.41/bin/x86_64-w64-mingw32-ld: /nix/store/hzmc7pyrq4f35hbih0fvmxnzs0102cqs-x86_64-w64-mingw32-gcc-13.2.0/lib/gcc/x86_64-w64-mingw32/13.2.0/libgcc_eh.a(emutls.o):(.text+0x8d): undefined reference to `__MCF_tls_table_get'
       >           /nix/store/04l771kck5lwdc9qqwr1pbwb57y9i0fk-x86_64-w64-mingw32-binutils-2.41/bin/x86_64-w64-mingw32-ld: /nix/store/hzmc7pyrq4f35hbih0fvmxnzs0102cqs-x86_64-w64-mingw32-gcc-13.2.0/lib/gcc/x86_64-w64-mingw32/13.2.0/libgcc_eh.a(emutls.o):(.text+0x120): undefined reference to `_MCF_mutex_unlock_slow'
       >           /nix/store/04l771kck5lwdc9qqwr1pbwb57y9i0fk-x86_64-w64-mingw32-binutils-2.41/bin/x86_64-w64-mingw32-ld: /nix/store/hzmc7pyrq4f35hbih0fvmxnzs0102cqs-x86_64-w64-mingw32-gcc-13.2.0/lib/gcc/x86_64-w64-mingw32/13.2.0/libgcc_eh.a(emutls.o):(.text+0x203): undefined reference to `__MCF_tls_table_xset'
       >           /nix/store/04l771kck5lwdc9qqwr1pbwb57y9i0fk-x86_64-w64-mingw32-binutils-2.41/bin/x86_64-w64-mingw32-ld: /nix/store/hzmc7pyrq4f35hbih0fvmxnzs0102cqs-x86_64-w64-mingw32-gcc-13.2.0/lib/gcc/x86_64-w64-mingw32/13.2.0/libgcc_eh.a(emutls.o):(.text+0x27d): undefined reference to `_MCF_once_wait_slow'
       >           /nix/store/04l771kck5lwdc9qqwr1pbwb57y9i0fk-x86_64-w64-mingw32-binutils-2.41/bin/x86_64-w64-mingw32-ld: /nix/store/hzmc7pyrq4f35hbih0fvmxnzs0102cqs-x86_64-w64-mingw32-gcc-13.2.0/lib/gcc/x86_64-w64-mingw32/13.2.0/libgcc_eh.a(emutls.o):(.text+0x291): undefined reference to `_MCF_tls_key_new'
       >           /nix/store/04l771kck5lwdc9qqwr1pbwb57y9i0fk-x86_64-w64-mingw32-binutils-2.41/bin/x86_64-w64-mingw32-ld: /nix/store/hzmc7pyrq4f35hbih0fvmxnzs0102cqs-x86_64-w64-mingw32-gcc-13.2.0/lib/gcc/x86_64-w64-mingw32/13.2.0/libgcc_eh.a(emutls.o):(.text+0x2a5): undefined reference to `_MCF_once_release'
       >           /nix/store/04l771kck5lwdc9qqwr1pbwb57y9i0fk-x86_64-w64-mingw32-binutils-2.41/bin/x86_64-w64-mingw32-ld: /nix/store/hzmc7pyrq4f35hbih0fvmxnzs0102cqs-x86_64-w64-mingw32-gcc-13.2.0/lib/gcc/x86_64-w64-mingw32/13.2.0/libgcc_eh.a(emutls.o):(.text+0x2da): undefined reference to `_MCF_mutex_lock_slow'
       >           /nix/store/04l771kck5lwdc9qqwr1pbwb57y9i0fk-x86_64-w64-mingw32-binutils-2.41/bin/x86_64-w64-mingw32-ld: /nix/store/hzmc7pyrq4f35hbih0fvmxnzs0102cqs-x86_64-w64-mingw32-gcc-13.2.0/lib/gcc/x86_64-w64-mingw32/13.2.0/libgcc_eh.a(emutls.o):(.text+0x2ef): undefined reference to `_MCF_once_abort'
       >           collect2: error: ld returned 1 exit status

I tried to add mcfgthreads with the following:

RUSTFLAGS = "-L native=${pkgs.pkgsCross.mingwW64.windows.mcfgthreads}/lib";

… but that didn’t work.

Does anyone know where these symbols come from or how to fix this issue?