🟡 nix/package.nix uses -Wl,-force_load for each grammar but may not link correctly on Linux #21

Open xenolandscapes.com
Open opened by xenolandscapes.com

Summary #

The linker flag -Wl,-force_load is macOS-specific; Linux should use --whole-archive wrapping.

The Problem #

In nix/package.nix line 49, parserStaticLibs uses -Wl,-force_load,${pkg}/lib/libparser.a for each grammar archive. This flag is only valid on macOS (ld64). On Linux, the equivalent is -Wl,--whole-archive ... -Wl,--no-whole-archive. Since the derivation sets platforms = platforms.darwin, this is not a runtime issue, but it limits portability. If a contributor tries to build on Linux, the link will fail.

Impact #

  • category: maintainability
  • description: -Wl,-force_load is macOS-specific; Linux builds need --whole-archive wrappers

Add a conditional: if stdenv.isDarwin, use -Wl,-force_load; if stdenv.isLinux, use -Wl,--whole-archive ... -Wl,--no-whole-archive. Or use Nixpkgs' linkFarm or lib.optionalString.


Commit range: 771c13a..771c13a
Code Review: CR-2026-07-27-11

Sign up or Sign in to add to the discussion.