godot-jolt / godot-jolt

Godot Jolt is a Godot extension that integrates the Jolt physics engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Friction combine function fails to compile on ARM64 Linux

Samuel-Maddock opened this issue · comments

Is there support for building godot-jolt to target arm64 on linux (Ubuntu 22.04)?

I have attempted to modify the CMakePresets.json for arm64 using clang (15.0.7) as follows:

    {
      "name": "arm64-base",
      "hidden": true,
      "cacheVariables": {
        "GDJ_TARGET_ARCHITECTURES": "arm64",
        "GDJ_X86_INSTRUCTION_SET": "NONE"    
      }
    },
    {
      "name": "gcc-arm64-base",
      "inherits": ["arm64-base"],
      "hidden": true,
      "environment": {
        "CFLAGS": "$penv{CFLAGS} -m64",
        "CXXFLAGS": "$penv{CXXFLAGS} -m64",
        "LDFLAGS": "$penv{LDFLAGS} -m64"
      }
    },
    {
      "name": "linux-clang-arm64",
      "displayName": "Clang, arm64",
      "inherits": ["linux-base", "clang-base", "lld-base", "gcc-arm64-base"]
    },
    {
      "name": "linux-clang-arm64-distribution",
      "inherits": ["linux-base", "install-base"],
      "configurePreset": "linux-clang-arm64",
      "configuration": "Distribution",
      "displayName": "Distribution"
    }

I get partway through the build process of cmake --build --preset linux-clang-arm64-distribution with the following error:

[31/31] Linking CXX static library Distribution/libgodot-cpp.a
[78/81] Building CXX object CMakeFiles/godot-jolt.dir/Distribution/src/spaces/jolt_space_3d.cpp.o
FAILED: CMakeFiles/godot-jolt.dir/Distribution/src/spaces/jolt_space_3d.cpp.o 
/usr/bin/clang++ -DGDJ_CONFIG_DISTRIBUTION -DGDJ_EXTERNAL_GODOT_CPP=43d02f2d7c -DGDJ_EXTERNAL_JOLT=4a74ff08e4 -DGDJ_EXTERNAL_MIMALLOC=43ce4bd7fd -DGDJ_GODOT_VERSION_MAJOR=4 -DGDJ_GODOT_VERSION_MINOR=2 -DGDJ_PLATFORM_LINUX -DGDJ_USE_MIMALLOC -DGDJ_VERSION_MAJOR=0 -DGDJ_VERSION_MINOR=12 -DGDJ_VERSION_PATCH=1 -DNDEBUG -DCMAKE_INTDIR=\"Distribution\" -I/home/ubuntu/GitHub/slc_game/godot-jolt/src -isystem /home/ubuntu/GitHub/slc_game/godot-jolt/build/linux-clang-arm64/External/Source/godot-cpp/gdextension -isystem /home/ubuntu/GitHub/slc_game/godot-jolt/build/linux-clang-arm64/External/Source/godot-cpp/include -isystem /home/ubuntu/GitHub/slc_game/godot-jolt/build/linux-clang-arm64/External/Build/godot-cpp/gen/include -isystem /home/ubuntu/GitHub/slc_game/godot-jolt/build/linux-clang-arm64/External/Source/jolt -isystem /home/ubuntu/GitHub/slc_game/godot-jolt/build/linux-clang-arm64/External/Source/mimalloc/include -O2 -g -DNDEBUG -flto=thin -fPIC -fvisibility=hidden -Wall -Wextra -pedantic -Wconversion -Wsign-conversion -Wcast-qual -Wshadow -Wundef -Wno-gnu-zero-variadic-macro-arguments -pthread -fno-exceptions -std=gnu++17 -Winvalid-pch -Xclang -include-pch -Xclang /home/ubuntu/GitHub/slc_game/godot-jolt/build/linux-clang-arm64/CMakeFiles/godot-jolt.dir/Distribution/cmake_pch.hxx.pch -Xclang -include -Xclang /home/ubuntu/GitHub/slc_game/godot-jolt/build/linux-clang-arm64/CMakeFiles/godot-jolt.dir/Distribution/cmake_pch.hxx -MD -MT CMakeFiles/godot-jolt.dir/Distribution/src/spaces/jolt_space_3d.cpp.o -MF CMakeFiles/godot-jolt.dir/Distribution/src/spaces/jolt_space_3d.cpp.o.d -o CMakeFiles/godot-jolt.dir/Distribution/src/spaces/jolt_space_3d.cpp.o -c /home/ubuntu/GitHub/slc_game/godot-jolt/src/spaces/jolt_space_3d.cpp
/home/ubuntu/GitHub/slc_game/godot-jolt/src/spaces/jolt_space_3d.cpp:65:11: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
                        return abs(min(p_body1.GetFriction(), p_body2.GetFriction()));
                               ^
/home/ubuntu/GitHub/slc_game/godot-jolt/src/spaces/jolt_space_3d.cpp:65:11: note: use function 'std::abs' instead
                        return abs(min(p_body1.GetFriction(), p_body2.GetFriction()));
                               ^~~
                               std::abs
/home/ubuntu/GitHub/slc_game/godot-jolt/src/spaces/jolt_space_3d.cpp:65:15: warning: implicit conversion turns floating-point number into integer: 'const float' to 'int' [-Wfloat-conversion]
                        return abs(min(p_body1.GetFriction(), p_body2.GetFriction()));
                               ~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ubuntu/GitHub/slc_game/godot-jolt/src/spaces/jolt_space_3d.cpp:61:3: error: no viable conversion from '(lambda at /home/ubuntu/GitHub/slc_game/godot-jolt/src/spaces/jolt_space_3d.cpp:61:3)' to 'ContactConstraintManager::CombineFunction' (aka 'float (*)(const JPH::Body &, const JPH::SubShapeID &, const JPH::Body &, const JPH::SubShapeID &)')
                [](const JPH::Body& p_body1,
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ubuntu/GitHub/slc_game/godot-jolt/src/spaces/jolt_space_3d.cpp:61:3: note: candidate function
/home/ubuntu/GitHub/slc_game/godot-jolt/build/linux-clang-arm64/External/Source/jolt/Jolt/Physics/PhysicsSystem.h:56:73: note: passing argument to parameter 'inCombineFriction' here
        void                                            SetCombineFriction(ContactConstraintManager::CombineFunction inCombineFriction) { mContactManager.SetCombineFriction(inCombineFriction); }
                                                                                                                     ^
2 warnings and 1 error generated.
[79/81] Building CXX object CMakeFiles/godot-jolt.dir/Distribution/src/spaces/jolt_physics_direct_space_state_3d.cpp.o
ninja: build stopped: subcommand failed.

Any pointers would be appreciated, thanks!

Are you cross-compiling for ARM64 on x86/x64 or are you just compiling for ARM64 on ARM64? That will impact how you go about doing this.

If you're just compiling for ARM64 on ARM64 then your configure preset just needs to inherit from ["linux-base", "clang-base", "lld-base"]. You should not use the -m64 flag since that will make GCC/Clang emit x86-64 machine code, as opposed to AArch64.

If you're cross-compiling then the whole thing gets a bit trickier, since you'll need a CMake toolchain file and all that jazz, much like what I do with Android and iOS currently.

As for the compilation errors you ran into, those should hopefully be fixed as of #768.

I am just compiling ARM64 on ARM64 - the fixes in #768 with the configure preset you mentioned now work for me. Thanks so much!