-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Description
Steps To Reproduce
Steps to reproduce the behavior:
- nix build "github:nixos/nixpkgs/a8f699a5730a#pkgsCross.mingwW64.mingw_w64_pthreads"
Build log
Build Log
x86_64-w64-mingw32-ar cru fakelib/libgcc.a src/libgcc/dll_dependency.o src/libgcc/dll_math.o
x86_64-w64-mingw32-ar: `u' modifier ignored since `D' is the default (see `U')
x86_64-w64-mingw32-ranlib fakelib/libgcc.a
rm -f fakelib/libgcc_eh.a
x86_64-w64-mingw32-ar cru fakelib/libgcc_eh.a
x86_64-w64-mingw32-ar: `u' modifier ignored since `D' is the default (see `U')
x86_64-w64-mingw32-ranlib fakelib/libgcc_eh.a
rm -f fakelib/libgcc_s.a
x86_64-w64-mingw32-ar cru fakelib/libgcc_s.a
x86_64-w64-mingw32-ar: `u' modifier ignored since `D' is the default (see `U')
x86_64-w64-mingw32-ranlib fakelib/libgcc_s.a
/nix/store/p6k7xp1lsfmbdd731mlglrdj2d66mr82-bash-5.2p37/bin/bash ./libtool --tag=CC --mode=link x86_64-w64-mingw32-gcc -Wall -DWIN32_LEAN_AND_MEAN -g -O2 -no-undefined -version-info 1:0:0 -L./fakelib -Wc,-no-pthread -o libwinpthread.la -rpath /nix/store/99n0xrfyx4awn6370avb3ihr03hxyavp-mingw_w64-pthreads-x86_64-w64-mingw32-12.0.0/lib src/libwinpthread_la-barrier.lo src/libwinpthread_la-cond.lo src/libwinpthread_la-misc.lo src/libwinpthread_la-mutex.lo src/libwinpthread_la-rwlock.lo src/libwinpthread_la-spinlock.lo src/libwinpthread_la-thread.lo src/libwinpthread_la-ref.lo src/libwinpthread_la-sem.lo src/libwinpthread_la-sched.lo src/libwinpthread_la-clock.lo src/libwinpthread_la-nanosleep.lo src/version.lo
libtool: link: x86_64-w64-mingw32-gcc -shared src/.libs/libwinpthread_la-barrier.o src/.libs/libwinpthread_la-cond.o src/.libs/libwinpthread_la-misc.o src/.libs/libwinpthread_la-mutex.o src/.libs/libwinpthread_la-rwlock.o src/.libs/libwinpthread_la-spinlock.o src/.libs/libwinpthread_la-thread.o src/.libs/libwinpthread_la-ref.o src/.libs/libwinpthread_la-sem.o src/.libs/libwinpthread_la-sched.o src/.libs/libwinpthread_la-clock.o src/.libs/libwinpthread_la-nanosleep.o src/.libs/version.o -L./fakelib -g -O2 -no-pthread -o .libs/libwinpthread-1.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libwinpthread.dll.a
/nix/store/p20jshmrrnksvkspp6rplrb7bhllhpqf-x86_64-w64-mingw32-binutils-2.43.1/bin/x86_64-w64-mingw32-ld: src/.libs/libwinpthread_la-thread.o: in function `pthread_create_wrapper':
/build/mingw-w64-v12.0.0/mingw-w64-libraries/winpthreads/src/thread.c:1544:(.text+0xb38): undefined reference to `__intrinsic_setjmpex'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:706: libwinpthread.la] Error 1
make[2]: Leaving directory '/build/mingw-w64-v12.0.0/mingw-w64-libraries/winpthreads'
make[1]: *** [Makefile:908: all-recursive] Error 1
make[1]: Leaving directory '/build/mingw-w64-v12.0.0/mingw-w64-libraries/winpthreads'
make: *** [Makefile:514: all] Error 2
Additional context
This error appears related to the new default of using ucrt as the default in mingw-w64. When I change the build to use ucrt instead of msvcrt with the following change set, the pthreads library will successfully compile. However, changing the underlying C library seems like a drastic step to take in this case.
This very well might be an upstream issue, due to the fact that changing the underlying C library for the MinGW builds fixes the problem. However, I have not yet made a complete determination of that. I would appreciate some help figuring out if this is a Nix-specific issue or if there is a related upstream issue that might be the cause of it.
Details
This patch allows the library to build, for me, but obviously the change would result in very different and likely incompatible binaries for anyone trying to mix the results of the two outputs.
diff --git a/lib/systems/default.nix b/lib/systems/default.nix
index d682eb815003..1f8aae2f763b 100644
--- a/lib/systems/default.nix
+++ b/lib/systems/default.nix
@@ -95,7 +95,8 @@ let
libc =
/**/ if final.isDarwin then "libSystem"
- else if final.isMinGW then "msvcrt"
+ else if final.isMinGW && final.isx86_64 then "ucrt"
+ else if final.isMinGW && !final.isx86_64 then "msvcrt"
else if final.isWasi then "wasilibc"
else if final.isWasm && !final.isWasi then null
else if final.isRedox then "relibc"
diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix
index 223de50f67dd..45f11b31bd67 100644
--- a/lib/systems/examples.nix
+++ b/lib/systems/examples.nix
@@ -317,7 +317,7 @@ rec {
mingwW64 = {
# That's the triplet they use in the mingw-w64 docs.
config = "x86_64-w64-mingw32";
- libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
+ libc = "ucrt"; # This distinguishes the mingw (non posix) toolchain
};
ucrt64 = {
Notify maintainers
Not sure if you're the maintainer, as I can't find the maintainers info for those mingw-w64 libraries, but you're the last one in the pthreads file.
Note for maintainers: Please tag this issue in your PR.
Add a 👍 reaction to issues you find important.