godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
86.3k stars 19.2k forks source link

Unable to cross-compile to Linux arm platforms (oidn and embree are incompatible) #48297

Open ggardet opened 3 years ago

ggardet commented 3 years ago

Godot version: 3.3

OS/device including version: openSUSE Tumbleweed

Issue description: I am unable to build godot 3.3 on Arm (aarch64, armv7 and armv6) becauseof:

[ 4474s] g++ -o thirdparty/oidn/core/device.x11.opt.tools.64.o -c -std=gnu++14 -w -g2 -O2 -mbranch-protection=standard -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -flto -pipe -Wall -Wno-misleading-indentation -Wshadow-local -Werror=return-type -w -DDEBUG_ENABLED -DSERVER_ENABLED -DUNIX_ENABLED -DPTRCALL_ENABLED -DTOOLS_ENABLED -DGDSCRIPT_ENABLED -DMINIZIP_ENABLED -DMODULE_BMP_ENABLED -DMODULE_BULLET_ENABLED -DMODULE_CSG_ENABLED -DMODULE_CVTT_ENABLED -DMODULE_DDS_ENABLED -DMODULE_DENOISE_ENABLED -DMKLDNN_THR=MKLDNN_THR_SEQ -DOIDN_STATIC_LIB -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DDISABLE_VERBOSE -DMKLDNN_ENABLE_CONCURRENT_EXEC -DNDEBUG -Ithirdparty/oidn -Ithirdparty/oidn/include -Ithirdparty/oidn/mkl-dnn/include -Ithirdparty/oidn/mkl-dnn/src -Ithirdparty/oidn/mkl-dnn/src/common -Ithirdparty/oidn/mkl-dnn/src/cpu/xbyak -Ithirdparty/oidn/mkl-dnn/src/cpu -Iplatform/server -I/usr/include/miniupnpc -I. -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/bullet -I/usr/include/opus thirdparty/oidn/core/device.cpp
[ 4474s] In file included from thirdparty/oidn/core/common.h:19,
[ 4474s]                  from thirdparty/oidn/core/device.h:19,
[ 4474s]                  from thirdparty/oidn/core/device.cpp:17:
[ 4474s] thirdparty/oidn/common/platform.h:27:10: fatal error: xmmintrin.h: No such file or directory
[ 4474s]    27 | #include <xmmintrin.h>
[ 4474s]       |          ^~~~~~~~~~~~~
[ 4474s] compilation terminated.
[ 4474s] scons: *** [thirdparty/oidn/core/device.x11.opt.tools.64.o] Error 1
[ 4474s] In file included from thirdparty/oidn/core/common.h:19,
[ 4474s]                  from thirdparty/oidn/core/device.h:19,
[ 4474s]                  from thirdparty/oidn/core/api.cpp:48:
[ 4474s] thirdparty/oidn/common/platform.h:27:10: fatal error: xmmintrin.h: No such file or directory
[ 4474s]    27 | #include <xmmintrin.h>
[ 4474s]       |          ^~~~~~~~~~~~~
[ 4474s] compilation terminated.
[ 4474s] scons: *** [thirdparty/oidn/core/api.x11.opt.tools.64.o] Error 1
[ 4478s] scons: building terminated because of errors.

oidn is likely too old. A fix is available upstream: https://github.com/OpenImageDenoise/oidn/commit/1439239a3c9a0fb77bd0feda3ea60a3008b808dd

Steps to reproduce: Try to build on Arm.

Minimal reproduction project: N/A

akien-mga commented 3 years ago

That's a known issue, the raycast, lightmapper_cpu and oidn modules are only compatible with x86_64 and should be disabled on other platforms, but the checks we use don't work well for cross-compilation (they check the host arch instead of target arch, which we don't track properly). It should work fine if you build on real hardware however (albeit with latest 3.3 branch, there have been a few fixes since 3.3-stable for this).

So you should disable these modules with module_denoise_enabled=no module_lightmapper_cpu_enabled=no module_raycast_enabled=no.

ggardet commented 3 years ago

Please note this is native builds, not cross-compiling.

akien-mga commented 3 years ago

So you're not building from a x86_64 Linux host? Then it should work fine. Can you try latest 3.3 branch?

Specifically, on real hardware, you shouldn't pass this (extremely hacky) check and thus it shouldn't attempt building oidn: https://github.com/godotengine/godot/blob/08bedba3411a5392fe947f3d625c8c933e724b13/modules/denoise/config.py#L12-L18

It fails when cross compiling as platform.machine() is the host, not the target.

akien-mga commented 3 years ago

If this is for openSUSE distro packaging, see my Mageia and Fedora package sources (they're the same, I maintain both).

Notably patches to allow unbundling embree and the need to manually disable the lightmapper on !x86_64 because our scripts are broken when run on an x86_64 host: https://src.fedoraproject.org/rpms/godot/blob/rawhide/f/godot.spec#_25 https://src.fedoraproject.org/rpms/godot/blob/rawhide/f/godot.spec#_242

akien-mga commented 3 years ago

For the reference after #48455, the raycast and lightmapper_cpu modules can now be built on aarch64. The denoise module is still x86_64 only for now and needs to be disabled manually.