ZDoom / gzdoom

GZDoom is a feature centric port for all Doom engine games, based on ZDoom, adding an OpenGL renderer and powerful scripting capabilities
http://zdoom.org
GNU General Public License v3.0
2.47k stars 540 forks source link

[BUG] Failing to compile from source on Raspberry Pi4 [undefined reference to `__atomic_fetch_sub_8'] #1597

Closed BoomSaag closed 1 year ago

BoomSaag commented 2 years ago

GZDoom version

4.7.1

Which game are you running with GZDoom?

No response

What Operating System are you using?

Linux ARM (Raspberry Pi)

If Other OS, please describe

No response

Relevant hardware info

Raspberry Pi 4B

Have you checked that no other similar issue already exists?

A clear and concise description of what the bug is.

I tried to compile the latest version of GZDoom on my Raspberry Pi4.

All goes well up to 99% then it fails.

It seems to be an issue with vulkan. But I am not experienced enough to figure it out:

/usr/bin/ld: CMakeFiles/zdoom.dir/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp.o: in function VmaBlockVector::~VmaBlockVector()': vk_mem_alloc.cpp:(.text+0x8260): undefined reference to `__atomic_fetch_sub_8'

Steps to reproduce the behaviour.

Explain how to reproduce

  1. Follow the instructions on https://zdoom.org/wiki/Compile_GZDoom_on_Linux

Your configuration

No response

Provide a Log

/usr/bin/ld: CMakeFiles/zdoom.dir/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp.o: in function VmaBlockVector::~VmaBlockVector()': vk_mem_alloc.cpp:(.text+0x8260): undefined reference toatomic_fetch_sub_8' /usr/bin/ld: CMakeFiles/zdoom.dir/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp.o: in function VmaAllocator_T::AllocateVulkanMemory(VkMemoryAllocateInfo const*, unsigned long long*)': vk_mem_alloc.cpp:(.text+0xbde8): undefined reference toatomic_load_8' /usr/bin/ld: vk_mem_alloc.cpp:(.text+0xbe34): undefined reference to __atomic_compare_exchange_8' /usr/bin/ld: vk_mem_alloc.cpp:(.text+0xbed0): undefined reference toatomic_fetch_add_8' /usr/bin/ld: vk_mem_alloc.cpp:(.text+0xbee8): undefined reference to __atomic_fetch_sub_8' /usr/bin/ld: CMakeFiles/zdoom.dir/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp.o: in functionVmaAllocator_T::FreeVulkanMemory(unsigned int, unsigned long long, unsigned long long)': vk_mem_alloc.cpp:(.text+0xbfe8): undefined reference to __atomic_fetch_sub_8' /usr/bin/ld: CMakeFiles/zdoom.dir/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp.o: in functionVmaAllocator_T::UpdateVulkanBudget()': vk_mem_alloc.cpp:(.text+0xcfc4): undefined reference to __atomic_load_8' /usr/bin/ld: CMakeFiles/zdoom.dir/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp.o: in functionVmaAllocator_T::GetBudget(VmaBudget*, unsigned int, unsigned int)': vk_mem_alloc.cpp:(.text+0xd1cc): undefined reference to `atomic_load_8' /usr/bin/ld: vk_mem_alloc.cpp:(.text+0xd1dc): undefined reference to __atomic_load_8' /usr/bin/ld: vk_mem_alloc.cpp:(.text+0xd2a0): undefined reference toatomic_load_8' /usr/bin/ld: vk_mem_alloc.cpp:(.text+0xd2b4): undefined reference to `atomic_load_8' /usr/bin/ld: CMakeFiles/zdoom.dir/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp.o: in function VmaAllocator_T::VmaAllocator_T(VmaAllocatorCreateInfo const*)': vk_mem_alloc.cpp:(.text+0x122d8): undefined reference toatomic_store_8' /usr/bin/ld: vk_mem_alloc.cpp:(.text+0x122ec): undefined reference to `atomic_store_8' /usr/bin/ld: CMakeFiles/zdoom.dir/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp.o: in function VmaAllocator_T::FreeMemory(unsigned int, VmaAllocation_T* const*)': vk_mem_alloc.cpp:(.text+0x13688): undefined reference toatomic_fetch_sub_8' /usr/bin/ld: CMakeFiles/zdoom.dir/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp.o: in function VmaAllocator_T::FreeMemory(unsigned int, VmaAllocation_T* const*) [clone .constprop.235]': vk_mem_alloc.cpp:(.text+0x138f4): undefined reference to__atomic_fetch_sub_8' /usr/bin/ld: CMakeFiles/zdoom.dir/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp.o: in function VmaAllocator_T::AllocateDedicatedMemoryPage(unsigned long long, VmaSuballocationType, unsigned int, VkMemoryAllocateInfo const&, bool, bool, void*, VmaAllocation_T**)': vk_mem_alloc.cpp:(.text+0x13d70): undefined reference toatomic_fetch_add_8' /usr/bin/ld: CMakeFiles/zdoom.dir/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp.o: in function VmaAllocator_T::AllocateDedicatedMemory(unsigned long long, VmaSuballocationType, unsigned int, bool, bool, bool, void*, float, unsigned long long, unsigned int, unsigned long long, unsigned int, VmaAllocation_T**)': vk_mem_alloc.cpp:(.text+0x1404c): undefined reference toatomic_fetch_sub_8' /usr/bin/ld: CMakeFiles/zdoom.dir/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp.o: in function VmaBlockVector::AllocateFromBlock(VmaDeviceMemoryBlock*, unsigned int, unsigned long long, unsigned long long, unsigned int, void*, VmaSuballocationType, unsigned int, VmaAllocation_T**)': vk_mem_alloc.cpp:(.text+0x14800): undefined reference toatomic_fetch_add_8' /usr/bin/ld: CMakeFiles/zdoom.dir/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp.o: in function VmaBlockVector::AllocatePage(unsigned int, unsigned long long, unsigned long long, VmaAllocationCreateInfo const&, VmaSuballocationType, VmaAllocation_T**)': vk_mem_alloc.cpp:(.text+0x150fc): undefined reference toatomic_fetch_add_8' /usr/bin/ld: CMakeFiles/zdoom.dir/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp.o: in function VmaBlockVector::Allocate(unsigned int, unsigned long long, unsigned long long, VmaAllocationCreateInfo const&, VmaSuballocationType, unsigned int, VmaAllocation_T**)': vk_mem_alloc.cpp:(.text+0x15350): undefined reference toatomic_fetch_sub_8' collect2: error: ld returned 1 exit status make[2]: [src/CMakeFiles/zdoom.dir/build.make:7095: gzdoom] Error 1 make[1]: [CMakeFiles/Makefile2:860: src/CMakeFiles/zdoom.dir/all] Error 2 make: *** [Makefile:130: all] Error 2

BoomSaag commented 2 years ago

I managed to fix it. Had to add:

set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -latomic")

to CMakeLists.txt at the beginning right after 'set(CMAKE_CXX_EXTENSIONS OFF)'

Compiled successfully.

It does swear at me that I need at least OpenGL 3.3, but I just used `export MESA_GL_VERSION_OVERRIDE=3.3' to get it working. Works great!

coelckers commented 2 years ago

It is a bit weird that this system does not put this stuff in its standard C++ library. On other systems this change is not needed so I'm not sure what the best approach would be.

madame-rachelle commented 2 years ago

It would really help to know what specific distro and version you are using. "Linux ARM" is not helpful at all.

BoomSaag commented 2 years ago

It would really help to know what specific distro and version you are using. "Linux ARM" is not helpful at all.

Apologies, the dropdown only provided that option. But I should have expanded on it. I am running the latest version of TwisterOS: https://twisteros.com/ It is based on Raspberry Pi OS Buster, which is based on Debian Buster. I hope that helps.

madame-rachelle commented 2 years ago

Thank you - I will update that to encourage providing more info.