aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Engberg <diizzy@FreeBSD.org>2023-01-07 19:08:44 +0000
committerDaniel Engberg <diizzy@FreeBSD.org>2023-01-07 19:22:36 +0000
commit967022fd812cf67dec264ee4e53bd016b69e7a2b (patch)
tree348ddac61682259240dfa111dae0e47abdbfe10a
parent0176fc46e96dd24f9c085b49b50eadf7ef2dc982 (diff)
downloadports-967022fd812cf67dec264ee4e53bd016b69e7a2b.tar.gz
ports-967022fd812cf67dec264ee4e53bd016b69e7a2b.zip
Mk/Uses/cargo.mk: Enable WITH_LTO by default
Ports utilizing Cargo will now enable Link Time Optimization (LTO), set error handling mechanism to abort and codegen-units to 1 by default. Exceptions are powerpc64 and riscv64 where LTO is known to be broken and disabled to avoid unnecessary breakage. Ports utilizing LTO will output "Additional optimization to port applied" during build. WITH_LTO is handled by Mk/Features/lto.mk and to disable define LTO_UNSAFE=yes. I'd also like to mention arrowd and tobik for helpful input and thanks to everyone involved. Reviewed by: mikael (via irc), pkubaj Tested by: eduardo (build) Approved by: rust (mikael, pkubaj) Differential Revision: https://reviews.freebsd.org/D36736
-rw-r--r--Mk/Uses/cargo.mk8
1 files changed, 8 insertions, 0 deletions
diff --git a/Mk/Uses/cargo.mk b/Mk/Uses/cargo.mk
index 5b6dfd268404..d3d7556c7630 100644
--- a/Mk/Uses/cargo.mk
+++ b/Mk/Uses/cargo.mk
@@ -139,6 +139,11 @@ CARGO_ENV+= \
CARGO_ENV+= RUST_BACKTRACE=1
. endif
+. if !defined(LTO_UNSAFE) || (defined(LTO_DISABLE_CHECK) && ${ARCH} == powerpc64) || (defined(LTO_DISABLE_CHECK) && ${ARCH} == riscv64)
+_CARGO_MSG= "===> Additional optimization to port applied"
+WITH_LTO= yes
+. endif
+
# Adjust -C target-cpu if -march/-mcpu is set by bsd.cpu.mk
. if ${ARCH} == amd64 || ${ARCH} == i386
RUSTFLAGS+= ${CFLAGS:M-march=*:S/-march=/-C target-cpu=/}
@@ -295,6 +300,9 @@ cargo-configure:
# Check that the running kernel has COMPAT_FREEBSD11 required by lang/rust post-ino64
@${SETENV} CC="${CC}" OPSYS="${OPSYS}" OSVERSION="${OSVERSION}" WRKDIR="${WRKDIR}" \
${SH} ${SCRIPTSDIR}/rust-compat11-canary.sh
+. if defined(_CARGO_MSG)
+ @${ECHO_MSG} ${_CARGO_MSG}
+. endif
@${ECHO_MSG} "===> Cargo config:"
@${MKDIR} ${WRKDIR}/.cargo
@: > ${WRKDIR}/.cargo/config.toml