Skip to content

Commit c32c99a

Browse files
committed
Fix postgresql musl: restore llvmPackages override + -fno-lto
hardeningDisable=["lto"] is not valid on musl cross stdenv (causes eval failure: "unsupported hardening flags"). Instead: - Restore llvmPackages_20 override to prevent LLVM dependency - Add -fno-lto via NIX_CFLAGS_COMPILE to disable GCC LTO (GCC LTO + GNU ld produces .ltrans link failures in postgresql)
1 parent 7c68545 commit c32c99a

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

flake.nix

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,27 @@
132132
# 2. perlSupport defaults true → musl perl lacks shared libperl.
133133
# 3. generic.nix switches to LLVM stdenv+bintools for LTO when
134134
# GCC is used. Cross-compiled LLVM 20 OOMs on darwin builders.
135-
# The switch provides ld.lld for GCC LTO; without it, GCC LTO
136-
# with GNU ld produces broken link (undefined refs in .ltrans).
137-
# Fix: disable LTO entirely via hardeningDisable.
135+
# We override llvmPackages_20 to prevent the switch (avoids
136+
# LLVM dependency), then explicitly disable LTO with -fno-lto
137+
# since GCC LTO + GNU ld is broken for postgresql (.ltrans
138+
# link failures). Can't use hardeningDisable=["lto"] because
139+
# "lto" is not a recognized hardening flag on musl cross.
138140
# 4. outputChecks unconditionally reference llvmPackages.llvm.
139141
postgresql = (prev.postgresql.override {
140142
jitSupport = false;
141143
perlSupport = false;
142-
}).overrideAttrs (_: {
143-
hardeningDisable = [ "lto" ];
144+
# Prevent the LTO stdenv switch: provide normal GCC-based
145+
# musl stdenv as llvmPackages_20, making the switch a no-op.
146+
llvmPackages_20 = prev.llvmPackages_20 // {
147+
inherit (prev) stdenv;
148+
bintools = prev.stdenv.cc.bintools;
149+
};
150+
}).overrideAttrs (old: {
151+
# Explicitly disable LTO since we're using GCC + GNU ld
152+
# (not the LLVM bintools the stdenv switch would provide).
153+
env = (old.env or {}) // {
154+
NIX_CFLAGS_COMPILE = (old.env.NIX_CFLAGS_COMPILE or "") + " -fno-lto";
155+
};
144156
doCheck = false;
145157
outputChecks = {};
146158
});

0 commit comments

Comments
 (0)