From ddf6cf6b3c34813bf4652ca9cb50bfab72a45519 Mon Sep 17 00:00:00 2001 From: Dennis Felsing Date: Wed, 11 Dec 2024 09:21:43 -0500 Subject: [PATCH] Use lld when building with mzcompose on macOS Incremental compile time for bin/mzcompose improves from 6min28s to 13s on my system by using lld. --- misc/python/materialize/xcompile.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/misc/python/materialize/xcompile.py b/misc/python/materialize/xcompile.py index 2ceb0493f5425..da438cee400bd 100644 --- a/misc/python/materialize/xcompile.py +++ b/misc/python/materialize/xcompile.py @@ -158,8 +158,13 @@ def cargo( if sys.platform == "darwin": _bootstrap_darwin(arch) + homebrew_prefix = spawn.capture(["brew", "--prefix"]) sysroot = spawn.capture([f"{_target}-cc", "-print-sysroot"]).strip() - rustflags += [f"-L{sysroot}/lib"] + rustflags += [ + f"-L{sysroot}/lib", + "-Clink-arg=-fuse-ld=lld", + f"-Clink-arg=-B{homebrew_prefix}/bin", + ] env.update( { "CMAKE_SYSTEM_NAME": "Linux", @@ -242,7 +247,7 @@ def _bootstrap_darwin(arch: Arch) -> None: # Building in Docker for Mac is painfully slow, so we install a # cross-compiling toolchain on the host and use that instead. - BOOTSTRAP_VERSION = "4" + BOOTSTRAP_VERSION = "5" BOOTSTRAP_FILE = MZ_ROOT / "target-xcompile" / target(arch) / ".xcompile-bootstrap" try: contents = BOOTSTRAP_FILE.read_text() @@ -251,7 +256,7 @@ def _bootstrap_darwin(arch: Arch) -> None: if contents == BOOTSTRAP_VERSION: return - spawn.runv(["brew", "install", f"materializeinc/crosstools/{target(arch)}"]) + spawn.runv(["brew", "install", "lld", f"materializeinc/crosstools/{target(arch)}"]) spawn.runv(["rustup", "target", "add", target(arch)]) BOOTSTRAP_FILE.parent.mkdir(parents=True, exist_ok=True)