From 63fb295ad8feba60af6dddebd470e022fefe7141 Mon Sep 17 00:00:00 2001 From: Qyriad Date: Fri, 19 Jun 2026 18:58:52 +0200 Subject: [PATCH] build: fix C++ dylibs on Musl by working around Nixpkgs brokenness Change-Id: Iad30ec38eef8205e2d73553caddbbbc96a6a6964 --- package.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/package.nix b/package.nix index 7ac9891ee..a9b5e251a 100644 --- a/package.nix +++ b/package.nix @@ -571,6 +571,17 @@ stdenv.mkDerivation (finalAttrs: { } // lib.optionalAttrs hostPlatform.isStatic { NIX_CFLAGS_COMPILE = " -static"; + } + // lib.optionalAttrs (hostPlatform.isStatic && stdenv.cc.libcxx == null) { + # pkgsStatic.clangStdenv.cc does not have the correct libstdc++. + # It's using pkgsStatic.buildPackages.gcc.cc, whose libstdc++ appears + # to have object files that were compiled with -fno-pic, + # (R_X86_64_32, R_X86_64_32S, and R_X86_64_TPOFF32 relocations). + # pkgsStatic.gcc.cc's libstdc++ has the correct relocations, but idk + # what the correct `wrapCCWith`/`stdenv.cc.override` incantation is. + # But just putting that libstdc++ in `-L` seems to make the driver find + # the right things. + NIX_CFLAGS_LINK = "-L${lib.makeLibraryPath [ pkgsStatic.gcc.cc ]}"; }; cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; };