Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable cross-lang-fat-lto on Linux #817

Merged
merged 12 commits into from
Feb 19, 2023
1 change: 1 addition & 0 deletions crates/bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ native-tls = ["binstalk/native-tls"]
trust-dns = ["binstalk/trust-dns"]

zstd-thin = ["binstalk/zstd-thin"]
cross-lang-fat-lto = ["binstalk/cross-lang-fat-lto"]

fancy-no-backtrace = ["miette/fancy-no-backtrace"]
fancy-with-backtrace = ["fancy-no-backtrace", "miette/fancy"]
Expand Down
2 changes: 2 additions & 0 deletions crates/binstalk-downloader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ native-tls = ["reqwest/native-tls", "trust-dns-resolver?/dns-over-native-tls"]
trust-dns = ["trust-dns-resolver", "reqwest/trust-dns"]

zstd-thin = ["zstd/thin"]

cross-lang-fat-lto = ["zstd/fat-lto"]
1 change: 1 addition & 0 deletions crates/binstalk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ native-tls = ["binstalk-downloader/native-tls"]
trust-dns = ["binstalk-downloader/trust-dns"]

zstd-thin = ["binstalk-downloader/zstd-thin"]
cross-lang-fat-lto = ["binstalk-downloader/cross-lang-fat-lto"]
25 changes: 22 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ support-pkg-config := if target == target-host {

cargo-features := trim_end_match(if override-features != "" { override-features
} else if (cargo-profile / ci-or-no) == "dev/ci" { "rustls,fancy-with-backtrace,zstd-thin,log_release_max_level_debug" + (if support-pkg-config != "" { ",pkg-config" } else { "" }) + extra-features
} else if (cargo-profile / ci-or-no) == "release/ci" { "static,rustls,trust-dns,fancy-no-backtrace,zstd-thin,log_release_max_level_debug" + extra-features
} else if (cargo-profile / ci-or-no) == "release/ci" { "static,rustls,trust-dns,fancy-no-backtrace,zstd-thin,log_release_max_level_debug" + (if target-os != "macos" { ",cross-lang-fat-lto" } else { "" }) + extra-features
} else { extra-features
}, ",")

Expand All @@ -92,14 +92,33 @@ rustc-miropt := if for-release != "" { " -Z mir-opt-level=4" } else { "" }
# 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 { "" }
#
# If cargo-zigbuild is used, then it will provide the lld linker.
# This option is disabled on windows since it not supported.
rust-lld := if use-cargo-zigbuild != "" {
""
} else if target-os != "windows" {
" -Z gcc-ld=lld"
} else {
""
}

# ICF: link-time identical code folding
#
# 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 { "" }

# Only enable linker-plugin-lto for release
# Also disable this on windows since it uses msvc.
linker-plugin-lto := if for-release == "" {
""
} else if target-os == "linux" {
"-C linker-plugin-lto "
} else {
""
}

target-glibc-ver-postfix := if glibc-version != "" {
if use-cargo-zigbuild != "" {
"." + glibc-version
Expand All @@ -111,7 +130,7 @@ target-glibc-ver-postfix := if glibc-version != "" {
}

cargo-build-args := (if for-release != "" { " --release" } else { "" }) + (" --target ") + (target) + (target-glibc-ver-postfix) + (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 := "-Z share-generics " + (rustc-gcclibs) + (rustc-miropt) + (rust-lld) + (rustc-icf)
export RUSTFLAGS := "-Z share-generics " + (linker-plugin-lto) + (rustc-gcclibs) + (rustc-miropt) + (rust-lld) + (rustc-icf)


# libblocksruntime-dev provides compiler-rt
Expand Down