openbor icon indicating copy to clipboard operation
openbor copied to clipboard

Linux AMD64 Build fails on Gentoo Linux.

Open amano-kenji opened this issue 1 year ago • 20 comments

Description

$ ./build.sh 4
-------------------------------------------------------
OpenBOR v3.0 Build 1 (commit hash 7f6f175) - http://www.ChronoCrash.com

All rights reserved.
See LICENSE and README within OpenBOR root for details.

Copyright (c) 2004 - 2018 OpenBOR Team
-------------------------------------------------------
-------------------------------------------------------
     ERROR - Linux x86 Environment Failed
                 SDK Installed?
-------------------------------------------------------
-------------------------------------------------------
   Linux x86 SDK (x86_64-pc-linux-gnu) Environment Loaded!
-------------------------------------------------------

Removing All LINUX Files...
Done!

Compiling LINUX Port: openbor.c...
Compiling LINUX Port: openborscript.c...
Compiling LINUX Port: sdl/control.c...
Compiling LINUX Port: sdl/sblaster.c...
Compiling LINUX Port: sdl/timer.c...
Compiling LINUX Port: sdl/sdlport.c...
openbor.c: In function ‘display_ents’:
openbor.c:22328:26: error: the comparison will always evaluate as ‘true’ for the pointer operand in ‘anim->platform + (sizetype)((long unsigned int)e->animpos * 32)’ must not be NULL [-Werror=address]
22328 |                     if ( anim->platform[e->animpos] )
      |                          ^~~~
Compiling LINUX Port: sdl/video.c...
Compiling LINUX Port: sdl/videocommon.c...
Compiling LINUX Port: sdl/threads.c...
Compiling LINUX Port: sdl/menu.c...
Compiling LINUX Port: sdl/opengl.c...
Compiling LINUX Port: sdl/loadgl.c...
Compiling LINUX Port: source/adpcmlib/adpcm.c...
Compiling LINUX Port: source/gfxlib/2xSaI.c...
Compiling LINUX Port: source/gfxlib/bilinear.c...
Compiling LINUX Port: source/gfxlib/dotmatrix.c...
Compiling LINUX Port: source/gfxlib/gfx.c...
Compiling LINUX Port: source/gfxlib/hq2x.c...
Compiling LINUX Port: source/gfxlib/scale2x.c...
Compiling LINUX Port: source/gfxlib/scanline.c...
Compiling LINUX Port: source/gfxlib/simple2x.c...
Compiling LINUX Port: source/gfxlib/tv2x.c...
Compiling LINUX Port: source/gamelib/draw.c...
Compiling LINUX Port: source/gamelib/draw16.c...
Compiling LINUX Port: source/gamelib/draw32.c...
Compiling LINUX Port: source/gamelib/font.c...
Compiling LINUX Port: source/gamelib/translation.c...
Compiling LINUX Port: source/gamelib/anigif.c...
Compiling LINUX Port: source/gamelib/bitmap.c...
Compiling LINUX Port: source/gamelib/screen.c...
Compiling LINUX Port: source/gamelib/screen16.c...
Compiling LINUX Port: source/gamelib/screen32.c...
Compiling LINUX Port: source/gamelib/loadimg.c...
Compiling LINUX Port: source/gamelib/palette.c...
Compiling LINUX Port: source/gamelib/packfile.c...
Compiling LINUX Port: source/gamelib/filecache.c...
Compiling LINUX Port: source/gamelib/pixelformat.c...
Compiling LINUX Port: source/gamelib/soundmix.c...
Compiling LINUX Port: source/gamelib/spriteq.c...
Compiling LINUX Port: source/gamelib/sprite.c...
Compiling LINUX Port: source/gamelib/spritex8p16.c...
Compiling LINUX Port: source/gamelib/spritex8p32.c...
Compiling LINUX Port: source/gamelib/models.c...
Compiling LINUX Port: source/gamelib/transform.c...
Compiling LINUX Port: source/gamelib/filters.c...
Compiling LINUX Port: source/stringptr.c...
Compiling LINUX Port: source/utils.c...
Compiling LINUX Port: source/stristr.c...
Compiling LINUX Port: source/omath.c...
Compiling LINUX Port: source/scriptlib/StackedSymbolTable.c...
source/utils.c: In function ‘checkAlloc’:
source/utils.c:307:9: error: ‘mallinfo’ is deprecated [-Werror=deprecated-declarations]
  307 |         writeToLogFile("Memory usage at exit: %u\n", mallinfo().arena);
      |         ^~~~~~~~~~~~~~
In file included from source/utils.c:13:
/usr/include/malloc.h:114:24: note: declared here
  114 | extern struct mallinfo mallinfo (void) __THROW __MALLOC_DEPRECATED;
      |                        ^~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:713: source/utils.o] Error 1
make: *** Waiting for unfinished jobs....
cc1: all warnings being treated as errors
make: *** [Makefile:712: openbor.o] Error 1

Removing All LINUX Files...
Done!

I think build.sh is extremely fragile. I wish it was replaced by cmake or meson. If you want an easy experience, meson.

Debugging

Reproduce

  1. ./build.sh 4

Expected behavior

No error.

Version

  • Platform: Gentoo Linux
  • Engine Build: https://github.com/DCurrent/openbor/commit/7f6f17507078848be625e6d1c1b4f41823151387

amano-kenji avatar Mar 24 '23 23:03 amano-kenji

Try building with gcc 7 or below.

msmalik681 avatar Mar 25 '23 00:03 msmalik681

Gentoo Linux doesn't have gcc 7. I have gcc 12.

https://packages.gentoo.org/packages/sys-devel/gcc

amano-kenji avatar Mar 25 '23 01:03 amano-kenji

Newer builds work with newer gcc but if your trying to build the last stable then i suggest using a virtual machine with ubuntu 20.04. So does the linux appimage not work for you ?

msmalik681 avatar Mar 25 '23 03:03 msmalik681

The appimage works for now without firejail. But, firejail often fails to deliver ALSA devices and input devices to appimage. Thus, I extracted files from appimage and run them in firejail.

How long is AppImage supposed to work? I suppose, not long because the executable still uses system shared libraries.

amano-kenji avatar Mar 25 '23 05:03 amano-kenji

It seems the executable uses wayland. But, I don't know how to run it on wayland instead of xwayland.

amano-kenji avatar Mar 25 '23 05:03 amano-kenji

I suggest replacing build.sh with meson or cmake or just plain configure.

I don't expect build.sh to be actually portable across various operating systems or across different machines.

amano-kenji avatar Mar 25 '23 05:03 amano-kenji

I will make sure everything is working in future releases but for now I know this is a terrible work around but maybe use the windows executable with wine.

msmalik681 avatar Mar 25 '23 10:03 msmalik681

I hated using wine.

amano-kenji avatar Mar 25 '23 11:03 amano-kenji

I think appimage is not necessary for openbor. It just needs to produce a statically linked binary.

amano-kenji avatar Mar 25 '23 11:03 amano-kenji

"statically linked binary" what does that mean?

msmalik681 avatar Mar 25 '23 13:03 msmalik681

$ ldd OpenBOR
	linux-vdso.so.1 (0x00007ffcc9596000)
	libSDL2-2.0.so.0 => ../lib/libSDL2-2.0.so.0 (0x00007fecaf000000)
	libSDL2_gfx-1.0.so.0 => ../lib/libSDL2_gfx-1.0.so.0 (0x00007fecaec00000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fecaf372000)
	libvorbisfile.so.3 => ../lib/libvorbisfile.so.3 (0x00007fecae800000)
	libvorbis.so.0 => ../lib/libvorbis.so.0 (0x00007fecae400000)
	libvpx.so.3 => ../lib/libvpx.so.3 (0x00007fecade00000)
	libpng12.so.0 => ../lib/libpng12.so.0 (0x00007fecada00000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fecaef22000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fecaea2a000)
	libasound.so.2 => /usr/lib64/libasound.so.2 (0x00007fecaee32000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007fecaf36a000)
	libpulse.so.0 => ../lib/libpulse.so.0 (0x00007fecad600000)
	libsndio.so.6.1 => ../lib/libsndio.so.6.1 (0x00007fecad200000)
	libX11.so.6 => /usr/lib64/libX11.so.6 (0x00007fecae6ba000)
	libXext.so.6 => ../lib/libXext.so.6 (0x00007fecace00000)
	libXcursor.so.1 => ../lib/libXcursor.so.1 (0x00007fecaca00000)
	libXinerama.so.1 => ../lib/libXinerama.so.1 (0x00007fecac600000)
	libXi.so.6 => ../lib/libXi.so.6 (0x00007fecac200000)
	libXrandr.so.2 => ../lib/libXrandr.so.2 (0x00007fecabe00000)
	libXss.so.1 => ../lib/libXss.so.1 (0x00007fecaba00000)
	libXxf86vm.so.1 => ../lib/libXxf86vm.so.1 (0x00007fecab600000)
	libwayland-egl.so.1 => ../lib/libwayland-egl.so.1 (0x00007fecab200000)
	libwayland-client.so.0 => ../lib/libwayland-client.so.0 (0x00007fecaae00000)
	libwayland-cursor.so.0 => ../lib/libwayland-cursor.so.0 (0x00007fecaaa00000)
	libxkbcommon.so.0 => ../lib/libxkbcommon.so.0 (0x00007fecaa600000)
	librt.so.1 => /lib64/librt.so.1 (0x00007fecaf362000)
	libogg.so.0 => ../lib/libogg.so.0 (0x00007fecaa200000)
	libz.so.1 => /lib64/libz.so.1 (0x00007fecaf342000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fecaf39a000)
	libpulsecommon-8.0.so => ../lib/libpulsecommon-8.0.so (0x00007feca9e00000)
	libdbus-1.so.3 => ../lib/libdbus-1.so.3 (0x00007feca9a00000)
	libbsd.so.0 => ../lib/libbsd.so.0 (0x00007feca9600000)
	libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x00007fecae68a000)
	libXrender.so.1 => ../lib/libXrender.so.1 (0x00007feca9200000)
	libXfixes.so.3 => ../lib/libXfixes.so.3 (0x00007feca8e00000)
	libffi.so.6 => ../lib/libffi.so.6 (0x00007feca8a00000)
	libsystemd.so.0 => ../lib/libsystemd.so.0 (0x00007fecae372000)
	libwrap.so.0 => ../lib/libwrap.so.0 (0x00007feca8600000)
	libsndfile.so.1 => ../lib/libsndfile.so.1 (0x00007feca8200000)
	libasyncns.so.0 => ../lib/libasyncns.so.0 (0x00007feca7e00000)
	libapparmor.so.1 => ../lib/libapparmor.so.1 (0x00007feca7a00000)
	libXau.so.6 => /usr/lib64/libXau.so.6 (0x00007fecaf33a000)
	libXdmcp.so.6 => /usr/lib64/libXdmcp.so.6 (0x00007fecaf332000)
	libselinux.so.1 => ../lib/libselinux.so.1 (0x00007feca7600000)
	liblzma.so.5 => ../lib/liblzma.so.5 (0x00007feca7200000)
	libgcrypt.so.20 => ../lib/libgcrypt.so.20 (0x00007feca6e00000)
	libnsl.so.1 => ../lib/libnsl.so.1 (0x00007feca6a00000)
	libFLAC.so.8 => ../lib/libFLAC.so.8 (0x00007feca6600000)
	libvorbisenc.so.2 => ../lib/libvorbisenc.so.2 (0x00007feca6200000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fecaf31a000)
	libpcre.so.3 => ../lib/libpcre.so.3 (0x00007feca5e00000)
	libgpg-error.so.0 => /usr/lib64/libgpg-error.so.0 (0x00007fecae662000)

Those are libraries dynamically linked by OpenBOR linux executable. The dynamically linked libraries from appimage are in '../lib/' directory. Those can be linked statically instead.

A statically linked executable would have no dynamically linked library or only a few that will not change over decades.

amano-kenji avatar Mar 25 '23 14:03 amano-kenji

If I was responsible for the build, I would replace build.sh with meson. If meson is not an option, then cmake or something easier than cmake.

I would produce a statically linked binary instead of an appimage. A statically linked binary is simpler than an appimage.

An appimage may be beneficial when there are resource files that should come with the binary. If there is no resource file that should come with the binary, then a statically linked executable is simpler.

amano-kenji avatar Mar 25 '23 14:03 amano-kenji

$ SDL_VIDEODRIVER=wayland ./OpenBOR_3.0_6391.AppImage
./OpenBOR_3.0_6391.AppImage: symbol lookup error: /usr/lib64/libEGL_mesa.so.0: undefined symbol: wl_proxy_marshal_flags

Appimage is already incompatible with mesa when SDL_VIDEODRIVER=wayland instead of SDL_VIDEODRIVER=x11.

amano-kenji avatar Mar 25 '23 15:03 amano-kenji

Wow i did not know there was such a downside to a appimage but the alternative is to build from source again something we are looking to fix for future builds.

There have been talks of moving to a more updated comiler but it would have to work across all platforms we support.

msmalik681 avatar Mar 25 '23 16:03 msmalik681

The actual downside of appimage is that since it involves more moving parts than a statically linked executable, firejail is still buggy with appimage. Security containers like firejail and flatpak can be buggy with appimage until they figure out how to use appimage.

Fixing incompatibility with mesa requires static linking which can be done with or without appimage. Or, you can just update the codebase to make it compatible with latest versions of mesa.

amano-kenji avatar Mar 25 '23 22:03 amano-kenji

I figured out why the appimage didn't have access to devices in firejail. It's going to be fixed.

Appimage is fine, but I want to build it on gentoo linux and package it for gentoo linux.

amano-kenji avatar Mar 29 '23 13:03 amano-kenji

We found a fix for compiling on linux i will get back to you with a update soon

msmalik681 avatar Mar 29 '23 13:03 msmalik681