Skip to content

Commit

Permalink
Use lld when building with mzcompose on macOS
Browse files Browse the repository at this point in the history
Incremental compile time for bin/mzcompose improves from 6min28s to 13s on my system by using lld.
  • Loading branch information
def- committed Dec 11, 2024
1 parent 92acf23 commit ddf6cf6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions misc/python/materialize/xcompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit ddf6cf6

Please sign in to comment.