diff --git a/Mk/Features/lto.mk b/Mk/Features/lto.mk index 9d38448f312c..75935b52ca89 100644 --- a/Mk/Features/lto.mk +++ b/Mk/Features/lto.mk @@ -1,17 +1,25 @@ # LTO Support # # This file enforces Link Time Optimization for ports. # In order to use it, add WITH_LTO=yes to your /etc/make.conf. .if !defined(_LTO_MK_INCLUDED) _LTO_MK_INCLUDED= yes LTO_Include_MAINTAINER= pkubaj@FreeBSD.org . if !defined(LTO_UNSAFE) +. if defined(_INCLUDE_USES_CARGO_MK) + CARGO_ENV+= CARGO_PROFILE_RELEASE_LTO="true" \ + CARGO_PROFILE_RELEASE_PANIC="abort" \ + CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 +. elif defined(_INCLUDE_USES_MESON_MK) + MESON_ARGS+= -Db_lto=true +. else # Overridable as a user may want to use -flto -LTO_FLAGS?= -flto=thin -CFLAGS+= ${LTO_FLAGS} -CXXFLAGS+= ${LTO_FLAGS} -LDFLAGS+= ${LTO_FLAGS} + LTO_FLAGS?= -flto=thin + CFLAGS+= ${LTO_FLAGS} + CXXFLAGS+= ${LTO_FLAGS} + LDFLAGS+= ${LTO_FLAGS} +. endif . endif .endif