Skip to content

Build settings: experiments and policy ​

Current linker policy: lld with Nix runtime-path integration ​

Linux builds now default to lld for LDC and DMD. The earlier measurements and gold selection below are historical evidence, not the current default. Shared Phobos/druntime remains the test and ordinary benchmark policy; shipping and bench-static keep their existing runtime-linkage choices.

Raw pkgs.lld bypasses Nix's bintools wrapper. It links successfully but omits runtime search paths for store libraries passed with -L, so six of the ten app test executables fail dynamic-library resolution. For example, ci --help exits 127 because libtree-sitter.so.0.26 cannot be found.

pkgs.lld-sparkles (nix/d-toolchain.nix) is the fork LLVM's lld tool suite (including wasm-ld and lld-link) with only ld.lld behind the bintools wrapper. Development/CI shells, the CI runtime compiler environment, Nix DUB builders, and the wired benchmark wrapper use this package. The wrapper discovers runtime paths from linker inputs; no machine-specific store paths enter DUB manifests, and LD_LIBRARY_PATH is not the fix. Re-enter the development shell after updating: an already-open shell still has the old raw linker on PATH.

The fixed integration was replayed against all ten app test link commands, five times each. Every resulting executable resolves its libraries and starts with --help. A smaller regression probe exercises both LDC and DMD with shared Phobos/druntime and pkg-config's tree-sitter, removing LD_LIBRARY_PATH for library-resolution and execution checks:

bash
dmd apps/ci/tools/build-settings-bench.d -of=/tmp/opencode/linker-probe
/tmp/opencode/linker-probe --check-runtime-linker /tmp/opencode/linker-probe-output

The probe fails with raw lld and passes with wrapped lld. Wrapper overhead is included in real build latency: the earlier raw-lld times are not promises for the corrected configuration. The default change is an explicit policy choice, not a claim that wrapped lld beats gold on this toolchain. Calibration build types outside the managed block may still explicitly select gold.

All-app follow-up, shared Phobos/druntime, five links per condition; median whole-link milliseconds (compiler driver and wrapper included):

AppgoldRaw lldWrapped lld
ci437168 (missing libraries)725
diagram381132 (missing libraries)712
hue772224 (missing libraries)802
nix-eval11475 (missing libraries)647
release248100658
shader-compile20088644
terminal510166 (missing libraries)750
terminal-benchmark18585639
twoslash-extract396139699
ui-gallery385138 (missing libraries)728

These reuse the same selected-policy root objects and dependency archives. Conditions rotate order within each app; the wrapped-lld follow-up is a separate batch. The corrected linker is slower than gold in every row of this sample. This cost is accepted for the requested lld default, not hidden behind raw-linker numbers. No application-runtime improvement is established by these link tests.

The shipping-mode hue build also links successfully with the new default. Its UI-event safety-inference diagnostic also appears in the pre-lld build; both builds finish successfully. The optimized standalone wired benchmark build passes its 16 ordinary tests with lld as well. The repository-wide no-coverage suite passes 58/58 packages with wrapped lld. The sandboxed nix build .#ci --no-link also succeeds, and the packaged CI executable starts with --help.

Original build-setting experiments ​

All-app extension of the original comparison ​

All ten apps/ packages listed by the root manifest completed three paired forced graph replays, comparing f71a5bffe with 2f6d74c26. This compares the original settings migration, before the subsequent wrapped-lld default. The selected side here uses gold, not the current lld policy. Every capture and replay succeeded. These are app test builds, not shipping GUI builds.

Seconds, medians of three invocations per configuration:

AppRoot compile, before → afterDependencies, before → afterLink, before → afterTotal, before → afterReduction
ci20.968 → 18.29144.749 → 40.8102.185 → 0.53867.867 → 59.52212.3%
diagram7.851 → 7.23850.141 → 41.1020.737 → 0.46258.695 → 48.84216.8%
hue27.719 → 25.29180.017 → 67.8431.443 → 1.014109.184 → 94.16313.8%
nix-eval1.039 → 0.90529.892 → 27.1070.477 → 0.11831.402 → 28.13810.4%
release5.435 → 4.92147.417 → 38.6331.218 → 0.29954.144 → 43.77219.2%
shader-compile2.931 → 2.68536.767 → 28.7591.055 → 0.23940.774 → 31.68022.3%
terminal24.111 → 20.25166.890 → 56.6600.978 → 0.65492.101 → 77.55715.8%
terminal-benchmark0.489 → 0.45441.713 → 33.6190.319 → 0.21642.547 → 34.29719.4%
twoslash-extract4.735 → 4.48666.667 → 55.6690.787 → 0.50072.187 → 60.56316.1%
ui-gallery10.563 → 9.70949.114 → 40.3690.754 → 0.49660.437 → 50.56616.3%

Totals are medians of each invocation's compile-plus-link sum, not sums of the independent column medians. Dependency compilation excludes root compilation but includes compiler-driven archive production. Warm filesystem caches, DUB setup exclusion, and suite-runtime exclusion match the original protocol. Apps run serially; no aggregate whole-monorepo speedup is inferred by summing their repeated dependency work. Runtime performance is not measured by this run.

The complete 60 samples, including per-command durations, are retained in the app results. The checkpointed driver is apps/ci/tools/compare-app-builds.d; it discovers apps from the root manifest, captures each worktree separately, and passes each capture's working directory to the replay harness. Build it and reproduce the summary with:

bash
dmd apps/ci/tools/compare-app-builds.d -of=/tmp/opencode/compare-app-builds
/tmp/opencode/compare-app-builds BASELINE_WORKTREE SELECTED_WORKTREE \
  /tmp/opencode/build-settings-bench /tmp/opencode/app-study 3
/tmp/opencode/compare-app-builds --summarize /tmp/opencode/app-study

Measured: October 21–22, 2026. Baseline: f71a5bffe.

Forced compilation of versions and its 13 dependency archives falls from 39.97 s to 32.31 s (19.2%), with suite execution and DUB setup excluded. The selected test policy reduces a warm wired root rebuild from 23.89 s to 20.12 s (15.8%), and versions from 3.83 s to 3.58 s (6.5%). These totals include compilation and linking, not test execution or DUB setup. Full debug information remains available through -b unittest-debug.

Root totals above are sums of the separately measured compile/link medians; individual paired samples are retained in the results JSON.

The apparent fastest linker is not the fastest working project-wide default: raw lld omits Nix runtime search paths, and wrapped lld is slower than gold. Blanket single-object compilation and static-runtime/linker changes also regress a real JSON workload. Defaults retain gold + shared Phobos/druntime; benchmarks select -O3 and native CPU targeting. Static runtime is an explicit alternative, not a universal speed improvement.

Questions and experiment plan ​

This investigation separates three objectives: compile/link latency for dub test, throughput of optimized benchmarks, and consistent settings in standalone and monorepo DUB recipes. Test-suite execution is not a build-time metric.

The starting evidence is the compiler/linker investigation in ndslice-vs-hand-written-c-gist/REPORT-FULL.md, sections 9 and “Build configurations”. Its results are hypotheses, not Sparkles measurements:

  • Compare ordinary template emission with LDC's linkonce-templates, singleobj, and removal of allinst or debug information.
  • Compare bfd, gold, lld, mold and Wild on the same precompiled objects, with shared and static Phobos/druntime. Static here does not mean static libc.
  • Compare benchmark runtime with static/shared runtime, bounds checks, generic/native CPU targeting, optimization levels and ThinLTO.
  • Preserve debug-mode checks and assertions in normal tests, and assertion-enabled checked shipping builds. Treat benchmark builds as a separate policy.
  • Apply only measured, working choices. Record failures rather than omitting them.

Protocol and environment ​

The harness captures actual compiler and linker commands from a successful dub test --force --verbose -- --help. It replays the root compilation and link separately, outside DUB and without executing the suite. Dependencies and filesystem caches are warm. These are root rebuild measurements, not clean dependency builds or no-op DUB invocations. Each experiment writes its command, exit status and output; failed commands are not timing wins.

The separate graph-replay mode additionally recompiles every captured dependency archive before the root and final link. It retains compiler-invoked archiving inside the compilation sum, but excludes DUB setup, package downloads and suite execution. It is still a warm-filesystem experiment, not a cold-cache benchmark.

Variants rotate order between rounds. Runtime measurements use the project's benchmark runner, separate process invocations pinned to CPU 4, and retain machine-readable output. Build commands are not CPU-pinned: their normal compiler and linker parallelism is part of the measured configuration. No other study build or benchmark runs concurrently.

ComponentMeasured environment
HostAMD Ryzen 9 7940HX, 16 cores / 32 logical CPUs, 64 MiB L3
OSLinux x86-64, Nix development toolchain
LDC1.42.0, DMD frontend 2.112.1, LLVM 18.1.8
DUBInstalled executable reports 1.42.0-beta.1
LinkersGNU gold/bfd, lld 21.1.8, mold 2.42.0, Wild 0.7.0
CPU controlsRuntime pinned to CPU 4; boost remains enabled
SamplingThree compilation rounds; five native links; five paired final runtime invocations

The 32 samples inside a benchmark invocation are not counted as 32 independent process invocations. Runtime tables summarize per-invocation medians; overlapping spreads are not advertised as reliable small wins. The machine was not an isolated performance lab: warm caches and paired controls reduce noise, but do not establish cold-cache, other-machine or other-compiler results.

Build-time results ​

Initial debug-build screening ​

versions, three warm root rebuilds per condition; medians in milliseconds:

Root compile settingCompileLink
Existing settings3549277
Remove inherited linkonce-templates3567283
Add singleobj3599279
Remove allinst3549274
Remove full debug information3126267

The template-emission change is not the 4× win from the input report: these are unoptimized test builds, not optimized ndslice instantiations. Dropping debug information is faster, but loses diagnostics; it is a screening result, not sufficient evidence to change the default.

The larger wired root gives the following medians (three builds each):

Root compile settingCompile (ms)Link (ms)
Existing settings23436456
Remove inherited linkonce-templates26127565
Add singleobj23550446
Remove allinst23524449
Remove full debug information17214370
Line-table-only debug information20079394

linkonce-templates is worth about 10% on this root, and line tables save about 14% of compilation versus full debug information. These gains do not include any change in suite execution time.

Linker and runtime-library matrix ​

Same wired object and dependency archives, five links per condition; median whole-link wall time in milliseconds:

LinkerShared Phobos/druntimeStatic Phobos/druntime
bfd14631854
gold386459
lld151174
mold10721382
Wild 0.7715719

These numbers include LDC, the C driver and Nix wrappers, not just the linker algorithm. The executable's .comment section confirms lld/mold/Wild identity; ldd confirms the requested shared/static default-runtime selection. This machine's real project link is unlike the tiny link in the input report: Wild does not win here. Both versions and wrapper costs matter.

A follow-up varied native linker thread counts (five links each). lld with one thread took 190 ms and four threads 152 ms; mold took 835/843 ms; Wild took 724/706 ms. No thread-count override improves on lld's ordinary invocation, so none belongs in the default policy.

Integration reverses the provisional lld choice. The raw lld binary does not perform the Nix wrapper's runtime-path discovery: the ci test executable linked, then failed to load libtree-sitter.so.0.26. A follow-up using the pinned llvmPackages.bintools wrapper produced runnable linkage but took 705 ms (five links: 713, 705, 694, 702, 707), versus gold's 386 ms on the same large object. Thus the raw 151 ms result is not the project-wide winner. This is the same class of driver/wrapper measurement trap highlighted in the input report. The final default stays gold rather than adding a slower wrapper or manually hard-coding every external library's runtime path.

Selected default test build ​

RootBaseline compile + link (ms)Selected compile + link (ms)Reduction
versions3549 + 2773367 + 2106.5%
wired23436 + 45619740 + 37615.8%

The selected build retains debugMode, unittests, assertions and the existing package-specific assertion/instantiation settings. LDC uses line tables rather than full variable/type debug information. A separate exception probe confirms that the caller frame, not just the exception's own source location, retains its file and line. Full debugger locals/types require unittest-debug.

Forced dependency-graph rebuild ​

The versions graph includes 13 dependency archives, the root compilation and the final link. Three paired rounds alternate baseline/selected order. Every compiler command runs again: this is not a no-op cache hit or just root editing. Source/filesystem caches remain warm.

PhaseBaseline median (s)Selected median (s)
All compilation, including archive production39.97332.312
Final link0.3410.239
Per-round compile + link total40.31432.558

The compilation reduction is 19.2%; total compile/link latency improves 19.2%. All six final graph replays succeed. Representative compilation components:

ComponentBaseline (s)Selected (s)
base library9.6398.555
wired library4.2013.907
ui library9.7178.795
Runner implementation10.4595.342
versions root3.6063.379

The runner comparison changes scoped single-object codegen and debug information together; it does not separate their contributions. The whole-graph improvement should not be attributed to a single template flag: the existing root already inherited linkonce behavior.

Benchmark-runtime results ​

One-variable CSV screening ​

Root-only flag screening, dependencies fixed. Three invocations, each with 32 samples; times are medians of invocation medians in microseconds:

VariantParse 1k rowsParse 10k rowsSniff 100 rowsCompile / link (ms)
Existing native -O3, shared runtime45.33452.8835.744901 / 136
Static runtime45.32447.8935.615025 / 201
Bounds checks off45.26452.8235.005269 / 135
Generic CPU52.31509.8441.704844 / 131
-O250.92511.9939.584825 / 136
Assertions enabled49.64495.3739.084939 / 132
Root ThinLTO + lld66.80630.5550.723854 / 975

Native targeting and -O3 materially beat their alternatives on these workloads. Assertion-enabled measurements remain available, but are a different policy. Bounds-check removal does not establish a useful win, so it is not selected. ThinLTO here is a root-bitcode/native-dependency experiment, not whole-program LTO; it does not reproduce the input report's link failure, but its runtime is worse. No claim about fully rebuilt whole-program LTO follows from this result.

Removing linkonce-templates from the root alone compiled in 6341 ms but failed all three links, with missing Buffer, allocator and Nullable instantiations. It is a rejected mixed-emission configuration, not evidence that every consistent non-linkonce build must fail. No runtime number is assigned to it.

Whole-build candidates: the regression that changed the choice ​

All benchmark binaries use identical sources and input datasets. Five paired process invocations, 32 samples per invocation, CPU 4; no build runs concurrently. std.json is a useful second implementation because it exercises Phobos code and allocation behavior beyond wired's hot loops.

Candidate, std.json / canada serializeBaseline (ms)Candidate (ms)Decision
Blanket singleobj, static runtime, lld20.7625.26Reject: ~22% slower
Same compiler policy, shared runtime, lld20.7430.49Reject: shared runtime alone does not fix it
Package-scoped emission, static runtime, gold21.1024.99Reject as default: ~18% slower
Package-scoped emission, shared runtime, gold20.8921.08Retain: invocation spreads overlap

The last candidate is the selected performance-first bench-unchecked policy. Some representative rows from its paired comparison:

Engine / dataset / operationBaseline (µs)Selected (µs)
wired-native / twitter / parse170.57170.00
wired-native / twitter / serialize399.06399.15
wired-native / canada / parse1434.801429.59
wired-native / canada / serialize2581.032586.97
std.json / twitter / parse4130.134165.49
std.json / canada / parse28410.1028579.60

These are performance preserved, not a claimed sub-percent speedup. The static alternative improved std.json's canada parse (28.76 → 25.50 ms), but lost on serialization. That is why bench-static is available for explicitly measured workloads rather than imposed on every benchmark.

A final rebuild of the accepted CSV policy also preserves performance (five paired invocations; microseconds):

CSV workloadBaselineAccepted
Parse 1k rows46.6444.58
Parse 10k rows451.84448.27
Sniff 100 rows35.7635.57

Invocation spreads overlap; these small differences are not the basis for a universal runtime-speedup claim.

With ordinary multi-object libraries, lld also exposed duplicate strong nested UI helpers (dtcg.colorValue.comp) that gold did not pull into this executable. Changing archive extraction/linker semantics and blanket object granularity is not an innocent latency-only change. The runner's known nested-helper workaround is scoped to the runner implementation, not every dependency. No assertion or UI algorithm was rewritten to make a particular linker win.

Selected settings and exceptions ​

All 150 tracked dub.sdl files contain the same generated build-type block, including standalone benchmarks, bindings, research examples and the root recipe. DUB resolves custom build types from the selected root, so defining them only in the monorepo root would not standardize standalone invocations.

Build typePurpose / policy
unittestOrdinary dub test: debug checks, assertions, LDC line tables; existing package template policies; Linux shared runtime + gold
unittest-debugSame test policy with full debug information
unittest-cov, unittest-cov-ctfeSame test/link policy while preserving DUB's ordinary/CTFE coverage options
checkedShipping: optimized, inlined, debug information, assertions live; no native CPU requirement
benchOptimized measurement with ordinary-function assertions retained; required for assertion-dependent workloads
bench-uncheckedPerformance-first measurement: unittests + release-mode optimization, LDC native -O3; Linux shared runtime + gold
bench-staticPerformance-first benchmark variant with static Phobos/druntime; measure before choosing it

Important boundaries:

  • Tests and shipping are not release builds. bench-unchecked and bench-static can remove assertions in ordinary functions; it is not a correctness gate or a deployment artifact.
  • Assertion-dependent setup remains supported. The fuzzy benchmark's setup and timed closures contain required calls inside assertions. bench therefore retains assertions; bench-unchecked is explicit rather than silently breaking those workloads. The wired Nix wrapper selects bench-unchecked, preserving its existing measurement protocol. Experiments originally captured with the old assertion-disabled bench name use the same flags as this new type.
  • DMD keeps shared Phobos + gold on Linux. An attempted lld switch built versions, but its executable could not locate libphobos2.so.0.112. Keeping gold preserves the Nix wrapper's working runtime-library search behavior. DMD does not receive LDC-only flags or line-table defaults.
  • Custom calibration types remain explicit exceptions. bench-plain in the event-loop suite and unittest-checked in the formatter retain their original optimization policy and shared/gold linkage. The conformance application's offline configuration keeps its DMD-specific link settings.
  • Retain package-specific template-emission settings. An attempted blanket unittest linkonce-templates policy crashed LDC compiling mir-ion with Type Expression not implemented: __error. Removing that blanket flag made the standalone wired debug build/list work. The final common unittest policy changes debug-information generation, not every dependency's template linkage. base and event-horizon-sys already enable linkonce; wired's library-inline retains its measured CMI/linkonce pairing. They are explicit compatibility/codegen exceptions, not silently erased to imitate the input report. Benchmarks here are not claimed to be linkonce-free.
  • Keep CMI scoped. Do not propagate it through benchmark build types to mir-ion; the existing wired recipe documents that frontend incompatibility.
  • allinst/context-assert configuration exceptions remain local. In particular, the DMD-frontend family deliberately omits flags that break its dependency build. The common unittest build type does not force them globally.
  • Linux linker switches are compiler/OS gated. Other platforms retain their native linkers; those platforms were not benchmarked here.
  • Inline single-file recipes are outside the requested dub.sdl migration. Their existing checked shipping declaration remains unchanged.

Reproduction and limitations ​

Correctness validation ​

CheckResult
Repository suite, ci test --no-coverage --fail-fast58/58 packages passed
versions with DMD, including DMD-selected probes167 passed
versions with unittest-debug167 passed
versions with ordinary coverage167 passed
Assertion-dependent fuzzy bench setup and timed casesAll five cases completed without row errors
Original nix run .#wired-bench -- --light --list-datasetsAll ten light datasets listed
Standalone wired debug build/list, including mir-ionBuilt and listed tests after removing blanket template linkage
Line-table exception probeCaller function, file and line retained
Shipping-mode CI helper, dub build :ci -b checkedBuilt successfully

The compiler-compatibility, coverage and fuzzy checks used isolated temporary build outputs. Their execution times are correctness evidence, not part of the build-time or performance-selection tables.

Repeating the measurements ​

The canonical source is standardize-build-settings.d. Regeneration is idempotent and has unit tests. --check reports drift without editing package-specific settings:

bash
dub run --single apps/ci/tools/standardize-build-settings.d -- --check

The measurement tool is build-settings-bench.d. Compile it once outside measured intervals, then capture and replay from the same working directory, in the same Nix development shell. Use fresh output directories so appended samples are not mixed:

bash
dmd apps/ci/tools/build-settings-bench.d -of=/tmp/opencode/build-settings-bench
dub test :wired --force --verbose -- --help > /tmp/opencode/wired-capture.txt 2>&1
/tmp/opencode/build-settings-bench /tmp/opencode/wired-capture.txt /tmp/opencode/wired-compile compile 3
/tmp/opencode/build-settings-bench /tmp/opencode/wired-capture.txt /tmp/opencode/wired-link link 5
/tmp/opencode/build-settings-bench --check-debug-info /tmp/opencode/debug-probe

To compare forced dependency rebuilds, capture both configurations using --force --verbose, then replay the full graphs in alternating order:

bash
/tmp/opencode/build-settings-bench --compare-graph BASELINE_CAPTURE SELECTED_CAPTURE \
  /tmp/opencode/graph-comparison 3

Graph mode writes the captured DUB cache paths. Run it only after other builds have stopped; do not race it against builds using those caches.

For Wild, set BUILD_STUDY_WILD_DIR to a directory containing an ld symlink to the chosen Wild executable. The harness uses the C driver's -B option; not every GCC version accepts -fuse-ld=wild. It records executable linker identity with readelf and runtime dependencies with ldd.

For one-variable optimized screening, capture a successful -b bench-unchecked build and use the harness's bench mode. For final whole-build comparisons, preserve each executable after rebuilding its entire dependency configuration, then alternate runs:

bash
WIRED_BENCH_DATASETS=twitter,canada WIRED_BENCH_ENGINES=wired-native,std.json \
  /tmp/opencode/build-settings-bench --compare /tmp/opencode/wired-pair BASELINE SELECTED 5 \
  --bench --bench-min-time=10

Retained build samples and per-invocation benchmark rows are in build-settings-results.json. Groups ending final, final-shared, and gold-static include rejected candidates; wired-gold-shared is the accepted JSON comparison. versions-graph-final and groups ending accepted-final contain the final test-build measurements; dsv-accepted contains the accepted CSV measurements. Earlier accepted and versions-graph groups precede the final template-scope compatibility correction. The original experiment directory also retains each compiler/linker command, diagnostic, .comment, ldd output and complete runner report. Timed @workload windows incidentally executed by the CSV module were not used to select flags.

Limits: no cold filesystem/package-download or whole-monorepo clean-build claims, no test-suite-runtime optimization, no cross-platform measurements, no fully static libc experiment, and no exhaustive whole-program LTO/PGO search. “Best” means the fastest working measured policy at the stated objective, not proof of a global optimum for every workload or machine. Rebaseline published benchmark numbers after changing build policy.

Primary sources ​

The DUB source above is release 1.42.0, a close-version reference rather than a claim to be the exact source of the installed beta executable. Experimental commands use the installed binaries and validate actual behavior.