libretro / hatari

New rebasing of Hatari based on Mercurial upstream. Tries to be a shallow fork for easy upstreaming later on.
25 stars 41 forks source link

Hatari core no longer compiles #33

Closed Shoegzer closed 5 years ago

Shoegzer commented 5 years ago

Hatari core no longer compiles. Getting a ton of undefined references such as:

./src/uae-cpu/fpp.o: In function `fpp_opp':
fpp.c:(.text+0x2899): undefined reference to `__log_finite'
fpp.c:(.text+0x28bf): undefined reference to `__log_finite'
fpp.c:(.text+0x28ff): undefined reference to `__exp_finite'
...
collect2: error: ld returned 1 exit status
Makefile.libretro:180: recipe for target 'hatari_libretro.so' failed

Compile attempted with Linux Mint 19.1 x64, kernel 4.18 using GCC7

@orbea do you have any ideas here?

orbea commented 5 years ago

@Shoegzer Sorry, I don't know, both normal and debug builds work here with gcc-8.2.0. I am also not finding any references to log_finite, exp_finite or even finite in the code base. Maybe you are missing a dependency of a dependency?

The relevant function is here.

https://github.com/libretro/hatari/blob/48b3d9fa5a7f1f0f91dbbd9cc3402941207f4f2a/src/uae-cpu/fpp.c#L815

https://github.com/libretro/hatari/blob/48b3d9fa5a7f1f0f91dbbd9cc3402941207f4f2a/src/uae-cpu/newcpu.h#L347

Please do try to find the first bad commit or what those undefined references are.

gingerbeardman commented 5 years ago

@Shoegzer what method of compilation? Are you using the compilation guide?

https://docs.libretro.com/compilation/linux-and-bsd/

orbea commented 5 years ago

For the record I am using:

make -f Makefile.libretro
gingerbeardman commented 5 years ago

May I suggest using the recommended https://github.com/libretro/libretro-super to build the hatari core?

./libretro-build.sh hatari
orbea commented 5 years ago

@Shoegzer I suppose your libm.so is broken?

See this similar issue https://github.com/BVLC/caffe/issues/757.

$ ldd hatari_libretro.so 
    linux-vdso.so.1 (0x00007ffc2f7fb000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f4485318000)
    libz.so.1 => /lib64/libz.so.1 (0x00007f4485100000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f44850d8000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f4484ee8000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f4486ec0000)
$ ldd /lib64/libm.so.6
    linux-vdso.so.1 (0x00007ffee03c3000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f2840108000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f28404c0000)

Its part of the glibc package here.

Shoegzer commented 5 years ago

Thanks guys.

@gingerbeardman I'm using a script to compile my cores using the buildbot process - so the hatari core is built like this:

for core in hatari; do FORCE=YES SINGLE_CORE=$core ./libretro-buildbot-recipe.sh recipes/linux/cores-linux-x64-generic; done

This worked with my previous build, which was on November 04, however I was using Mint 19, and I've since moved to Mint 19.1, so maybe there's an issue there.

@orbea Doing a system-wide search it appears I don't have the 64-but libm.so.6, however I do have the 32-bit lib:

$ ldd /lib32/libm.so.6 
    linux-gate.so.1 (0xf7f2f000)
    libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7c45000)
    /lib/ld-linux.so.2 (0xf7f31000)

Also: to your comment, I noticed glibc-source is not installed. Is that what you're referring to, and if so, is that a new dependency? I don't think that was needed before.

r-type commented 5 years ago

I got the same issue building with gcc 7.1. i assume it s related to https://github.com/libretro/hatari/commit/b7d86ff5a0f016cef05b145098b532600494ad32

if i tweaks makefile.libretro to replace line 184

    $(CC) $(CFLAGS) $(INCFLAGS) -lm -lz $(SHARED) $(LDFLAGS) $(OBJECTS) -o $@ 

with

    $(CC) $(CFLAGS) $(INCFLAGS) -lm -lz $(SHARED) $(LDFLAGS) $(OBJECTS) -o $@ -lm -lz -lpthread

it build fine fo me , so it seem to be related with the order of library for linking.

orbea commented 5 years ago

Also: to your comment, I noticed glibc-source is not installed. Is that what you're referring to, and if so, is that a new dependency? I don't think that was needed before.

Not sure, try installing it and seeing if it helps, I only have a single glibc package in Slackware which doesn't split packages into many smaller parts.

r-type commented 5 years ago

@Shoegzer you should maybe you try first to build with -lm -lz -lpthread at the end of line 184 to see if it does the trick instead of installing lib...

orbea commented 5 years ago

@r-type I am confused, Makefile.libretro only has 158 lines and it doesn't seem to have the line you changed. Are we using the same repo?

Edit: Nvm I was in the wrong branch....it still builds here however.

orbea commented 5 years ago

Your change doesn't have any difference here, but does it really need -lm and -lz twice?

r-type commented 5 years ago

can you post the build log ? it's not needed twice , but for me it need to be at the end. if i remove the first -lm -lz and leave only at the end it build fine too.

r-type commented 5 years ago

if I remove the -lm -lz -lpthread at the end then i have

https://pastebin.com/5KB4KKcv

but if i add it to the end i have

https://pastebin.com/SXmnY79G

orbea commented 5 years ago

It doesn't have any difference as in it still builds fine, sorry if that was not clear.

Here is a build log for reference though.

https://pastebin.com/eCuCB9kX

r-type commented 5 years ago

I mean it make difference with gcc 7.1.

Shoegzer commented 5 years ago

@r-type Thanks, your modification worked! For the record I'm using gcc 7.3.0 specifically. I wonder if this step is needed past gcc 7.x?

@orbea if it isn't too much trouble, could you compile this under gcc 7.x to confirm the issue and fix? And regardless, could this be added to the actual Makefile to avoid problems for others?

r-type commented 5 years ago

BTW , we should move the $(SHARED) at the end of the line , this also fix build for me with gcc 7.

 else
-       $(CC) $(CFLAGS) $(INCFLAGS) -lm -lz $(SHARED) $(LDFLAGS) $(OBJECTS) -o $@
+       $(CC) $(CFLAGS) $(INCFLAGS) $(LDFLAGS) $(OBJECTS) -o $@ $(SHARED)
 endif
Shoegzer commented 5 years ago

@r-type Hmm does this really matter, or is your previous fix just as good?

r-type commented 5 years ago

i push the fix in last commit,can you try it?

edit: i remove the extra -lz -lm , hope it doesnt hurt other platforms.

Shoegzer commented 5 years ago

Yes it works - thanks @r-type!

I assumed something similar for the fsuae and pcem cores but I had forgotten those aren't in the buildbot script (really wish they were though).

Appreciate your working through this. Now I can use buildbot to compile the hatari core once again.

r-type commented 5 years ago

cool , i just hope the remove of extra -lz -lm will not break other platforms that don't add the -lm -lz flags. just wait and see the buildbot result...

orbea commented 5 years ago

if it isn't too much trouble, could you compile this under gcc 7.x to confirm the issue and fix? And regardless, could this be added to the actual Makefile to avoid problems for others?

Unfortunately it would be a lot of trouble, I would have to compile gcc7 from source, but it still works with gcc-8.2.0 and clang-7.0.0 here in Slackware current. I also tried Slackware 14.2 with gcc-5.5.0 and clang-3.8.0 without any build issues. If it works for you guys I think its probably fine, thanks for taking the time to track this down!

Shoegzer commented 5 years ago

@orbea no worries, we seem to be in good shape now. Just hoping the buildbot works across the board at this point. ;)

orbea commented 5 years ago

Unfortunately it looks like there are problems with osx and ios...

I'm not sure if these are old or new.

<inline asm>:4:1: error: unknown directive
.type co_switch_arm,STT_FUNC
^
1 error generated.
make: *** [libretro/libretro-sdk/libco/libco.o] Error 1
make: *** Waiting for unfinished jobs....
COPY CMD: cp -v ./hatari_libretro_ios.dylib /Users/buildbot/buildbot/ios/dist/ios//hatari_libretro_ios.dylib
cp: ./hatari_libretro_ios.dylib: No such file or directory
cc -std=gnu99 -fPIC -fsigned-char -D__LIBRETRO__ -fno-builtin -funroll-loops -ffast-math -fomit-frame-pointer -DGIT_VERSION=\"" 620c5ec"\" -O3 -DLSB_FIRST -DALIGN_DWORD -I./src  -I./src/uae-cpu  -I./src/falcon -I./src/includes -I./src/debug -I./src -I./libretro -I./libretro/libretro-sdk/include -I./libretro/include -I./libretro/utils -I./libretro/uae-cpu-pregen  ./libretro/uae-cpu-pregen/cpudefs.o ./libretro/uae-cpu-pregen/cpuemu.o ./libretro/uae-cpu-pregen/cpustbl.o ./src/uae-cpu/hatari-glue.o ./src/uae-cpu/memory.o ./src/uae-cpu/newcpu.o ./src/uae-cpu/readcpu.o ./src/uae-cpu/fpp.o ./libretro/gui-retro/dlgAbout.o ./libretro/gui-retro/dlgAlert.o ./libretro/gui-retro/dlgDevice.o ./libretro/gui-retro/dlgFileSelect.o ./libretro/gui-retro/dlgFloppy.o ./libretro/gui-retro/dlgHardDisk.o ./libretro/gui-retro/dlgJoystick.o ./libretro/gui-retro/dlgKeyboard.o ./libretro/gui-retro/dlgMain.o ./libretro/gui-retro/dlgMemory.o ./libretro/gui-retro/dlgNewDisk.o ./libretro/gui-retro/dlgRom.o ./libretro/gui-retro/dlgScreen.o ./libretro/gui-retro/dlgSound.o ./libretro/gui-retro/dlgSystem.o ./libretro/gui-retro/sdlgui.o ./src/falcon/crossbar.o ./src/falcon/dsp.o ./src/falcon/dsp_core.o ./src/falcon/dsp_cpu.o ./src/falcon/dsp_disasm.o ./src/falcon/hostscreen.o ./src/falcon/microphone.o ./src/falcon/nvram.o ./src/falcon/videl.o ./src/debug/log.o ./src/debug/debugui.o ./src/debug/breakcond.o ./src/debug/debugcpu.o ./src/debug/debugInfo.o ./src/debug/debugdsp.o ./src/debug/evaluate.o ./src/debug/history.o ./src/debug/symbols.o ./src/debug/profile.o ./src/debug/profilecpu.o ./src/debug/profiledsp.o ./src/debug/natfeats.o ./src/debug/console.o ./src/debug/68kDisass.o ./src/createBlankImage.o ./src/dim.o ./src/msa.o ./src/st.o ./src/zip.o ./src/acia.o ./src/audio.o ./src/avi_record.o ./src/bios.o ./src/blitter.o ./src/cart.o ./src/cfgopts.o ./src/clocks_timings.o ./src/configuration.o ./src/options.o ./src/change.o ./src/control.o ./src/cycInt.o ./src/cycles.o ./src/dialog.o ./src/dmaSnd.o ./src/fdc.o ./src/file.o ./src/floppy.o ./src/floppy_ipf.o ./src/floppy_stx.o ./src/gemdos.o ./src/hd6301_cpu.o ./src/hdc.o ./src/ide.o ./src/ikbd.o ./src/ioMem.o ./src/ioMemTabST.o ./src/ioMemTabSTE.o ./src/ioMemTabTT.o ./src/ioMemTabFalcon.o ./src/joy.o ./src/keymap.o ./src/m68000.o ./src/main.o ./src/midi.o ./src/memorySnapShot.o ./src/mfp.o ./src/paths.o ./src/psg.o ./src/printer.o ./src/resolution.o ./src/rs232.o ./src/reset.o ./src/rtc.o ./src/scandir.o ./src/stMemory.o ./src/screen.o ./src/screenSnapShot.o ./src/shortcut.o ./src/sound.o ./src/spec512.o ./src/statusbar.o ./src/str.o ./src/tos.o ./src/unzip.o ./src/utils.o ./src/vdi.o ./src/video.o ./src/wavFormat.o ./src/xbios.o ./src/ymFormat.o ./libretro/libretro-sdk/libco/libco.o ./libretro/libretro.o ./libretro/hatari-mapper.o ./libretro/vkbd.o ./libretro/graph.o ./libretro/bmp.o ./libretro/retro_strings.o ./libretro/retro_files.o ./libretro/retro_disk_control.o -o hatari_libretro.dylib -dynamiclib
Undefined symbols for architecture x86_64:
  "_crc32", referenced from:
      _unzReadCurrentFile in unzip.o
     (maybe you meant: _crc32_reset, _crc32_add_byte )
  "_gzclose", referenced from:
      _HFile_Read in file.o
      _File_Save in file.o
      _MemorySnapShot_Capture in memorySnapShot.o
      _MemorySnapShot_Restore in memorySnapShot.o
  "_gzeof", referenced from:
      _HFile_Read in file.o
  "_gzopen", referenced from:
      _HFile_Read in file.o
      _File_Save in file.o
      _MemorySnapShot_OpenFile in memorySnapShot.o
  "_gzread", referenced from:
      _HFile_Read in file.o
      _MemorySnapShot_Store in memorySnapShot.o
      _MemorySnapShot_Capture in memorySnapShot.o
      _MemorySnapShot_OpenFile in memorySnapShot.o
      _MemorySnapShot_Restore in memorySnapShot.o
      _save_u32 in memorySnapShot.o
      _save_u16 in memorySnapShot.o
      ...
  "_gzrewind", referenced from:
      _HFile_Read in file.o
  "_gzseek", referenced from:
      _MemorySnapShot_Skip in memorySnapShot.o
  "_gztell", referenced from:
      _HFile_Read in file.o
  "_gzwrite", referenced from:
      _File_Save in file.o
      _MemorySnapShot_Store in memorySnapShot.o
      _MemorySnapShot_Capture in memorySnapShot.o
      _MemorySnapShot_OpenFile in memorySnapShot.o
      _MemorySnapShot_Restore in memorySnapShot.o
      _save_u32 in memorySnapShot.o
      _save_u16 in memorySnapShot.o
      ...
  "_inflate", referenced from:
      _unzReadCurrentFile in unzip.o
  "_inflateEnd", referenced from:
      _unzClose in unzip.o
      _unzCloseCurrentFile in unzip.o
      _unzOpenCurrentFile in unzip.o
  "_inflateInit2_", referenced from:
      _unzOpenCurrentFile in unzip.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [hatari_libretro.dylib] Error 1
COPY CMD: cp -v ./hatari_libretro.dylib /Users/buildbot/buildbot/osx/dist/osx-x86_64//hatari_libretro.dylib
cp: ./hatari_libretro.dylib: No such file or directory
r-type commented 5 years ago

so i re-add the -lm -lz for all thoose platform :(

Shoegzer commented 5 years ago

@r-type are we okay to close this issue now?

r-type commented 5 years ago

if you are okay , i'm okay.