mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:17: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
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