Skip to content

Commit

Permalink
fix(scripts): search for a proper lld version
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed Dec 13, 2024
1 parent ebb13e2 commit a650b5e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion scripts/build-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
13 changes: 12 additions & 1 deletion scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 4 additions & 9 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a650b5e

Please # to comment.