Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux->Windows MinGW Cross-compiling issues (0.262) #12056

Closed
ghost opened this issue Feb 23, 2024 · 2 comments
Closed

Linux->Windows MinGW Cross-compiling issues (0.262) #12056

ghost opened this issue Feb 23, 2024 · 2 comments

Comments

@ghost
Copy link

ghost commented Feb 23, 2024

Trying to compile 0.262 on Debian 12 (x64 host) for Windows x64 with these makefile options:

REGENIE=1
VERBOSE=1
IGNORE_GIT=1
TESTS=0
NO_USE_MIDI=1
NO_USE_PORTAUDIO=1
NO_USE_PULSEAUDIO=1
FORCE_DRC_C_BACKEND=1
DEBUG=0
BENCHMARKS=0
SYMBOLS=0
PROFILER=0
MAP=0
LTO=0
TARGETOS=windows
PTR64=1
OVERRIDE_CC=x86_64-w64-mingw32-gcc-posix
OVERRIDE_CXX=x86_64-w64-mingw32-g++-posix
OVERRIDE_LD=x86_64-w64-mingw32-ld
OVERRIDE_AR=x86_64-w64-mingw32-ar
CROSS_BUILD=1
MINGW64=/usr**

Here are my compiler and package versions:

$ x86_64-w64-mingw32-g++-posix --version
x86_64-w64-mingw32-g++-posix (GCC) 12-posix
$ x86_64-w64-mingw32-ld --version
GNU ld (GNU Binutils) 2.40
$ x86_64-w64-mingw32-ar --version
GNU ar (GNU Binutils) 2.40

$ dpkg -l | grep -i mingw-w64-x86-64
ii  binutils-mingw-w64-x86-64          2.40-2+10.4                         amd64        Cross-binutils for Win64 (x64) using MinGW-w64
ii  g++-mingw-w64-x86-64               12.2.0-14+25.2                      all          GNU C++ compiler for MinGW-w64 targeting Win64
ii  g++-mingw-w64-x86-64-posix         12.2.0-14+25.2                      amd64        GNU C++ compiler for MinGW-w64, Win64/POSIX
ii  g++-mingw-w64-x86-64-win32         12.2.0-14+25.2                      amd64        GNU C++ compiler for MinGW-w64, Win64/Win32
ii  gcc-mingw-w64-x86-64               12.2.0-14+25.2                      all          GNU C compiler for MinGW-w64 targeting Win64
ii  gcc-mingw-w64-x86-64-posix         12.2.0-14+25.2                      amd64        GNU C compiler for MinGW-w64, Win64/POSIX
ii  gcc-mingw-w64-x86-64-posix-runtime 12.2.0-14+25.2                      amd64        GNU Compiler Collection for MinGW-w64, x86-64/POSIX
ii  gcc-mingw-w64-x86-64-win32         12.2.0-14+25.2                      amd64        GNU C compiler for MinGW-w64, Win64/Win32
ii  gcc-mingw-w64-x86-64-win32-runtime 12.2.0-14+25.2                      amd64        GNU Compiler Collection for MinGW-w64, x86-64/Win32
ii  mingw-w64-x86-64-dev               10.0.0-3                            all          Development files for MinGW-w64 targeting Win64

$ cat /etc/debian_version
12.5

I was faced with various issues stemming from bgfx, it's directx-headers dependency and Win32 API functions. I tracked down the problematic PR to #10789 and was able to cross-compile 0.251 (the last tagged release before it was merged) just fine with the same build options.
I was able to fix the problem by commenting out these include "include/wsl/stubs" lines:
https://github.com/mamedev/mame/blob/mame0262/scripts/src/3rdparty.lua#L1491C64-L1491C67
https://github.com/mamedev/mame/blob/mame0262/3rdparty/bgfx/scripts/bgfx.lua#L114

But now, new issues arise:
When compilation reaches src/emu/ files, CPU (4 cores / make -j5) and memory usage are at the maximum, reaching 7.7GB out of total 8 available, and compiling the emumem* source files takes a couple minutes each. This becomes problematic, as I planned on compiling on a 3GB tmpfs ramdisk. I am using an SSD, and the rest of the project compiles at normal speed, just specifically emumem* files as I was watching htop.
It eventually gets through compiling, and gets to the archiving / ar stage... and then the process takes a few minutes, and errors with no output:

Compiling src/emu/rendlay.cpp...
x86_64-w64-mingw32-g++-posix    -MMD -MP -MP -DX64_WINDOWS_ABI -DPTR64=1 -DNDEBUG -DCRLF=3 -DLSB_FIRST -DFLAC__NO_DLL -DPUGIXML_HEADER_ONLY -DLUA_COMPAT_ALL -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DWIN32 -I"../../../../../src/osd" -I"../../../../../src/emu" -I"../../../../../src/lib" -I"../../../../../src/lib/util" -I"../../../../../3rdparty" -I"../../../../../3rdparty/sol2" -I"../../../../generated/emu" -I"../../../../generated/emu/layout" -I"../../../../../3rdparty/asio/include" -I"../../../../../3rdparty/expat/lib" -I"../../../../../3rdparty/zlib" -I"../../../../../3rdparty/flac/include" -I"../../../../../3rdparty/libjpeg" -I"../../../../../3rdparty/rapidjson/include" -I"../../../../../3rdparty/pugixml/src"  -m64 -std=c++17 -pipe -Werror -O3 -fno-strict-aliasing -fuse-ld=lld -Wl,-v -fno-lto -Wno-unknown-pragmas -Wall -Wcast-align -Wformat-security -Wundef -Wwrite-strings -Wno-conversion -Wno-sign-compare -Wno-error=deprecated-declarations -Wno-error=unused-result -Wno-array-bounds -Wno-error=attributes -Wno-stringop-truncation -Wno-stringop-overflow -Wno-nonnull -Wno-stringop-overread -Wno-error=maybe-uninitialized -Wno-error=uninitialized -m64 -std=c++17 -Woverloaded-virtual -Wvla -Wimplicit-fallthrough -Wno-class-memaccess -Wsuggest-override -include ../../../../mingw-gcc/obj/x64/Release/emu.h -o "../../../../mingw-gcc/obj/x64/Release/src/emu/rendlay.o" -c "../../../../../src/emu/rendlay.cpp"
Archiving libemu.a...
rm -f "../../../../mingw-gcc/bin/x64/Release/libemu.a"
x86_64-w64-mingw32-ar  -cs ../../../../mingw-gcc/bin/x64/Release/libemu.a
make[1]: Leaving directory 'xxxxxx/MAME0262/build/projects/windows/mamemmm/gmake-mingw64-gcc'
make: *** [makefile:1173: windows_x64] Error 2

(these issues did not occur while compiling 0.251)

@ghost ghost changed the title Cross-compiling issues (0.262) Linux->Windows MinGW Cross-compiling issues (0.262) Feb 23, 2024
@rb6502
Copy link
Contributor

rb6502 commented Feb 23, 2024

If the compile errors out and you don't see the error, that means it happened further back. Try compiling again without -j and it will stop where the error is.

Beyond that, we strongly recommend having at least 16 GB of RAM to compile MAME. And I'm really curious what your use case is for cross compiling for Windows in the first place given perfectly good Windows binaries are available at mamedev.org.

@ghost
Copy link
Author

ghost commented Feb 23, 2024

Thanks, I feel foolish... I deleted 3rdparty/bgfx/examples assuming it'd be unused (140MB of textures shaders), but there's a few imgui source files in there that bgfx depends on... compiling singlethreaded showed the error.

I'm really curious what your use case is

I had a few negative experiences trying to set up a MSYS2 build environment (see: mamedev/buildtools#7) so I decided to use my Linux build server. It compiled and linked just fine now at least, so I may try to see if there's a cleaner way to fix the wsl include issue and contribute that.

@ghost ghost closed this as completed Feb 23, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant