AndreRH / hangover

Hangover runs simple Win32 applications on arm64 Linux
GNU Lesser General Public License v2.1
1.24k stars 91 forks source link

failure build wine-guest on aarch64 host. #107

Closed xlla closed 1 year ago

xlla commented 3 years ago

System Details

raspberry pi 4B

aarch64 GNU/Linux, kernel 5.4.83

i686-w64-mingw32-gcc --version clang version 10.0.1 (https://github.com/llvm/llvm-project ef32c611aa214dea855364efd7ba451ec5ec3f74) Target: i686-w64-windows-gnu Thread model: posix InstalledDir: /home/pi/git/llvm-mingw/build/bin

Problems Description

just execute make

after a long time compiling, it stop with an error:

make[2]: Leaving directory '/home/pi/git/hangover/build/wine-guest/po'
./../wine-tools/tools/winebuild/winebuild -w -o dlls/aclui/libaclui.a --implib -b x86_64-w64-mingw32 -m64 --export \
  ../../wine/dlls/aclui/aclui.spec
./../wine-tools/tools/winebuild/winebuild -w -o dlls/activeds/libactiveds.a --implib -b x86_64-w64-mingw32 -m64 --export \
  ../../wine/dlls/activeds/activeds.spec
./../wine-tools/tools/winebuild/winebuild -w -o dlls/advapi32/libadvapi32.delay.a --implib -b x86_64-w64-mingw32 -m64 --export \
  ../../wine/dlls/advapi32/advapi32.spec
OVERVIEW: llvm-dlltool

USAGE: llvm-dlltool [options] file...

OPTIONS:
  -D  Specify the input DLL Name
  -d  Input .def File
  -f  Assembler Flags
  -k         Kill @n Symbol from export
  -l  Generate an import lib
  -m  Set target machine
  -S  Assembler

TARGETS: i386, i386:x86-64, arm, arm64
winebuild: /home/pi/git/llvm-mingw/build/bin/x86_64-w64-mingw32-dlltool failed with status 1
make[1]: *** [Makefile:1904: dlls/advapi32/libadvapi32.delay.a] Error 1
make[1]: Leaving directory '/home/pi/git/hangover/build/wine-guest'
make: *** [Makefile:162: build/wine-guest/.built] Error 2

I found other two command executed successful on [ dlls/aclui/libaclui.a , dlls/activeds/libactiveds.a ] , so I enter the work folder and manual invoke each winebuild with -v parameter, then I observed each successful winebuild invoke will convert to llvm-dlltool with "-k -l ", but the failure one will convert to llvm-dlltool with "-k -y ", and llvm-dlltool in my system does not recognize "-y" parameter, so script stop.

rpi4:~/git/hangover/build/wine-guest$ ./../wine-tools/tools/winebuild/winebuild -w -o dlls/aclui/libaclui.a --implib -b x86_64-w64-mingw32 -m64 -v  --export   ../../wine/dlls/aclui/aclui.spec
/usr/bin/llvm-dlltool -k -l dlls/aclui/libaclui.a -d dlls/aclui/libaclui.UZlJoS.def -m i386:x86-64 --as-flags=--64
rpi4:~/git/hangover/build/wine-guest$ ./../wine-tools/tools/winebuild/winebuild -w -o dlls/activeds/libactiveds.a --implib -v -b x86_64-w64-mingw32 -m64 --export   ../../wine/dlls/activeds/activeds.spec
/usr/bin/llvm-dlltool -k -l dlls/activeds/libactiveds.a -d dlls/activeds/libactiveds.xT4JxH.def -m i386:x86-64 --as-flags=--64
rpi4:~/git/hangover/build/wine-guest$ ./../wine-tools/tools/winebuild/winebuild -w -o dlls/advapi32/libadvapi32.delay.a --implib -b x86_64-w64-mingw32 -m64 --export   ../../wine/dlls/advapi32/advapi32.spec
OVERVIEW: llvm-dlltool

USAGE: llvm-dlltool [options] file...

OPTIONS:
  -D  Specify the input DLL Name
  -d  Input .def File
  -f  Assembler Flags
  -k         Kill @n Symbol from export
  -l  Generate an import lib
  -m  Set target machine
  -S  Assembler

TARGETS: i386, i386:x86-64, arm, arm64
winebuild: /usr/bin/llvm-dlltool failed with status 1

yes.

stefand commented 3 years ago

I have never tested this with clang-based mingw. I remember discussions on wine-devel about this but didn't follow them beyond reading the subject headers.

xlla commented 3 years ago

I am a newbie of clang too, and I manage to dynamic change paramter "-y" to "-l" then build can pass on.

...
./../wine-tools/tools/winebuild/winebuild -w -o dlls/gdi32/libgdi32.delay.a --implib -b x86_64-w64-mingw32 -m64 --export \
  ../../wine/dlls/gdi32/gdi32.spec
unknow param -y, replace to -l
./../wine-tools/tools/winebuild/winebuild -w -o dlls/gdi32/libgdi32.a --implib -b x86_64-w64-mingw32 -m64 --export \
  ../../wine/dlls/gdi32/gdi32.spec
./../wine-tools/tools/winebuild/winebuild -w -o dlls/gdiplus/libgdiplus.delay.a --implib -b x86_64-w64-mingw32 -m64 --export \
  ../../wine/dlls/gdiplus/gdiplus.spec
unknow param -y, replace to -l
./../wine-tools/tools/winebuild/winebuild -w -o dlls/gdiplus/libgdiplus.a --implib -b x86_64-w64-mingw32 -m64 --export \
  ../../wine/dlls/gdiplus/gdiplus.spec
./../wine-tools/tools/winebuild/winebuild -w -o dlls/glu32/libglu32.delay.a --implib -b x86_64-w64-mingw32 -m64 --export \
  ../../wine/dlls/glu32/glu32.spec
unknow param -y, replace to -l
./../wine-tools/tools/winebuild/winebuild -w -o dlls/glu32/libglu32.a --implib -b x86_64-w64-mingw32 -m64 --export \
  ../../wine/dlls/glu32/glu32.spec
...
xlla commented 3 years ago

Now stuck on dlls32/ntdll.dll,

rpi4:~/git/hangover$ make
ln -sf ../../../dlls32/dxgi/dxgi.dll build/qemu/x86_64-windows-user/qemu_guest_dll32/
make -C build/dlls32/dxgi dxgi.dll
make[1]: Entering directory '/home/pi/git/hangover/build/dlls32/dxgi'
make[1]: 'dxgi.dll' is up to date.
make[1]: Leaving directory '/home/pi/git/hangover/build/dlls32/dxgi'
ln -sf ../../../dlls32/ntdll/ntdll.dll build/qemu/x86_64-windows-user/qemu_guest_dll32/
make -C build/dlls32/ntdll ntdll.dll
make[1]: Entering directory '/home/pi/git/hangover/build/dlls32/ntdll'
i686-w64-mingw32-gcc ../../../dlls/ntdll/actctx.c -c -o actctx_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=32 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -fcommon -DQEMU_DLL_GUEST
In file included from ../../../dlls/ntdll/actctx.c:28:
In file included from ../../../dlls/ntdll/../include/thunk/qemu_windows.h:8:
../../../dlls/ntdll/../include/thunk/qemu_wingdi.h:145:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]
#include 
         ^
/home/pi/git/llvm-mingw/build/i686-w64-mingw32/include/pshpack4.h:7:9: note: previous '#pragma pack' directive that modifies alignment is here
#pragma pack(push,4)
        ^
In file included from ../../../dlls/ntdll/actctx.c:28:
In file included from ../../../dlls/ntdll/../include/thunk/qemu_windows.h:8:
../../../dlls/ntdll/../include/thunk/qemu_wingdi.h:233:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]
#include 
         ^
note: previous '#pragma pack' directive that modifies alignment is here
../../../dlls/ntdll/actctx.c:57:28: error: dllimport cannot be applied to non-inline function definition
WINBASEAPI NTSTATUS WINAPI RtlCreateActivationContext(HANDLE *handle, const void *ptr)
                           ^
../../../dlls/ntdll/actctx.c:88:24: error: dllimport cannot be applied to non-inline function definition
WINBASEAPI void WINAPI RtlAddRefActivationContext(HANDLE handle)
                       ^
../../../dlls/ntdll/actctx.c:116:24: error: dllimport cannot be applied to non-inline function definition
WINBASEAPI void WINAPI RtlReleaseActivationContext(HANDLE handle)
                       ^
../../../dlls/ntdll/actctx.c:144:28: error: dllimport cannot be applied to non-inline function definition
WINBASEAPI NTSTATUS WINAPI RtlZombifyActivationContext(HANDLE handle)
                           ^
../../../dlls/ntdll/actctx.c:176:28: error: dllimport cannot be applied to non-inline function definition
WINBASEAPI NTSTATUS WINAPI RtlActivateActivationContext(ULONG unknown, HANDLE handle, PULONG_PTR cookie)
                           ^
../../../dlls/ntdll/actctx.c:212:24: error: dllimport cannot be applied to non-inline function definition
WINBASEAPI void WINAPI RtlDeactivateActivationContext(ULONG flags, ULONG_PTR cookie)
                       ^
../../../dlls/ntdll/actctx.c:240:24: error: dllimport cannot be applied to non-inline function definition
WINBASEAPI void WINAPI RtlFreeThreadActivationContextStack(void)
                       ^
../../../dlls/ntdll/actctx.c:267:28: error: dllimport cannot be applied to non-inline function definition
WINBASEAPI NTSTATUS WINAPI RtlGetActiveActivationContext(HANDLE *handle)
                           ^
../../../dlls/ntdll/actctx.c:300:27: error: dllimport cannot be applied to non-inline function definition
WINBASEAPI BOOLEAN WINAPI RtlIsActivationContextActive(HANDLE handle)
                          ^
../../../dlls/ntdll/actctx.c:336:28: error: dllimport cannot be applied to non-inline function definition
WINBASEAPI NTSTATUS WINAPI RtlQueryInformationActivationContext(ULONG flags, HANDLE handle, PVOID subinst, ULONG class, PVOID buffer, SIZE_T bufsize, SIZE_T *retlen)
                           ^
../../../dlls/ntdll/actctx.c:377:28: error: dllimport cannot be applied to non-inline function definition
WINBASEAPI NTSTATUS WINAPI RtlFindActivationContextSectionString(ULONG flags, const GUID *guid, ULONG section_kind, const UNICODE_STRING *section_name, PVOID ptr)
                           ^
../../../dlls/ntdll/actctx.c:451:28: error: dllimport cannot be applied to non-inline function definition
WINBASEAPI NTSTATUS WINAPI RtlFindActivationContextSectionGuid(ULONG flags, const GUID *extguid, ULONG section_kind, const GUID *guid, void *ptr)
                           ^
../../../dlls/ntdll/actctx.c:492:28: error: dllimport cannot be applied to non-inline function definition
WINBASEAPI NTSTATUS WINAPI RtlQueryActivationContextApplicationSettings(DWORD flags, HANDLE handle, const WCHAR *ns, const WCHAR *settings, WCHAR *buffer, SIZE_T size, SIZE_T *written)
                           ^
2 warnings and 13 errors generated.
make[1]: *** [../../../dlls/ntdll/Makefile:18: actctx_g.o] Error 1
make[1]: Leaving directory '/home/pi/git/hangover/build/dlls32/ntdll'
make: *** [Makefile:261: build/dlls32/ntdll/ntdll.dll] Error 2
xlla commented 3 years ago

add KERNEL32 and NTSYSTEM can bypass those errors, but stuck on dlls/ntdll/printf.c

i686-w64-mingw32-gcc ../../../dlls/ntdll/nt.c -c -o nt_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=32 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -fcommon -DQEMU_DLL_GUEST -D_KERNEL32_ -D_NTSYSTEM_
i686-w64-mingw32-gcc ../../../dlls/ntdll/om.c -c -o om_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=32 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -fcommon -DQEMU_DLL_GUEST -D_KERNEL32_ -D_NTSYSTEM_
i686-w64-mingw32-gcc ../../../dlls/ntdll/path.c -c -o path_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=32 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -fcommon -DQEMU_DLL_GUEST -D_KERNEL32_ -D_NTSYSTEM_
i686-w64-mingw32-gcc ../../../dlls/ntdll/printf.c -c -o printf_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=32 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -fcommon -DQEMU_DLL_GUEST -D_KERNEL32_ -D_NTSYSTEM_
../../../dlls/ntdll/printf.c:230:61: warning: implicit declaration of function 'offsetof' is invalid in C99 [-Wimplicit-function-declaration]
    call = ntdll_RtlAllocateHeap(ntdll_GetProcessHeap(), 0, offsetof(struct qemu_sprintf, args[count]));
                                                            ^
../../../dlls/ntdll/printf.c:230:70: error: expected expression
    call = ntdll_RtlAllocateHeap(ntdll_GetProcessHeap(), 0, offsetof(struct qemu_sprintf, args[count]));
                                                                     ^
1 warning and 1 error generated.
make[1]: *** [../../../dlls/ntdll/Makefile:18: printf_g.o] Error 1
make[1]: Leaving directory '/home/pi/git/hangover/build/dlls32/ntdll'
make: *** [Makefile:261: build/dlls32/ntdll/ntdll.dll] Error 2
stefand commented 3 years ago

Try to include stddef.h: https://en.wikipedia.org/wiki/Offsetof

xlla commented 3 years ago

Try to include stddef.h: https://en.wikipedia.org/wiki/Offsetof

It go on a bit.

8 warnings generated.
../../../build/wine-tools/tools/winegcc/winegcc --winebuild ../../../build/wine-tools/tools/winebuild/winebuild -I../../../build/wine-host/include -I../../../wine/include --wine-objdir ../../../build/wine-guest32 -shared -b i686-w64-mingw32 ../../../dlls/ntdll/ntdll.spec *_g.o -o ntdll.dll -nodefaultlibs -nostdlib -mno-cygwin  -Wl,--image-base,0x9000000
lld-link: error: undefined symbol: _RtlInterlockedPushListSList
>>> referenced by ntdll.dll-P6cQWI.spec.o:(.L__wine_spec_exports_funcs)

lld-link: error: undefined symbol: _memcpy
>>> referenced by signal_g.o:(@qemu_exception_handler@4)
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
winegcc: /home/pi/git/llvm-mingw/build/bin/i686-w64-mingw32-gcc failed
make[1]: *** [../../../dlls/ntdll/Makefile:12: ntdll.dll] Error 2
make[1]: Leaving directory '/home/pi/git/hangover/build/dlls32/ntdll'
make: *** [Makefile:262: build/dlls32/ntdll/ntdll.dll] Error 2
xlla commented 3 years ago

I noticed on x86_64 host, it will generate warning on same task.

../../../build/wine-tools/tools/winegcc/winegcc --winebuild ../../../build/wine-tools/tools/winebuild/winebuild -I../../../build/wine-host/include -I../../../wine/include --wine-objdir ../../../build/wine-guest32 -shared -b i686-w64-mingw32 ../../../dlls/ntdll/ntdll.spec *_g.o -o ntdll.dll -nodefaultlibs -nostdlib -Wl,--image-base,0x9000000
/usr/bin/i686-w64-mingw32-ld: warning: resolving _RtlInterlockedPushListSList by linking to @RtlInterlockedPushListSList@16
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
make[1]: Leaving directory '/home/xlla/git/hangover/build/dlls32/ntdll'

how to bridge _RtlInterlockedPushListSList to RtlInterlockedPushListSList for clang?

xlla commented 3 years ago

By copy dlls from x86 host build folder I can cross those errors and finish build process.

But failure to launch actual x86 app.

rpi4:~/git/hangover$ WINEPREFIX="$HOME/.wineho" WINEARCH=win64 ./build/wine-host/wine64 build/qemu/x86_64-windows-user/qemu-x86_64.exe.so ~/winapp/Notepad++/notepad++.exe 
0024:err:qemu_module:open_dll_file Unsupported machine 452.
0024:err:winediag:SECUR32_initNTLMSP ntlm_auth was not found or is outdated. Make sure that ntlm_auth >= 3.0.25 is in your path. Usually, you can find it in the winbind package of your distribution.
Could not reserve address for main image, expect trouble later
0024:err:qemu_module:open_dll_file Unsupported machine 452.
Failed to load "/home/pi/winapp/Notepad++/notepad++.exe", last error 193.

I learned it depend on winbind and installed that, but still failure to launch.

rpi4:~/git/hangover$ WINEPREFIX="$HOME/.wineho" WINEARCH=win64 ./build/wine-host/wine64 build/qemu/x86_64-windows-user/qemu-x86_64.exe.so ~/winapp/Notepad++/notepad++.exe 
0024:err:qemu_module:open_dll_file Unsupported machine 452.
Could not reserve address for main image, expect trouble later
0024:err:qemu_module:open_dll_file Unsupported machine 452.
Failed to load "/home/pi/winapp/Notepad++/notepad++.exe", last error 193.
AndreRH commented 1 year ago

irrelevant with new Hangover approach