nac3artiq module fails to load with latest msys2 #175

Closed
opened 2022-01-24 14:48:07 +08:00 by sb10q · 6 comments
1cbc:028c @ 01393031 - LdrpResolveDllName - ENTER: DLL name: C:\msys64\mingw64\bin\libstdc++-6.dll
1cbc:02a0 @ 01393031 - LdrpFindKnownDll - ENTER: DLL name: zlib1.dll
1cbc:02a0 @ 01393031 - LdrpFindKnownDll - RETURN: Status: 0xc0000135
1cbc:1fac @ 01393031 - LdrpSearchPath - ENTER: DLL name: zlib1.dll
1cbc:1fac @ 01393031 - LdrpResolveDllName - ENTER: DLL name: C:\msys64\mingw64\bin\zlib1.dll
1cbc:028c @ 01393031 - LdrpResolveDllName - RETURN: Status: 0x00000000
1cbc:028c @ 01393031 - LdrpSearchPath - RETURN: Status: 0x00000000
1cbc:1fac @ 01393031 - LdrpResolveDllName - RETURN: Status: 0x00000000
1cbc:1fac @ 01393031 - LdrpSearchPath - RETURN: Status: 0x00000000
1cbc:028c @ 01393031 - LdrpMinimalMapModule - ENTER: DLL name: C:\msys64\mingw64\bin\libstdc++-6.dll
1cbc:1fac @ 01393046 - LdrpMinimalMapModule - ENTER: DLL name: C:\msys64\mingw64\bin\zlib1.dll
ModLoad: 00007fff`09200000 00007fff`09224000   C:\msys64\mingw64\bin\zlib1.dll
1cbc:1fac @ 01393046 - LdrpMinimalMapModule - RETURN: Status: 0x00000000
ModLoad: 00007ffe`e5e00000 00007ffe`e5fe5000   C:\msys64\mingw64\bin\libstdc++-6.dll
1cbc:028c @ 01393046 - LdrpMinimalMapModule - RETURN: Status: 0x00000000
1cbc:1fac @ 01393046 - LdrpFindDllActivationContext - INFO: Probing for the manifest of DLL "C:\msys64\mingw64\bin\zlib1.dll" failed with status 0xc0000089
1cbc:0768 @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlDeleteCriticalSection" by name
1cbc:028c @ 01393046 - LdrpFindDllActivationContext - INFO: Probing for the manifest of DLL "C:\msys64\mingw64\bin\libstdc++-6.dll" failed with status 0xc0000089
1cbc:0768 @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlEnterCriticalSection" by name
1cbc:0768 @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlInitializeCriticalSection" by name
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "SystemFunction036" by name
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlAcquireSRWLockExclusive" by name
1cbc:0768 @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlLeaveCriticalSection" by name
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlAcquireSRWLockShared" by name
1cbc:028c @ 01393046 - LdrpFindKnownDll - ENTER: DLL name: libgcc_s_seh-1.dll
1cbc:028c @ 01393046 - LdrpFindKnownDll - RETURN: Status: 0xc0000135
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlAddVectoredExceptionHandler" by name
1cbc:028c @ 01393046 - LdrpFindKnownDll - ENTER: DLL name: libwinpthread-1.dll
1cbc:028c @ 01393046 - LdrpFindKnownDll - RETURN: Status: 0xc0000135
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlDeleteCriticalSection" by name
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlEnterCriticalSection" by name
1cbc:1fac @ 01393046 - LdrpPreprocessDllName - INFO: DLL api-ms-win-core-sysinfo-l1-1-0 was redirected to C:\Windows\SYSTEM32\kernelbase.dll by API set
1cbc:0768 @ 01393046 - LdrpSearchPath - ENTER: DLL name: libgcc_s_seh-1.dll
1cbc:028c @ 01393046 - LdrpSearchPath - ENTER: DLL name: libwinpthread-1.dll
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "GetLogicalProcessorInformationEx" by name
1cbc:028c @ 01393046 - LdrpResolveDllName - ENTER: DLL name: C:\msys64\mingw64\bin\libwinpthread-1.dll
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlAllocateHeap" by name
1cbc:0768 @ 01393046 - LdrpResolveDllName - ENTER: DLL name: C:\msys64\mingw64\bin\libgcc_s_seh-1.dll
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlReAllocateHeap" by name
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlInitializeCriticalSection" by name
1cbc:028c @ 01393046 - LdrpResolveDllName - RETURN: Status: 0x00000000
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlLeaveCriticalSection" by name
1cbc:028c @ 01393046 - LdrpSearchPath - RETURN: Status: 0x00000000
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlReleaseSRWLockExclusive" by name
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlReleaseSRWLockShared" by name
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlRemoveVectoredExceptionHandler" by name
1cbc:1fac @ 01393046 - LdrpPreprocessDllName - INFO: DLL api-ms-win-core-synch-l1-2-0 was redirected to C:\Windows\SYSTEM32\kernelbase.dll by API set
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "SleepConditionVariableSRW" by name
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlTryAcquireSRWLockExclusive" by name
1cbc:028c @ 01393046 - LdrpMinimalMapModule - ENTER: DLL name: C:\msys64\mingw64\bin\libwinpthread-1.dll
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlTryEnterCriticalSection" by name
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlWakeAllConditionVariable" by name
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlWakeConditionVariable" by name
ModLoad: 00007fff`09a10000 00007fff`09a26000   C:\msys64\mingw64\bin\libwinpthread-1.dll
1cbc:1fac @ 01393046 - LdrpPreprocessDllName - INFO: DLL api-ms-win-core-com-l1-1-0 was redirected to C:\Windows\SYSTEM32\combase.dll by API set
1cbc:028c @ 01393046 - LdrpMinimalMapModule - RETURN: Status: 0x00000000
1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "CoTaskMemFree" by name
1cbc:0768 @ 01393046 - LdrpResolveDllName - RETURN: Status: 0x00000000
1cbc:0768 @ 01393046 - LdrpSearchPath - RETURN: Status: 0x00000000
1cbc:028c @ 01393046 - LdrpFindDllActivationContext - INFO: Probing for the manifest of DLL "C:\msys64\mingw64\bin\libwinpthread-1.dll" failed with status 0xc000008a
1cbc:028c @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlAddVectoredExceptionHandler" by name
1cbc:028c @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlDeleteCriticalSection" by name
1cbc:028c @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlEnterCriticalSection" by name
1cbc:028c @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlInitializeCriticalSection" by name
1cbc:028c @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlLeaveCriticalSection" by name
1cbc:028c @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlRemoveVectoredExceptionHandler" by name
1cbc:0768 @ 01393046 - LdrpMinimalMapModule - ENTER: DLL name: C:\msys64\mingw64\bin\libgcc_s_seh-1.dll
1cbc:028c @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlTryEnterCriticalSection" by name
1cbc:1fac @ 01393046 - LdrpNameToOrdinal - WARNING: Procedure "_ZSt14__once_functor" could not be located in DLL at base 0x00007FFEE5E00000.
1cbc:1fac @ 01393046 - LdrpReportError - ERROR: Locating export "_ZSt14__once_functor" for DLL "C:\msys64\mingw64\lib\python3.9\site-packages\nac3artiq.pyd" failed with status: 0xc0000139.
(1cbc.1fac): Unknown exception - code c0000139 (first chance)
1cbc:1fac @ 01393046 - LdrpGenericExceptionFilter - ERROR: Function LdrpSnapModule raised exception 0xc0000139
	Exception record: .exr 000000FFF97BE870
	Context record: .cxr 000000FFF97BE380
ModLoad: 00007fff`091e0000 00007fff`091fc000   C:\msys64\mingw64\bin\libgcc_s_seh-1.dll
1cbc:0768 @ 01393062 - LdrpMinimalMapModule - RETURN: Status: 0x00000000
1cbc:0768 @ 01393062 - LdrpFindDllActivationContext - INFO: Probing for the manifest of DLL "C:\msys64\mingw64\bin\libgcc_s_seh-1.dll" failed with status 0xc0000089
1cbc:0768 @ 01393062 - LdrpProcessWork - ERROR: Unable to load DLL: "libgcc_s_seh-1.dll", Parent Module: "C:\msys64\mingw64\bin\libstdc++-6.dll", Status: 0xc0000139
1cbc:02a0 @ 01393062 - LdrpLoadDllInternal - RETURN: Status: 0xc0000139
1cbc:02a0 @ 01393062 - LdrLoadDll - RETURN: Status: 0xc0000139

to obtain those traces:

  1. install https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-download-tools
  2. gflags /i python.exe +sls
  3. start Python in MSYS2
  4. attach to the python process with windbg and enter the g command
  5. import nac3artiq
``` 1cbc:028c @ 01393031 - LdrpResolveDllName - ENTER: DLL name: C:\msys64\mingw64\bin\libstdc++-6.dll 1cbc:02a0 @ 01393031 - LdrpFindKnownDll - ENTER: DLL name: zlib1.dll 1cbc:02a0 @ 01393031 - LdrpFindKnownDll - RETURN: Status: 0xc0000135 1cbc:1fac @ 01393031 - LdrpSearchPath - ENTER: DLL name: zlib1.dll 1cbc:1fac @ 01393031 - LdrpResolveDllName - ENTER: DLL name: C:\msys64\mingw64\bin\zlib1.dll 1cbc:028c @ 01393031 - LdrpResolveDllName - RETURN: Status: 0x00000000 1cbc:028c @ 01393031 - LdrpSearchPath - RETURN: Status: 0x00000000 1cbc:1fac @ 01393031 - LdrpResolveDllName - RETURN: Status: 0x00000000 1cbc:1fac @ 01393031 - LdrpSearchPath - RETURN: Status: 0x00000000 1cbc:028c @ 01393031 - LdrpMinimalMapModule - ENTER: DLL name: C:\msys64\mingw64\bin\libstdc++-6.dll 1cbc:1fac @ 01393046 - LdrpMinimalMapModule - ENTER: DLL name: C:\msys64\mingw64\bin\zlib1.dll ModLoad: 00007fff`09200000 00007fff`09224000 C:\msys64\mingw64\bin\zlib1.dll 1cbc:1fac @ 01393046 - LdrpMinimalMapModule - RETURN: Status: 0x00000000 ModLoad: 00007ffe`e5e00000 00007ffe`e5fe5000 C:\msys64\mingw64\bin\libstdc++-6.dll 1cbc:028c @ 01393046 - LdrpMinimalMapModule - RETURN: Status: 0x00000000 1cbc:1fac @ 01393046 - LdrpFindDllActivationContext - INFO: Probing for the manifest of DLL "C:\msys64\mingw64\bin\zlib1.dll" failed with status 0xc0000089 1cbc:0768 @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlDeleteCriticalSection" by name 1cbc:028c @ 01393046 - LdrpFindDllActivationContext - INFO: Probing for the manifest of DLL "C:\msys64\mingw64\bin\libstdc++-6.dll" failed with status 0xc0000089 1cbc:0768 @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlEnterCriticalSection" by name 1cbc:0768 @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlInitializeCriticalSection" by name 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "SystemFunction036" by name 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlAcquireSRWLockExclusive" by name 1cbc:0768 @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlLeaveCriticalSection" by name 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlAcquireSRWLockShared" by name 1cbc:028c @ 01393046 - LdrpFindKnownDll - ENTER: DLL name: libgcc_s_seh-1.dll 1cbc:028c @ 01393046 - LdrpFindKnownDll - RETURN: Status: 0xc0000135 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlAddVectoredExceptionHandler" by name 1cbc:028c @ 01393046 - LdrpFindKnownDll - ENTER: DLL name: libwinpthread-1.dll 1cbc:028c @ 01393046 - LdrpFindKnownDll - RETURN: Status: 0xc0000135 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlDeleteCriticalSection" by name 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlEnterCriticalSection" by name 1cbc:1fac @ 01393046 - LdrpPreprocessDllName - INFO: DLL api-ms-win-core-sysinfo-l1-1-0 was redirected to C:\Windows\SYSTEM32\kernelbase.dll by API set 1cbc:0768 @ 01393046 - LdrpSearchPath - ENTER: DLL name: libgcc_s_seh-1.dll 1cbc:028c @ 01393046 - LdrpSearchPath - ENTER: DLL name: libwinpthread-1.dll 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "GetLogicalProcessorInformationEx" by name 1cbc:028c @ 01393046 - LdrpResolveDllName - ENTER: DLL name: C:\msys64\mingw64\bin\libwinpthread-1.dll 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlAllocateHeap" by name 1cbc:0768 @ 01393046 - LdrpResolveDllName - ENTER: DLL name: C:\msys64\mingw64\bin\libgcc_s_seh-1.dll 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlReAllocateHeap" by name 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlInitializeCriticalSection" by name 1cbc:028c @ 01393046 - LdrpResolveDllName - RETURN: Status: 0x00000000 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlLeaveCriticalSection" by name 1cbc:028c @ 01393046 - LdrpSearchPath - RETURN: Status: 0x00000000 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlReleaseSRWLockExclusive" by name 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlReleaseSRWLockShared" by name 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlRemoveVectoredExceptionHandler" by name 1cbc:1fac @ 01393046 - LdrpPreprocessDllName - INFO: DLL api-ms-win-core-synch-l1-2-0 was redirected to C:\Windows\SYSTEM32\kernelbase.dll by API set 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "SleepConditionVariableSRW" by name 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlTryAcquireSRWLockExclusive" by name 1cbc:028c @ 01393046 - LdrpMinimalMapModule - ENTER: DLL name: C:\msys64\mingw64\bin\libwinpthread-1.dll 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlTryEnterCriticalSection" by name 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlWakeAllConditionVariable" by name 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlWakeConditionVariable" by name ModLoad: 00007fff`09a10000 00007fff`09a26000 C:\msys64\mingw64\bin\libwinpthread-1.dll 1cbc:1fac @ 01393046 - LdrpPreprocessDllName - INFO: DLL api-ms-win-core-com-l1-1-0 was redirected to C:\Windows\SYSTEM32\combase.dll by API set 1cbc:028c @ 01393046 - LdrpMinimalMapModule - RETURN: Status: 0x00000000 1cbc:1fac @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "CoTaskMemFree" by name 1cbc:0768 @ 01393046 - LdrpResolveDllName - RETURN: Status: 0x00000000 1cbc:0768 @ 01393046 - LdrpSearchPath - RETURN: Status: 0x00000000 1cbc:028c @ 01393046 - LdrpFindDllActivationContext - INFO: Probing for the manifest of DLL "C:\msys64\mingw64\bin\libwinpthread-1.dll" failed with status 0xc000008a 1cbc:028c @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlAddVectoredExceptionHandler" by name 1cbc:028c @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlDeleteCriticalSection" by name 1cbc:028c @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlEnterCriticalSection" by name 1cbc:028c @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlInitializeCriticalSection" by name 1cbc:028c @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlLeaveCriticalSection" by name 1cbc:028c @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlRemoveVectoredExceptionHandler" by name 1cbc:0768 @ 01393046 - LdrpMinimalMapModule - ENTER: DLL name: C:\msys64\mingw64\bin\libgcc_s_seh-1.dll 1cbc:028c @ 01393046 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlTryEnterCriticalSection" by name 1cbc:1fac @ 01393046 - LdrpNameToOrdinal - WARNING: Procedure "_ZSt14__once_functor" could not be located in DLL at base 0x00007FFEE5E00000. 1cbc:1fac @ 01393046 - LdrpReportError - ERROR: Locating export "_ZSt14__once_functor" for DLL "C:\msys64\mingw64\lib\python3.9\site-packages\nac3artiq.pyd" failed with status: 0xc0000139. (1cbc.1fac): Unknown exception - code c0000139 (first chance) 1cbc:1fac @ 01393046 - LdrpGenericExceptionFilter - ERROR: Function LdrpSnapModule raised exception 0xc0000139 Exception record: .exr 000000FFF97BE870 Context record: .cxr 000000FFF97BE380 ModLoad: 00007fff`091e0000 00007fff`091fc000 C:\msys64\mingw64\bin\libgcc_s_seh-1.dll 1cbc:0768 @ 01393062 - LdrpMinimalMapModule - RETURN: Status: 0x00000000 1cbc:0768 @ 01393062 - LdrpFindDllActivationContext - INFO: Probing for the manifest of DLL "C:\msys64\mingw64\bin\libgcc_s_seh-1.dll" failed with status 0xc0000089 1cbc:0768 @ 01393062 - LdrpProcessWork - ERROR: Unable to load DLL: "libgcc_s_seh-1.dll", Parent Module: "C:\msys64\mingw64\bin\libstdc++-6.dll", Status: 0xc0000139 1cbc:02a0 @ 01393062 - LdrpLoadDllInternal - RETURN: Status: 0xc0000139 1cbc:02a0 @ 01393062 - LdrLoadDll - RETURN: Status: 0xc0000139 ``` to obtain those traces: 1. install https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-download-tools 2. `gflags /i python.exe +sls` 3. start Python in MSYS2 4. attach to the python process with windbg and enter the `g` command 5. `import nac3artiq`
sb10q changed title from nac3artiq cmodule fails to load with latest msys2 to nac3artiq module fails to load with latest msys2 2022-01-24 14:48:21 +08:00
Poster
Owner
may be useful: https://users.rust-lang.org/t/linking-against-c-dependencies/25099
Poster
Owner

No dice, cargo is being a pain in the neck as usual...

diff --git a/flake.nix b/flake.nix
index 2844256..768a995 100644
--- a/flake.nix
+++ b/flake.nix
@@ -172,7 +172,8 @@
               chmod +x llvm-cfg/llvm-config
               export PATH=`pwd`/llvm-cfg:$PATH
 
-              export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUSTFLAGS="-C link-arg=-lz -C link-arg=-luuid -C link-arg=-lole32 -C link-arg=-lmcfgthread"
+              export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUSTFLAGS="-C link-arg=-lz -C link-arg=-luuid -C link-arg=-lole32 -C link-arg=-lmcfgthread -C link-arg=-static-libgcc -C link-arg=-static-libstdc++"
+              export RUSTC_BOOTSTRAP=1
               '';
             cargoBuildFlags = [ "--package" "nac3artiq" ];
             doCheck = false;
diff --git a/nac3artiq/build.rs b/nac3artiq/build.rs
new file mode 100644
index 0000000..5f2dde6
--- /dev/null
+++ b/nac3artiq/build.rs
@@ -0,0 +1,3 @@
+fn main() {
+    println!("cargo:rustc-link-lib=static=stdc++");
+}
diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs
index a180a28..de79832 100644
--- a/nac3artiq/src/lib.rs
+++ b/nac3artiq/src/lib.rs
@@ -1,3 +1,4 @@
+#![feature(static_nobundle)]
 use std::collections::{HashMap, HashSet};
 use std::fs;
 use std::process::Command;
> winedump -j import nac3artiq.pyd|grep offset      wineWowPackages.stable 
  offset 03259600 ADVAPI32.dll
  offset 03259614 KERNEL32.dll
  offset 03259628 ole32.dll
  offset 0325963c SHELL32.dll
  offset 03259650 libpython3.9.dll
  offset 03259664 bcrypt.dll
  offset 03259678 KERNEL32.dll
  offset 0325968c msvcrt.dll
  offset 032596a0 USERENV.dll
  offset 032596b4 WS2_32.dll
  offset 032596c8 mcfgthread-12.dll
  offset 032596dc libstdc++-6.dll
  offset 032596f0 zlib1.dll
No dice, cargo is being a pain in the neck as usual... ``` diff --git a/flake.nix b/flake.nix index 2844256..768a995 100644 --- a/flake.nix +++ b/flake.nix @@ -172,7 +172,8 @@ chmod +x llvm-cfg/llvm-config export PATH=`pwd`/llvm-cfg:$PATH - export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUSTFLAGS="-C link-arg=-lz -C link-arg=-luuid -C link-arg=-lole32 -C link-arg=-lmcfgthread" + export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUSTFLAGS="-C link-arg=-lz -C link-arg=-luuid -C link-arg=-lole32 -C link-arg=-lmcfgthread -C link-arg=-static-libgcc -C link-arg=-static-libstdc++" + export RUSTC_BOOTSTRAP=1 ''; cargoBuildFlags = [ "--package" "nac3artiq" ]; doCheck = false; diff --git a/nac3artiq/build.rs b/nac3artiq/build.rs new file mode 100644 index 0000000..5f2dde6 --- /dev/null +++ b/nac3artiq/build.rs @@ -0,0 +1,3 @@ +fn main() { + println!("cargo:rustc-link-lib=static=stdc++"); +} diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs index a180a28..de79832 100644 --- a/nac3artiq/src/lib.rs +++ b/nac3artiq/src/lib.rs @@ -1,3 +1,4 @@ +#![feature(static_nobundle)] use std::collections::{HashMap, HashSet}; use std::fs; use std::process::Command; ``` ``` > winedump -j import nac3artiq.pyd|grep offset wineWowPackages.stable offset 03259600 ADVAPI32.dll offset 03259614 KERNEL32.dll offset 03259628 ole32.dll offset 0325963c SHELL32.dll offset 03259650 libpython3.9.dll offset 03259664 bcrypt.dll offset 03259678 KERNEL32.dll offset 0325968c msvcrt.dll offset 032596a0 USERENV.dll offset 032596b4 WS2_32.dll offset 032596c8 mcfgthread-12.dll offset 032596dc libstdc++-6.dll offset 032596f0 zlib1.dll ```
Poster
Owner

Overwriting msys2 C:/msys64/mingw64/bin/libstdc++-6.dll with /nix/store/h5lyl6x1x0932n5j3yfchka71fmdnvbz-x86_64-w64-mingw32-stage-final-gcc-debug-10.3.0/x86_64-w64-mingw32/lib/libstdc++-6.dll solves the problem (but breaks Qt and lld), so fighting cargo until it statically links looks promising as a fix.
With this workaround, NAC3 loads and compiles fine up to the point of LLD invokation.

Overwriting msys2 `C:/msys64/mingw64/bin/libstdc++-6.dll` with `/nix/store/h5lyl6x1x0932n5j3yfchka71fmdnvbz-x86_64-w64-mingw32-stage-final-gcc-debug-10.3.0/x86_64-w64-mingw32/lib/libstdc++-6.dll` solves the problem (but breaks Qt and lld), so fighting cargo until it statically links looks promising as a fix. With this workaround, NAC3 loads and compiles fine up to the point of LLD invokation.

is this an issue caused by pyo3? or what is the cause of this issue?

is this an issue caused by pyo3? or what is the cause of this issue?
Poster
Owner

It's probably LLVM that wants libstdc++.
The issue is the libstdc++-6 DLL that nixpkgs uses is incompatible with the one that msys2 ships. Linking in the nixpkgs version statically should eliminate the issue.

It's probably LLVM that wants libstdc++. The issue is the libstdc++-6 DLL that nixpkgs uses is incompatible with the one that msys2 ships. Linking in the nixpkgs version statically should eliminate the issue.
Poster
Owner

I guess llvm-sys needs to be patched.
405a05abc6/build.rs (L425)
405a05abc6/build.rs (L289)

I guess llvm-sys needs to be patched. https://gitlab.com/taricorp/llvm-sys.rs/-/blob/405a05abc69a374b8bd07f78b31fafc4023e390f/build.rs#L425 https://gitlab.com/taricorp/llvm-sys.rs/-/blob/405a05abc69a374b8bd07f78b31fafc4023e390f/build.rs#L289
sb10q closed this issue 2022-01-24 16:54:14 +08:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#175
There is no content yet.