Skip to content

Commit

Permalink
cmake: fix link with lld and mold
Browse files Browse the repository at this point in the history
  • Loading branch information
abouvier committed Sep 16, 2024
1 parent 7e78907 commit 295629c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "^(GNU|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)
Expand Down
2 changes: 1 addition & 1 deletion rpcsx-gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion rpcsx-os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 295629c

Please sign in to comment.