From b2a5649290c80f28154909a8e3d49c14dddbf597 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Tue, 12 Dec 2023 15:06:46 +0100 Subject: [PATCH] chore(build): use mold linker instead of lld if available --- README.md | 2 +- debian/control | 14 +++++++------- justfile | 22 +++++++++++----------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index c3c47be..fab1809 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ To compile, a stable Rust compiler and [just](https://github.com/casey/just) are - cargo - just -- lld +- mold Some C libraries are also required for font support at the moment. diff --git a/debian/control b/debian/control index ce2372f..bfa23bb 100644 --- a/debian/control +++ b/debian/control @@ -4,18 +4,18 @@ Priority: optional Maintainer: Michael Murphy Build-Depends: debhelper-compat (=13), - just (>= 1.13.0), - rust-all, cmake, + just (>= 1.13.0), libexpat1-dev, libfontconfig-dev, libfreetype-dev, - lld, - libwayland-dev, - pkg-config, - libxkbcommon-dev, + libinput-dev, libudev-dev, - libinput-dev + libwayland-dev, + libxkbcommon-dev, + mold, + pkg-config, + rust-all, Standards-Version: 4.6.2 Homepage: https://github.com/pop-os/cosmic-settings diff --git a/justfile b/justfile index 27bda0d..a08e3cd 100644 --- a/justfile +++ b/justfile @@ -1,21 +1,21 @@ name := 'cosmic-settings' appid := 'com.system76.CosmicSettings' -# Use lld linker if available -ld-args := if `which lld || true` != '' { - '-C link-arg=-fuse-ld=lld -C link-arg=-Wl,--build-id=sha1' +# Use mold linker if clang and mold exists. +clang-path := `which clang || true` +mold-path := `which mold || true` + +linker-arg := if clang-path != '' { + if mold-path != '' { + '-C linker=' + clang-path + ' -C link-arg=--ld-path=' + mold-path + ' ' + } else { + '' + } } else { '' } -# Use the x86-64-v2 target by default on x86-64 systems. -target-cpu := if arch() == 'x86_64' { 'x86-64-v2' } else { '' } - -export RUSTFLAGS := if target-cpu != '' { - ld-args + ' -C target-cpu=' + target-cpu + ' ' + env_var_or_default('RUSTFLAGS', '') -} else { - ld-args + ' ' + env_var_or_default('RUSTFLAGS', '') -} +export RUSTFLAGS := linker-arg + env_var_or_default('RUSTFLAGS', '') rootdir := '' prefix := '/usr'