Skip to content

Commit

Permalink
Enable icf=safe & use rust-lld for targets other than win (#805)
Browse files Browse the repository at this point in the history
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu authored Feb 15, 2023
1 parent 89b920a commit 9c6ab59
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,24 @@ win-arm64-ring16 := if target == "aarch64-pc-windows-msvc" { " --config='patch.c
# MIR optimisation level (defaults to 2, bring it up to 4 for release builds)
rustc-miropt := if for-release != "" { " -Z mir-opt-level=4" } else { "" }

# Use rust-lld that is bundled with rustup to speedup linking
# and support for icf=safe.
#
# -Zgcc-ld=lld uses the rust-lld that is bundled with rustup.
#
# TODO: There is ongoing effort to stabilise this and we will need to update
# this once it is merged.
# https://github.com/rust-lang/compiler-team/issues/510
rust-lld := if target-os != "windows" { " -Z gcc-ld=lld" } else { "" }

# ICF: link-time identical code folding
# disabled for now, as it requires the gold linker
rustc-icf := "" #if for-release != "" { " -C link-arg=-Wl,--icf=all" } else { "" }
#
# On windows it works out of the box and on other targets it uses
# rust-lld.
rustc-icf := if for-release != "" { " -C link-arg=-Wl,--icf=safe" } else { "" }

cargo-build-args := (if for-release != "" { " --release" } else { "" }) + (if target != target-host { " --target " + target } else if cargo-buildstd != "" { " --target " + target } else { "" }) + (cargo-buildstd) + (if extra-build-args != "" { " " + extra-build-args } else { "" }) + (cargo-no-default-features) + (cargo-split-debuginfo) + (if cargo-features != "" { " --features " + cargo-features } else { "" }) + (win-arm64-ring16)
export RUSTFLAGS := (rustc-gcclibs) + (rustc-miropt) + (rustc-icf)
export RUSTFLAGS := (rustc-gcclibs) + (rustc-miropt) + (rust-lld) + (rustc-icf)


# libblocksruntime-dev provides compiler-rt
Expand Down

0 comments on commit 9c6ab59

Please sign in to comment.