libretro / mame2016-libretro

Late 2016 version of MAME (0.174) for libretro. Compatible with MAME 0.174 sets.
Other
32 stars 40 forks source link

Should be able to build for Windows using mingw64.exe shell #40

Open c0d3h4x0r opened 4 years ago

c0d3h4x0r commented 4 years ago

I've been trying to get mame2016-libretro building under mingw64.exe (rather than the MSYS2-based win32env shell), which has required me to pull in the latest stable version (version 1115 (commit cd9b1a624810b166d11788d01c2aa4daf2ea42e6)) of GENie to resolve some build errors.

With that in place, I still get the following remaining build errors:

:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../../../../gmake/libretro/debug/mame_mame/libsega.a(model1.o): in function `model1_state::model1_interrupt(timer_device&, void*, int)':
C:\msys64\src\mame2016-libretro\build\projects\retro\mame\gmake-mingw64-gcc/../../../../../src/mame/drivers/model1.cpp:745: undefined reference to `segam1audio_device::check_fifo_irq()'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../../../../gmake/libretro/debug/mame_mame/libsega.a(model1.o): in function `model1_state::snd_68k_ready_r(address_space&, unsigned int, unsigned short)':
C:\msys64\src\mame2016-libretro\build\projects\retro\mame\gmake-mingw64-gcc/../../../../../src/mame/drivers/model1.cpp:848: undefined reference to `segam1audio_device::ready_r(address_space&, unsigned int, unsigned short)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../../../../gmake/libretro/debug/mame_mame/libsega.a(model1.o): in function `model1_state::snd_latch_to_68k_w(address_space&, unsigned int, unsigned short, unsigned short)':
C:\msys64\src\mame2016-libretro\build\projects\retro\mame\gmake-mingw64-gcc/../../../../../src/mame/drivers/model1.cpp:859: undefined reference to `segam1audio_device::write_fifo(unsigned char)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../../../../gmake/libretro/debug/mame_mame/libsega.a(model1.o):model1.cpp:(.rdata$.refptr.SEGAM1AUDIO[.refptr.SEGAM1AUDIO]+0x0): undefined reference to `SEGAM1AUDIO'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../../../../gmake/libretro/debug/mame_mame/libsega.a(model2.o): in function `model2_state::model2o_serial_w(address_space&, unsigned int, unsigned int, unsigned int)':
C:\msys64\src\mame2016-libretro\build\projects\retro\mame\gmake-mingw64-gcc/../../../../../src/mame/drivers/model2.cpp:1186: undefined reference to `segam1audio_device::ready_r(address_space&, unsigned int, unsigned short)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\src\mame2016-libretro\build\projects\retro\mame\gmake-mingw64-gcc/../../../../../src/mame/drivers/model2.cpp:1191: undefined reference to `segam1audio_device::write_fifo(unsigned char)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../../../../gmake/libretro/debug/mame_mame/libsega.a(model2.o): in function `model2_state::model2_serial_w(address_space&, unsigned int, unsigned int, unsigned int)':
C:\msys64\src\mame2016-libretro\build\projects\retro\mame\gmake-mingw64-gcc/../../../../../src/mame/drivers/model2.cpp:1210: undefined reference to `segam1audio_device::ready_r(address_space&, unsigned int, unsigned short)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\src\mame2016-libretro\build\projects\retro\mame\gmake-mingw64-gcc/../../../../../src/mame/drivers/model2.cpp:1215: undefined reference to `segam1audio_device::write_fifo(unsigned char)'
collect2.exe: error: ld returned 1 exit status
make[3]: *** [mame2016.make:556: ../../../../../mame2016_libretro.dll] Error 1
make[2]: *** [Makefile:940: mame2016] Error 2
make[2]: Leaving directory '/src/mame2016-libretro/build/projects/retro/mame/gmake-mingw64-gcc'
make[1]: *** [makefile:931: windows_x64] Error 2
make[1]: Leaving directory '/src/mame2016-libretro'
make: *** [Makefile.libretro:198: build] Error 2

This is caused by incorrect library ordering in the generated mame2016.make. libshared.a needs to come before libsega.a in order for that function to be recognized by the linker when it reasons over libsega.a.

The LUA code responsible for this appears to reside in make_cpp.lua, inside the function cpp.linker(). It needs to somehow be adjusted to guarantee the correct relative static library ordering as needed by mame2016-libretro in order to successfully link.

c0d3h4x0r commented 4 years ago

I am working on a fix for this.

c0d3h4x0r commented 4 years ago

I've think I've finally got this working. I had to add a table-ordering hack to make_cpp.lua in GENie, then run genie embed to force scripts.c to get regenerated correctly, then rebuild mame2016-libretro with REGENIE=1.

y0ush4 commented 4 months ago

can you please guide me whats wrong

Generating ../build/projects/windows/mame/gmake-mingw64-gcc/zenith.make... Generating ../build/projects/windows/mame/gmake-mingw64-gcc/zpa.make... Generating ../build/projects/windows/mame/gmake-mingw64-gcc/zvt.make... Generating ../build/projects/windows/mame/gmake-mingw64-gcc/skeleton.make... Generating ../build/projects/windows/mame/gmake-mingw64-gcc/mame2016.make... Done. Precompiling src/emu/emu.h... In file included from ../../../../../src/emu/emu.h:60: ../../../../../src/emu/input.h: In copy constructor 'input_seq::input_seq(const input_seq&)': ../../../../../src/emu/input.h:451:49: error: 'void memcpy(void, const void*, size_t)' writing to an object of non-trivially copyable type 'class input_code'; use copy-assignment or copy-initialization instead [-Werror=class-memaccess] 451 | input_seq(const input_seq &rhs) { memcpy(m_code, rhs.m_code, sizeof(m_code)); } | ~~^~~~~~~~ In file included from ../../../../../src/emu/emu.h:60: ../../../../../src/emu/input.h:400:7: note: 'class input_code' declared here 400 | class input_code | ^~~~~~ cc1plus.exe: all warnings being treated as errors precompile.make:455: recipe for target '../../../../mingw-gcc/obj/x64/Release/emu.h.gch' failed make[2]: [../../../../mingw-gcc/obj/x64/Release/emu.h.gch] Error 1 makefile:70: recipe for target 'precompile' failed make[1]: [precompile] Error 2 makefile:930: recipe for target 'windows_x64' failed make: *** [windows_x64] Error 2

[MINGW64] C:\msys64\src\mame2016-libretro>cc1plus.exe: all warnings being treated as errors 'cc1plus.exe:' is not recognized as an internal or external command, operable program or batch file.