This might increase build and lto times a bit,
but may result in faster and better optimized result.
It also honors resource limits properly.

Signed-off-by: Georgy Yakovlev <gyakov...@gentoo.org>
---
 eclass/cargo.eclass | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index a7c7bffd3c0c..00b8078f80ea 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -279,6 +279,11 @@ cargo_gen_config() {
        $(usex debug 'opt-level = 0' '')
        $(usex debug 'lto = false' '')
 
+       # 
https://doc.rust-lang.org/rustc/codegen-options/index.html#codegen-units
+       # We use single codegen unit for most optimized code and to honor -j 
from MAKEOPTS.
+       # Users can override via e.g. CARGO_PROFILE_gentoo_CODEGEN_UNITS="16" 
in make.conf.
+       codegen-units = 1
+
        [build]
        jobs = $(makeopts_jobs)
        incremental = false
-- 
2.39.1


Reply via email to