cmake: fix link with lld and mold (#73)

This commit is contained in:
Alexandre Bouvier 2024-09-16 15:55:40 +00:00 committed by GitHub
parent 7e78907829
commit 0634f87168
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 2 deletions

View file

@ -52,6 +52,14 @@ function(add_precompiled_vulkan_spirv target)
endforeach()
endfunction()
function(target_base_address target address)
if(CMAKE_CXX_COMPILER_LINKER_ID MATCHES "^(LLD|MOLD)$")
target_link_options(${target} PUBLIC "LINKER:--image-base=${address}")
else()
target_link_options(${target} PUBLIC "LINKER:-Ttext-segment,${address}")
endif()
endfunction()
add_subdirectory(tools)
add_subdirectory(orbis-kernel)

View file

@ -8,5 +8,5 @@ add_executable(rpcsx-gpu
target_include_directories(rpcsx-gpu PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(rpcsx-gpu PUBLIC amdgpu::bridge amdgpu::device glfw Vulkan::Vulkan rx)
set_target_properties(rpcsx-gpu PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
target_link_options(rpcsx-os PUBLIC "LINKER:-Ttext-segment,0x0000060000000000")
target_base_address(rpcsx-os 0x0000060000000000)
install(TARGETS rpcsx-gpu RUNTIME DESTINATION bin)

View file

@ -65,7 +65,7 @@ add_executable(rpcsx-os
target_include_directories(rpcsx-os PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(rpcsx-os PUBLIC orbis::kernel amdgpu::bridge rx libcrypto libunwind::unwind-x86_64 xbyak::xbyak)
target_link_options(rpcsx-os PUBLIC "LINKER:-Ttext-segment,0x0000010000000000")
target_base_address(rpcsx-os 0x0000010000000000)
target_compile_options(rpcsx-os PRIVATE "-mfsgsbase")
set_target_properties(rpcsx-os PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)