From 338d383d47114411843d1d0b67f4a461ca3d9815 Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Sun, 21 Nov 2021 22:52:44 -0400 Subject: [PATCH] Fix FreeBSD aarch64 faulies when use luajit * FreeBSD uses lld, and lld does not support -Ttext-segment, suggesting --image-base instead. Not sure if it's equivalent change for the purpose at least if fixes build on FreeBSD/aarch64. Note that the code checks for FreeBSD, while it should really check for lld on any system, however I don't know any CMake facilities which allow this * https://codeberg.org/minenux/minetest-engine/issues/16 --- src/CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 36298b38d..36a010853 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -703,7 +703,16 @@ else() check_c_source_compiles("#ifndef __aarch64__\n#error\n#endif\nint main(){}" IS_AARCH64) if(IS_AARCH64) # Move text segment below LuaJIT's 47-bit limit (see issue #9367) - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Ttext-segment=0x200000000") + if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + # FreeBSD uses lld, and lld does not support -Ttext-segment, suggesting + # --image-base instead. Not sure if it's equivalent change for the purpose + # but at least if fixes build on FreeBSD/aarch64 + # XXX: the condition should also be changed to check for lld regardless of + # os, bit CMake doesn't have anything like CMAKE_LINKER_IS_LLD yet + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--image-base=0x200000000") + else() + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Ttext-segment=0x200000000") + endif() endif() endif()