1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +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:
Daniel Bertalan 2023-09-05 07:40:57 +02:00 committed by Andreas Kling
parent 07039af982
commit dac443fbff
6 changed files with 46 additions and 23 deletions

View 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()