diff options
| author | Yang Liu <liuyang22@iscas.ac.cn> | 2023-11-26 23:47:29 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-26 16:47:29 +0100 |
| commit | bdf7d477426f00bb3559a6428d8ed7491b60fbe4 (patch) | |
| tree | afbf77278bd1fd3eae1d4b768056c8b45d62b524 | |
| parent | 6ad9435b4d5720c70fed6e0ade85cb56f9be204d (diff) | |
| download | box64-bdf7d477426f00bb3559a6428d8ed7491b60fbe4.tar.gz box64-bdf7d477426f00bb3559a6428d8ed7491b60fbe4.zip | |
[CMAKE] Add WITH_MOLD option (#1085)
GNU ld is extremely slow on RISC-V. mold is a much faster drop in replacement, but it does not support `-Ttext-segment`, so add an option to allow use it.
| -rw-r--r-- | CMakeLists.txt | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bac0c02..52bee538 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ option(NOGIT "Set to ON if not building from a git clone repo (like when buildin option(BAD_SIGNAL "Set to ON to activate the workaround for incoherent si_info on SIGSEGV" ${BAD_SIGNAL}) option(SW64 "Set ON if targeting an SW64 based device" ${SW64}) option(CI "Set to ON if running in CI" ${CI}) +option(WITH_MOLD "Set to ON to use with mold" ${WITH_MOLD}) if(LARCH64) set(LD80BITS OFF CACHE BOOL "") @@ -804,7 +805,7 @@ target_link_libraries(${BOX64} interpreter) if(${CMAKE_VERSION} VERSION_LESS "3.13") if(NOT NOLOADADDR) - if(CMAKE_C_COMPILER_ID STREQUAL "Clang") + if(CMAKE_C_COMPILER_ID STREQUAL "Clang" OR WITH_MOLD) set_target_properties(${BOX64} PROPERTIES LINK_FLAGS "-Wl,--image-base=${BOX64_ELF_ADDRESS}") else() set_target_properties(${BOX64} PROPERTIES LINK_FLAGS "-Wl,-Ttext-segment,${BOX64_ELF_ADDRESS}") @@ -813,7 +814,7 @@ if(${CMAKE_VERSION} VERSION_LESS "3.13") else() # If symbols are missing, try this: target_link_options(${BOX64} PUBLIC -rdynamic) if(NOT NOLOADADDR) - if(CMAKE_C_COMPILER_ID STREQUAL "Clang") + if(CMAKE_C_COMPILER_ID STREQUAL "Clang" OR WITH_MOLD) target_link_options(${BOX64} PUBLIC LINKER:--image-base=${BOX64_ELF_ADDRESS}) else() target_link_options(${BOX64} PUBLIC LINKER:-Ttext-segment,${BOX64_ELF_ADDRESS}) |