From 76377a00a6bf330d07f6949dddcfae1fb1f8ca88 Mon Sep 17 00:00:00 2001 From: centdix <40307056+centdix@users.noreply.github.com> Date: Mon, 9 Feb 2026 15:03:22 +0100 Subject: [PATCH] internal: flake nix devshell clang/mold/openssl compatibility (#7855) * fix: flake nix devshell clang/mold/openssl compatibility - Add mold linker to buildInputs - Pin cargo linker to clang 18 (stdenv's clang 21 causes SIGSEGV with mold) - Embed OpenSSL rpath via rustflags instead of LD_LIBRARY_PATH to avoid leaking into git/ssh Co-Authored-By: Claude Opus 4.6 * more fixes * fix --------- Co-authored-by: Claude Opus 4.6 --- flake.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 75bf82de8c..211c281e86 100644 --- a/flake.nix +++ b/flake.nix @@ -55,8 +55,11 @@ nodejs postgresql pkg-config - clang + llvmPackages_18.clang + mold cmake + cyrus_sasl + krb5 ]; coursier = pkgs.fetchFromGitHub { owner = "coursier"; @@ -66,7 +69,7 @@ }; PKG_CONFIG_PATH = pkgs.lib.makeSearchPath "lib/pkgconfig" - (with pkgs; [ openssl.dev libxml2.dev xmlsec.dev libxslt.dev ]); + (with pkgs; [ openssl.dev libxml2.dev xmlsec.dev libxslt.dev cyrus_sasl.dev krb5.dev ]); RUSTY_V8_ARCHIVE = let # NOTE: needs to be same as in Cargo.toml version = "130.0.7"; @@ -303,6 +306,14 @@ # RUST_LOG = "debug"; # RUST_LOG = "kube=debug"; + # Override cargo linker to use clang 18 (stdenv brings clang 21 which causes SIGSEGV with mold) + CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER = "${pkgs.llvmPackages_18.clang}/bin/clang"; + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER = "${pkgs.llvmPackages_18.clang}/bin/clang"; + CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS = "-C link-arg=-fuse-ld=mold -C link-arg=-Wl,-rpath,${pkgs.lib.makeLibraryPath [ pkgs.openssl pkgs.libffi pkgs.cyrus_sasl pkgs.krb5 pkgs.libxml2 pkgs.xmlsec pkgs.libxslt stdenv.cc.cc.lib ]}"; + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS = "-C link-arg=-fuse-ld=mold -C link-arg=-Wl,-rpath,${pkgs.lib.makeLibraryPath [ pkgs.openssl pkgs.libffi pkgs.cyrus_sasl pkgs.krb5 pkgs.libxml2 pkgs.xmlsec pkgs.libxslt stdenv.cc.cc.lib ]}"; + # rpath for build scripts and proc macros (host compilation) + CARGO_HOST_RUSTFLAGS = "-C link-arg=-Wl,-rpath,${pkgs.lib.makeLibraryPath [ pkgs.openssl pkgs.libffi pkgs.cyrus_sasl pkgs.krb5 pkgs.libxml2 pkgs.xmlsec pkgs.libxslt stdenv.cc.cc.lib ]}"; + # See this issue: https://github.com/NixOS/nixpkgs/issues/370494 # Allows to build jemalloc on nixos CFLAGS = "-Wno-error=int-conversion"; @@ -310,6 +321,7 @@ # Need to tell bindgen where to find libclang LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + # LD_LIBRARY_PATH set in shellHook with a wrapper to avoid leaking into git/ssh # LD_LIBRARY_PATH = "${pkgs.gcc.lib}/lib"; # Set C flags for Rust's bindgen program. Unlike ordinary C