From a650b5e7a9ed0e792b515dbcbe6569fbe3c6ad90 Mon Sep 17 00:00:00 2001 From: Ivan Kalinin Date: Fri, 13 Dec 2024 15:10:27 +0100 Subject: [PATCH] fix(scripts): search for a proper `lld` version --- scripts/build-node.sh | 2 +- scripts/common.sh | 13 ++++++++++++- scripts/install.sh | 13 ++++--------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/scripts/build-node.sh b/scripts/build-node.sh index bf0e85398..47ba66588 100755 --- a/scripts/build-node.sh +++ b/scripts/build-node.sh @@ -14,7 +14,7 @@ else profile="${TYCHO_BUILD_PROFILE}" fi -set_clang_env 19 18 +set_clang_env 19 cargo build --bin tycho $profile_arg echo "${root_dir}/target/${profile}/tycho" diff --git a/scripts/common.sh b/scripts/common.sh index 056fee6f5..e42ed1c2a 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -36,9 +36,20 @@ function set_clang_env { local cc_path=$(command -v "clang-$clang_version" 2>&1 || true) local cxx_path=$(command -v "clang++-$clang_version" 2>&1 || true) - if [ ! -z "$cc_path" ] && [ ! -z "$cxx_path" ]; then + local lld_bin="" + if command -v "ld.lld-$clang_version" 2>&1 >/dev/null; then + lld_bin="lld-$clang_version" + elif command -v "ld.lld" 2>&1 >/dev/null; then + local lld_version=$(ld.lld -V | awk '{print $2}' | cut -d '.' -f 1) + if [ "$lld_version" == "$clang_version" ]; then + lld_bin="lld" + fi + fi + + if [ ! -z "$cc_path" ] && [ ! -z "$cxx_path" ] && [ ! -z "$lld_bin" ]; then export CC="$cc_path" export CXX="$cxx_path" + export LD="$lld_bin" return 0 else prev_version="$clang_version" diff --git a/scripts/install.sh b/scripts/install.sh index a9ec5b740..71a7097cc 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -21,18 +21,13 @@ EOF fi features="" -if set_clang_env 19 18; then - if ! command -v cargo 2>&1 >/dev/null; then - echo "ERROR: \`lld\` could not be found." - exit 1 - fi - - features="--features lto" +if set_clang_env 19; then + features="$features --features lto" echo "INFO: Building node with lto" - export RUSTFLAGS="-Clinker-plugin-lto -Clinker=clang -Clink-arg=-fuse-ld=lld" + export RUSTFLAGS="-Clinker-plugin-lto -Clinker=clang -Clink-arg=-fuse-ld=$LD" fi -cargo install --path ./cli --locked $features +cargo install $features --path ./cli --locked cat << EOF Node installed successfully. Run the following to configure it: