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

GCC 14 inlining failed in call to always_inline #1096

Closed
tksuoran opened this issue May 9, 2024 · 2 comments
Closed

GCC 14 inlining failed in call to always_inline #1096

tksuoran opened this issue May 9, 2024 · 2 comments

Comments

@tksuoran
Copy link
Contributor

tksuoran commented May 9, 2024

I can build Jolt by itself fine using GCC 14.
When I try to use Jolt in my own project using CMake fetchcontent, I get the following compilation error with GCC 14:

[build] [27/415] Building CXX object _deps/joltphysics-build/CMakeFiles/Jolt.dir/__/Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp.o
[build] FAILED: _deps/joltphysics-build/CMakeFiles/Jolt.dir/__/Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp.o 
[build] /usr/bin/g++-14 -DERHE_AUDIO_LIBRARY_NONE -DERHE_DLOAD_ALL_GL_SYMBOLS -DERHE_FONT_RASTERIZATION_LIBRARY_FREETYPE -DERHE_GLTF_LIBRARY_CGLTF -DERHE_GUI_LIBRARY_IMGUI -DERHE_OS_LINUX -DERHE_PNG_LIBRARY_MANGO -DERHE_PROFILE_LIBRARY_TRACY -DERHE_RAYTRACE_LIBRARY_BVH -DERHE_SVG_LIBRARY_LUNASVG -DERHE_TERMINAL_LIBRARY_NONE -DERHE_TEXT_LAYOUT_LIBRARY_HARFBUZZ -DERHE_WINDOW_LIBRARY_GLFW -DFMT_HEADER_ONLY -DGLM_ENABLE_EXPERIMENTAL -DGLM_FORCE_CXX2A=1 -DGLM_FORCE_DEPTH_ZERO_TO_ONE -DJPH_DEBUG_RENDERER -DJPH_FLOATING_POINT_EXCEPTIONS_ENABLED -DJPH_PROFILE_ENABLED -DJPH_USE_AVX -DJPH_USE_AVX2 -DJPH_USE_F16C -DJPH_USE_FMADD -DJPH_USE_LZCNT -DJPH_USE_SSE4_1 -DJPH_USE_SSE4_2 -DJPH_USE_TZCNT -DSPDLOG_FMT_EXTERNAL -D_DEBUG -I"/home/tksuoran/git/erhe/build/Configure GCC 14 Debug/_deps/joltphysics-src/Build/.." -Wno-comment -ffp-contract=off -Wno-inline -mavx2 -msse4.2 -mpopcnt -mlzcnt -mbmi -mf16c -mfma -Wall -Werror -g -Wno-stringop-overflow -ffp-contract=off -std=c++17 -Woverloaded-virtual -Wno-empty-body -O0 -g3 -mavx2 -mbmi -mpopcnt -mlzcnt -mf16c -mfma -mfpmath=sse -Winvalid-pch -include "/home/tksuoran/git/erhe/build/Configure GCC 14 Debug/_deps/joltphysics-build/CMakeFiles/Jolt.dir/cmake_pch.hxx" -MD -MT _deps/joltphysics-build/CMakeFiles/Jolt.dir/__/Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp.o -MF _deps/joltphysics-build/CMakeFiles/Jolt.dir/__/Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp.o.d -o _deps/joltphysics-build/CMakeFiles/Jolt.dir/__/Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp.o -c '/home/tksuoran/git/erhe/build/Configure GCC 14 Debug/_deps/joltphysics-src/Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp'
[build] /home/tksuoran/git/erhe/build/Configure GCC 14 Debug/_deps/joltphysics-src/Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp: In member function ‘virtual bool JPH::StaticCompoundShape::CastRay(const JPH::RayCast&, const JPH::SubShapeIDCreator&, JPH::RayCastResult&) const’:
[build] /home/tksuoran/git/erhe/build/Configure GCC 14 Debug/_deps/joltphysics-src/Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp:430:39: error: inlining failed in call to ‘always_inline’ ‘JPH::StaticCompoundShape::CastRay(const JPH::RayCast&, const JPH::SubShapeIDCreator&, JPH::RayCastResult&) const::Visitor::Visitor(const JPH::RayCast&, const JPH::CompoundShape*, const JPH::SubShapeIDCreator&, JPH::RayCastResult&) [inherited from JPH::CompoundShape::CastRayVisitor]’: function not considered for inlining
[build]   430 |                 using CastRayVisitor::CastRayVisitor;
[build]       |                                       ^~~~~~~~~~~~~~
[build] /home/tksuoran/git/erhe/build/Configure GCC 14 Debug/_deps/joltphysics-src/Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp:449:64: note: called from here
[build]   449 |         Visitor visitor(inRay, this, inSubShapeIDCreator, ioHit);
[build]       |                                                                ^

The compiler arguments may be slightly different from what Jolt uses by itself, even though I've tried to make them compatible.

It seems that MutableCompoundShape::CastRay() uses CompoundShape::CastRayVisitor::CastRayVisitor which is marked with JPH_INLINE which is defined to __inline__ __attribute__((always_inline)) for clang/GCC.

Any suggestions how to deal with this? Thanks!

@tksuoran
Copy link
Contributor Author

tksuoran commented May 9, 2024

Using JPH_NO_FORCE_INLINE works around the issue, but I am still curious if there is something better.

@jrouwe
Copy link
Owner

jrouwe commented May 10, 2024

I can reproduce this by just building Jolt in debug mode on gcc 14 (doesn't happen in release mode). I think that when specifying -O0 code shouldn't be inlined but it appears that the compiler gets confused and tries to inline these 2 functions anyway and then fails. I've created a workaround in #1099.

Note that it assumes that JPH_DEBUG will be on when -O0 is specified, but this doesn't need to be true, I did a quick search but can't find a macro that would allow me to detect this in a better way.

@jrouwe jrouwe closed this as completed in 4a08d8d May 10, 2024
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