Hi, I think this patch will be appreciate by many.
Some parts are "cosmetics": - devel/cmake is BUILD_DEPENDS only when rustc is compiled with embedded-llvm: so move it inside PORTS_LLVM part (so I will remind to remove it when we will switch back to devel/llvm). - propagate the verbose flag to embedded-llvm build. And the last part is optimisation: it seems that Rust developpers like to control lot of parts of the build. They removed any optimisation flag (-O) from CFLAGS passed to compiler. So take back the control of them. It appeared that the llvm-embedded version was builded *without* any optimisation flag (no -O2) resulting a slow (well more exactly, a very slow) LLVM version. As rustc is linked statically with it, and use it for building any Rust program, the slowdown affected any build using rustc (build of rustc itself, build of cargo, build of others ports using rustc). Before: build time rustc approx 12h After: build time rustc approx 4h (the build of llvm-embedded is included) Thanks. -- Sebastien Marie Index: Makefile =================================================================== RCS file: /cvs/ports/lang/rust/Makefile,v retrieving revision 1.37 diff -u -p -r1.37 Makefile --- Makefile 15 Feb 2017 12:52:35 -0000 1.37 +++ Makefile 16 Feb 2017 16:38:14 -0000 @@ -8,6 +8,7 @@ COMMENT-doc = html documentation for ru V = 1.15.1 DISTNAME = rustc-${V}-src +REVISION = 0 # rustc bootstrap version RBV-amd64 = 1.15.0-20170203 @@ -65,7 +66,6 @@ PKG_ARGS += -Damd64=0 -Di386=1 MODULES += gcc4 \ lang/python -BUILD_DEPENDS += devel/cmake MODPY_RUNDEP = No # use embedded or ports version of LLVM @@ -73,7 +73,8 @@ PORTS_LLVM ?= No .if ${PORTS_LLVM:L:Myes} BUILD_DEPENDS += devel/llvm<4 .else -BUILD_DEPENDS += devel/ninja +BUILD_DEPENDS += devel/cmake \ + devel/ninja .endif # rustllvm need c++11 Index: patches/patch-src_bootstrap_lib_rs =================================================================== RCS file: patches/patch-src_bootstrap_lib_rs diff -N patches/patch-src_bootstrap_lib_rs --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_bootstrap_lib_rs 16 Feb 2017 16:38:14 -0000 @@ -0,0 +1,12 @@ +$OpenBSD$ +Let us compilation choice to be honored. +--- src/bootstrap/lib.rs.orig Thu Feb 16 12:26:21 2017 ++++ src/bootstrap/lib.rs Thu Feb 16 12:26:27 2017 +@@ -791,7 +791,6 @@ impl Build { + // gcc-rs because the build scripts will determine that for themselves. + let mut base = self.cc[target].0.args().iter() + .map(|s| s.to_string_lossy().into_owned()) +- .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")) + .collect::<Vec<_>>(); + + // If we're compiling on OSX then we add a few unconditional flags Index: patches/patch-src_bootstrap_native_rs =================================================================== RCS file: /cvs/ports/lang/rust/patches/patch-src_bootstrap_native_rs,v retrieving revision 1.1 diff -u -p -r1.1 patch-src_bootstrap_native_rs --- patches/patch-src_bootstrap_native_rs 15 Feb 2017 12:52:35 -0000 1.1 +++ patches/patch-src_bootstrap_native_rs 16 Feb 2017 16:38:14 -0000 @@ -1,8 +1,8 @@ $OpenBSD: patch-src_bootstrap_native_rs,v 1.1 2017/02/15 12:52:35 landry Exp $ use default settings from devel/llvm to local embedded version --- src/bootstrap/native.rs.orig Thu Feb 9 02:37:48 2017 -+++ src/bootstrap/native.rs Fri Feb 10 13:35:47 2017 -@@ -85,10 +85,10 @@ pub fn llvm(build: &Build, target: &str) { ++++ src/bootstrap/native.rs Thu Feb 16 12:22:02 2017 +@@ -85,16 +85,21 @@ pub fn llvm(build: &Build, target: &str) { .define("LLVM_INCLUDE_EXAMPLES", "OFF") .define("LLVM_INCLUDE_TESTS", "OFF") .define("LLVM_INCLUDE_DOCS", "OFF") @@ -16,3 +16,14 @@ use default settings from devel/llvm to .define("LLVM_PARALLEL_COMPILE_JOBS", build.jobs().to_string()) .define("LLVM_TARGET_ARCH", target.split('-').next().unwrap()) .define("LLVM_DEFAULT_TARGET_TRIPLE", target); + + if target.starts_with("i686") { + cfg.define("LLVM_BUILD_32_BITS", "ON"); ++ } ++ ++ // propagate verbose flag to llvm build ++ if build.flags.verbose { ++ cfg.define("CMAKE_VERBOSE_MAKEFILE", "ON"); + } + + // http://llvm.org/docs/HowToCrossCompileLLVM.html