mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.52k stars 1.6k forks source link

sanitycheckcpp_cross.exe needs libgcc_s_dw2-1.dll #8704

Open mishka88ru opened 3 years ago

mishka88ru commented 3 years ago

Hello.

It is very easy to avoid the error below: just manually copy libgcc_s_dw2-1.dll into the meson-private directory (PATH tuning will also help, I believe). But for a better user experience I suggest to consider building sanitycheckcpp_cross.exe with -static-libgcc and/or -static-libstdc++.

0009:err:module:import_dll Library libgcc_s_dw2-1.dll (which is needed by L"Z:\\home\\mishka\\my-library\\build\\release\\windows-mingw_x86\\meson-private\\sanitycheckcpp_cross.exe") not found
0009:err:module:LdrInitializeThunk Importing dlls for L"Z:\\home\\mishka\\my-library\\build\\release\\windows-mingw_x86\\meson-private\\sanitycheckcpp_cross.exe" failed, status c0000135

meson.build:4:0: ERROR: Executables created by cpp compiler /usr/bin/i686-w64-mingw32-g++ are not runnable.

For reference:

The Meson build system
Version: 0.57.2
Build type: cross build
C++ compiler for the host machine: /usr/bin/i686-w64-mingw32-g++ (gcc 10.0.0 "i686-w64-mingw32-g++ (GCC) 10-win32 20210408")
C++ linker for the host machine: /usr/bin/i686-w64-mingw32-g++ ld.bfd 2.35.1
C++ compiler for the build machine: c++ (gcc 10.3.0 "c++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
C++ linker for the build machine: c++ ld.bfd 2.36.1
Build machine cpu family: x86_64
Build machine cpu: x86_64
Host machine cpu family: x86
Host machine cpu: i686
Target machine cpu family: x86
Target machine cpu: i686
surrim commented 1 year ago

Same here, Fedora mingw32 doesn't does contain libgcc_s_dw2-1.dll. Disabling the sanity check is also possible.

Merge this lines into your cross file

[properties] skip_sanity_check = true

YaLTeR commented 1 year ago

It does, actually: /usr/i686-w64-mingw32/sys-root/mingw/bin/libgcc_s_dw2-1.dll

Just meson doesn't pass some environment correctly or something I guess?

surrim commented 1 year ago

MinGW32/64 ships /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libgcc_s_seh-1.dll, the sanity check runs only fine with MinGW64:

The Meson build system
Version: 0.62.2
Source dir: ~/test
Build dir: ~/test/builddir
Build type: cross build
Project name: test
Project version: 0.1
002c:fixme:winediag:LdrInitializeThunk wine-staging 8.4 is a testing version containing experimental patches.
002c:fixme:winediag:LdrInitializeThunk Please mention your exact version when filing bug reports on winehq.org.
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
C++ compiler for the host machine: x86_64-w64-mingw32-g++ (gcc 11.2.1 "x86_64-w64-mingw32-g++ (GCC) 11.2.1 20211019 (Fedora MinGW 11.2.1-6.fc36)")
C++ linker for the host machine: x86_64-w64-mingw32-g++ ld.bfd 2.37-7
C++ compiler for the build machine: ccache c++ (gcc 12.2.1 "c++ (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4)")
C++ linker for the build machine: c++ ld.bfd 2.37-37
Build machine cpu family: x86_64
Build machine cpu: x86_64
Host machine cpu family: x86_64
Host machine cpu: x86_64
Target machine cpu family: x86_64
Target machine cpu: x86_64

[...]

MinGW32:

The Meson build system
Version: 0.62.2
Source dir: ~/test
Build dir: ~/test/builddir
Build type: cross build
Project name: test
Project version: 0.1
002c:fixme:winediag:LdrInitializeThunk wine-staging 8.4 is a testing version containing experimental patches.
002c:fixme:winediag:LdrInitializeThunk Please mention your exact version when filing bug reports on winehq.org.
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0108:err:module:import_dll Library libgcc_s_dw2-1.dll (which is needed by L"Z:\\home\\test\\test\\builddir\\meson-private\\sanitycheckcpp_cross.exe") not found
0108:err:module:LdrInitializeThunk Importing dlls for L"Z:\\home\\test\\test\\builddir\\meson-private\\sanitycheckcpp_cross.exe" failed, status c0000135

meson.build:1:0: ERROR: Executables created by cpp compiler i686-w64-mingw32-g++ are not runnable.

A full log can be found at ~/test/builddir/meson-logs/meson-log.txt

MINGW32, ~/test/builddir/meson-logs/meson-log.txt:

Build started at 2023-04-23T12:54:32.284124
Main binary: /usr/bin/python3
Build Options: -Dprefix=/usr/i686-w64-mingw32/sys-root/mingw -Dlibdir=lib -Ddefault_library=static '--cross-file mingw32' '--cross-file wrapper.ini'
Python system: Linux
The Meson build system
Version: 0.62.2
Source dir: ~/test
Build dir: ~/test/builddir
Build type: cross build
Project name: test
Project version: 0.1
Sanity testing C++ compiler: i686-w64-mingw32-g++
Is cross compiler: True.
Sanity check compiler command line: i686-w64-mingw32-g++ sanitycheckcpp.cc -o sanitycheckcpp_cross.exe -D_FILE_OFFSET_BITS=64
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command: /usr/bin/wine ~/test/builddir/meson-private/sanitycheckcpp_cross.exe

meson.build:1:0: ERROR: Executables created by cpp compiler i686-w64-mingw32-g++ are not runnable.
$ cd builddir/meson-private
$ i686-w64-mingw32-g++ sanitycheckcpp.cc -o sanitycheckcpp_cross.exe -D_FILE_OFFSET_BITS=64 # non-static, see meson-log.txt
$ wine sanitycheckcpp_cross.exe
002c:fixme:winediag:LdrInitializeThunk wine-staging 8.4 is a testing version containing experimental patches.
002c:fixme:winediag:LdrInitializeThunk Please mention your exact version when filing bug reports on winehq.org.
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0108:err:module:import_dll Library libgcc_s_dw2-1.dll (which is needed by L"Z:\\home\\kathi\\projects\\ax\\builddir\\meson-private\\sanitycheckcpp_cross.exe") not found
0108:err:module:LdrInitializeThunk Importing dlls for L"Z:\\home\\kathi\\projects\\ax\\builddir\\meson-private\\sanitycheckcpp_cross.exe" failed, status c0000135

$ i686-w64-mingw32-g++ sanitycheckcpp.cc -o sanitycheckcpp_cross.exe -D_FILE_OFFSET_BITS=64 -static-libgcc # this time static
$ wine sanitycheckcpp_cross.exe 
002c:fixme:winediag:LdrInitializeThunk wine-staging 8.4 is a testing version containing experimental patches.
002c:fixme:winediag:LdrInitializeThunk Please mention your exact version when filing bug reports on winehq.org.
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005

... but the MinGW64 build uses x86_64-w64-mingw32-g++ sanitycheckcpp.cc -o sanitycheckcpp_cross.exe -D_FILE_OFFSET_BITS=64 (= non-static) and it works. So I guess it's a problem with the OS. I'm sure that MinGW32 worked in the past, at least in Oct 2018, and probably Jan 2020 (own Git logs).