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

Build fails on Linux ARM64 (sokol-shdc not supported on this platform) #104

Open
Sakari369 opened this issue Aug 18, 2022 · 4 comments
Open
Assignees

Comments

@Sakari369
Copy link

Hey, I'm trying to build the sokol-samples on Linux ARM64 (running virtualized inside a M1 mac), the build fails most probably because the sokol-tools-bin does not contain a precompiled version for arm64 linux:

=== building: sapp-linux-make-debug
cmake --build . --parallel 6 --config Debug -- 
[  2%] Built target imgui
[  3%] Built target microui
[  5%] Built target cimgui
[  7%] Built target imgui-dock
[ 19%] Built target libmodplug
[ 19%] Building C object libs/sokol/CMakeFiles/sokol.dir/sokol.c.o
Consolidate compiler generated dependencies of target stb
Consolidate compiler generated dependencies of target basisu
[ 20%] Building C object libs/sokol/CMakeFiles/sokol-noentry.dir/sokol-noentry.c.o
[ 20%] Building CXX object libs/sokol/CMakeFiles/sokol-cpp.dir/sokol.cc.o
[ 21%] Built target stb
[ 22%] Built target basisu
[ 23%] Building C object libs/sokol/CMakeFiles/sokol-dll.dir/sokol-dll.c.o
[ 24%] Building C object libs/nuklear/CMakeFiles/nuklear.dir/nuklear.c.o
[ 25%] Building CXX object libs/ozzanim/CMakeFiles/ozzanim.dir/src/ozz_base.cc.o
[ 25%] Building CXX object libs/ozzanim/CMakeFiles/ozzanim.dir/src/ozz_animation.cc.o
[ 26%] Linking C static library libsokol.a
[ 26%] Built target sokol
[ 27%] Building C object libs/util/CMakeFiles/fileutil.dir/fileutil.c.o
[ 27%] Linking CXX static library libsokol-cpp.a
[ 27%] Linking C shared library /home/parallels/dvl/fips-deploy/sokol-samples/sapp-linux-make-debug/libsokol-dll.so
[ 27%] Linking C static library libfileutil.a
[ 27%] Linking C static library libsokol-noentry.a
[ 27%] Built target sokol-cpp
[ 27%] Built target sokol-dll
[ 27%] Built target fileutil
[ 27%] Built target sokol-noentry
[ 27%] Building C object sapp/CMakeFiles/clear-sapp.dir/clear-sapp.c.o
[ 27%] Building CXX object libs/ozzanim/CMakeFiles/ozzanim.dir/src/mesh.cc.o
[ 27%] Building CXX object libs/dbgui/CMakeFiles/dbgui.dir/dbgui.cc.o
## sokol-shdc: /home/parallels/dvl/sokol-samples/sapp/triangle-sapp.glsl /home/parallels/dvl/fips-build/sokol-samples/sapp-linux-make-debug/sapp/triangle-sapp.glsl.h {'slang': 'glsl330', 'compiler': 'GNU'}
[ 27%] Linking C executable /home/parallels/dvl/fips-deploy/sokol-samples/sapp-linux-make-debug/clear-sapp
Traceback (most recent call last):
  File "/home/parallels/dvl/fips-build/sokol-samples/sapp-linux-make-debug/fips-gen.py", line 65, in <module>
    processFile(attrs)
  File "/home/parallels/dvl/fips-build/sokol-samples/sapp-linux-make-debug/fips-gen.py", line 56, in processFile
    module.generate(input, out_src, out_hdr, args)
  File "/home/parallels/dvl/sokol-tools-bin/fips-files/generators/SokolShader.py", line 57, in generate
    res = subprocess.call(cmd)
  File "/usr/lib/python3.10/subprocess.py", line 345, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.10/subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1842, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/parallels/dvl/sokol-tools-bin/fips-files/generators/../../bin/linux/sokol-shdc'
gmake[2]: *** [sapp/CMakeFiles/ALL_GENERATE.dir/build.make:70: sapp/CMakeFiles/ALL_GENERATE] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1087: sapp/CMakeFiles/ALL_GENERATE.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
[ 27%] Built target clear-sapp
[ 28%] Linking CXX static library libdbgui.a
[ 28%] Built target dbgui
[ 29%] Linking CXX static library libozzanim.a
[ 29%] Built target ozzanim
[ 29%] Linking C static library libnuklear.a
[ 29%] Built target nuklear
gmake: *** [Makefile:91: all] Error 2
[ERROR] Failed to build config 'sapp-linux-make-debug' of project 'sokol-samples'
parallels@ubuntu-linux-22-04-desktop ~/d/sokol-samples (master) [10]> 
parallels@ubuntu-linux-22-04-desktop ~/d/sokol-samples (master) [10]> uname -a
Linux ubuntu-linux-22-04-desktop 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:08:11 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

Just wanted to report this, although probably not a high priority target and seems I can manually build the docker version of the sokol-shdc, at least I got it to compile but no idea how to run it (no experience with docker).

Anyway let me know if you need somebody to build the binary on, already succeeded on it but gave up as couldn't figure out how to run it or where the docker build actually ended up :)

@floooh
Copy link
Owner

floooh commented Aug 18, 2022

Yep, that's expected unfortunately. Fixing this shouldn't be too complicated, because I had set up a build pipeline for sokol-shdc here while ago: https://github.com/floooh/sokol-tools/actions/runs/2765663111

How do you run Linux on your M1 Mac? Through Docker, or some other VM solution? If I manage to setup a similar environment on my Mac I can look into this.

PS: thinking about this, I probably just need to build sokol-shdc in a different docker image (like https://hub.docker.com/r/arm64v8/alpine/) - the Linux build already happens in an Alpine docker image so that I can trivially get a statically linked executable which runs on all Linux distros.

@floooh floooh self-assigned this Aug 18, 2022
@Sakari369
Copy link
Author

Sakari369 commented Aug 18, 2022

Yep, that's expected unfortunately. Fixing this shouldn't be too complicated, because I had set up a build pipeline for sokol-shdc here while ago: https://github.com/floooh/sokol-tools/actions/runs/2765663111

How do you run Linux on your M1 Mac? Through Docker, or some other VM solution? If I manage to setup a similar environment on my Mac I can look into this.

I'm running Ubuntu 22.04 arm64 with Parallels Desktop 18, which is of course a commercial product. Don't have much experience with other virtualization systems on M1, so can't help on that one too much if it's possible with other solutions.

PS: thinking about this, I probably just need to build sokol-shdc in a different docker image (like https://hub.docker.com/r/arm64v8/alpine/) - the Linux build already happens in an Alpine docker image so that I can trivially get a statically linked executable which runs on all Linux distros.

If it's not too complicated, would help us test out that our Linux builds (https://sumo.app/, working on an yet-to-be-announced creative software that uses Sokol as it's GPU abstraction and app layer) work on a single developer computer more easier. Can help you test out if needed 👍

@floooh
Copy link
Owner

floooh commented Aug 27, 2022

Hmm, wait it's not as simple as just running an ARM docker image, this would need emulation because the Github runners are all x86. I need to add proper linux cross-compilation support to fips first, that's be a bit more work. I'll try to tinker with this in a free minute.

@Sakari369
Copy link
Author

Hmm, wait it's not as simple as just running an ARM docker image, this would need emulation because the Github runners are all x86. I need to add proper linux cross-compilation support to fips first, that's be a bit more work. I'll try to tinker with this in a free minute.

Well don't stress about it, not a high priority target, we are running actual x86 linux machines for our Linux developers anyway, the arm64 target would be nice but not necessary :)

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

2 participants