Skip to content

Commit

Permalink
Use --image-base instead of -Ttext-segment for lld linker on FreeBSD (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed May 15, 2021
1 parent 69c70dd commit 53dca4f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/CMakeLists.txt
Expand Up @@ -758,7 +758,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()

Expand Down

0 comments on commit 53dca4f

Please sign in to comment.