mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:47:35 +00:00
Meta: Link Lagom with LLD by default and allow configuring the linker
This ports over the `LADYBIRD_USE_LLD` option from the standalone Ladybird build and generalizes it to work for mold as well: the `LAGOM_USE_LINKER` variable can be set to the desired name of the linker. If it's empty, we default to trying LLD and Mold on ELF platforms (in this order).
This commit is contained in:
parent
07039af982
commit
dac443fbff
6 changed files with 46 additions and 23 deletions
|
@ -4,7 +4,19 @@ add_compile_options(-Wno-maybe-uninitialized)
|
|||
add_compile_options(-Wno-shorten-64-to-32)
|
||||
add_compile_options(-fsigned-char)
|
||||
add_compile_options(-g1)
|
||||
add_compile_options(-ggnu-pubnames)
|
||||
add_compile_options(-O2)
|
||||
if (NOT WIN32)
|
||||
add_compile_options(-fPIC)
|
||||
endif()
|
||||
|
||||
function(add_linker_flag_if_supported flag)
|
||||
include(CheckLinkerFlag)
|
||||
|
||||
check_linker_flag(CXX ${flag} LAGOM_LINKER_SUPPORTS_${flag})
|
||||
if (${LAGOM_LINKER_SUPPORTS_${flag}})
|
||||
add_link_options(${flag})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
add_linker_flag_if_supported(LINKER:--gdb-index)
|
||||
|
|
|
@ -12,6 +12,6 @@ serenity_option(ENABLE_FUZZERS_LIBFUZZER OFF CACHE BOOL "Build fuzzers using Cla
|
|||
serenity_option(ENABLE_FUZZERS_OSSFUZZ OFF CACHE BOOL "Build OSS-Fuzz compatible fuzzers")
|
||||
serenity_option(BUILD_LAGOM OFF CACHE BOOL "Build parts of the system targeting the host OS for fuzzing/testing")
|
||||
serenity_option(ENABLE_LAGOM_CCACHE ON CACHE BOOL "Enable ccache for Lagom builds")
|
||||
serenity_option(ENABLE_LAGOM_MOLD OFF CACHE BOOL "Enable mold for Lagom builds")
|
||||
serenity_option(ENABLE_LAGOM_LIBWEB ON CACHE BOOL "Enable compiling LibWeb for Lagom builds")
|
||||
serenity_option(ENABLE_LAGOM_LADYBIRD OFF CACHE BOOL "Enable compiling Ladybird from Lagom")
|
||||
serenity_option(LAGOM_USE_LINKER "" CACHE STRING "The linker to use (e.g. lld, mold) instead of the system default")
|
||||
|
|
26
Meta/CMake/use_linker.cmake
Normal file
26
Meta/CMake/use_linker.cmake
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
|
||||
# Copyright (c) 2023, Daniel Bertalan <dani@danielbertalan.dev>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
|
||||
if (NOT APPLE AND "${LAGOM_USE_LINKER}" STREQUAL "")
|
||||
find_program(LLD_LINKER NAMES "ld.lld")
|
||||
if (LLD_LINKER)
|
||||
message("Using LLD to link Lagom.")
|
||||
set(LAGOM_USE_LINKER "lld" CACHE STRING "")
|
||||
else()
|
||||
find_program(MOLD_LINKER NAMES "ld.mold")
|
||||
if (MOLD_LINKER)
|
||||
message("Using mold to link Lagom.")
|
||||
set(LAGOM_USE_LINKER "mold" CACHE STRING "")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT "${LAGOM_USE_LINKER}" STREQUAL "")
|
||||
set(LINKER_FLAG "-fuse-ld=${LAGOM_USE_LINKER}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAG}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAG}")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LINKER_FLAG}")
|
||||
endif()
|
Loading…
Add table
Add a link
Reference in a new issue