[M5+] swap toolchain to gcc15Stdenv + libstdc++
This commit is contained in:
@@ -18,7 +18,6 @@ struct DepBinding {
|
||||
std::string sanitized; // "nixpkgs_fmt_10_2_1" — input attr,
|
||||
// let-binding stem, lambda param
|
||||
std::optional<std::string> rev; // pinned commit (null → unpinned)
|
||||
bool libcxx_override = false; // wrap in .override { stdenv = libcxx }
|
||||
};
|
||||
|
||||
// Replaces every char outside [a-zA-Z0-9_] with '_'. The result is safe
|
||||
@@ -77,7 +76,6 @@ auto build_bindings(const GenerateInputs& in) -> std::vector<DepBinding> {
|
||||
.nixpkgs_attr = std::move(attr),
|
||||
.sanitized = sanitize_input_attr(dep.name, dep.version_spec),
|
||||
.rev = std::move(ref.rev),
|
||||
.libcxx_override = rec.requires_libcxx_override,
|
||||
};
|
||||
out.push_back(std::move(b));
|
||||
}
|
||||
@@ -146,32 +144,13 @@ auto base_expr(const DepBinding& b) -> std::string {
|
||||
: std::format("pkgs.{}", b.nixpkgs_attr);
|
||||
}
|
||||
|
||||
auto emit_build_input_line(const DepBinding& b) -> std::string {
|
||||
auto expr = base_expr(b);
|
||||
if (b.libcxx_override) {
|
||||
// Stdenv swap (libc++) plus a `doCheck = false` overrideAttrs
|
||||
// to skip the package's test suite — without it, the rebuilt
|
||||
// dep would re-run its full check phase under the new stdenv,
|
||||
// adding minutes to hours of evaluation/build time.
|
||||
expr = std::format(
|
||||
"(({}.override {{ stdenv = llvmPkgs.libcxxStdenv; }})"
|
||||
".overrideAttrs (old: {{ doCheck = false; }}))",
|
||||
expr);
|
||||
}
|
||||
return std::format(" {}\n", expr);
|
||||
}
|
||||
|
||||
auto emit_build_inputs(const std::vector<DepBinding>& bindings) -> std::string {
|
||||
std::set<std::string> seen;
|
||||
std::string out;
|
||||
for (const auto& b : bindings) {
|
||||
// Dedupe by base expression — two deps that resolve to the same
|
||||
// (set, attr) but differ only in override are considered distinct
|
||||
// because the dedup key includes the override flag.
|
||||
auto key = std::format("{}{}", base_expr(b),
|
||||
b.libcxx_override ? "@libcxx" : "");
|
||||
if (seen.insert(key).second) {
|
||||
out += emit_build_input_line(b);
|
||||
auto expr = base_expr(b);
|
||||
if (seen.insert(expr).second) {
|
||||
out += std::format(" {}\n", expr);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
@@ -197,25 +176,17 @@ auto flake_nix(const GenerateInputs& in) -> std::string {
|
||||
" let\n"
|
||||
" pkgs = import nixpkgs { inherit system; };\n";
|
||||
out += emit_let_bindings(pinned);
|
||||
out += " llvmPkgs = pkgs.llvmPackages;\n"
|
||||
" in {\n"
|
||||
" devShell = llvmPkgs.libcxxStdenv.mkDerivation {\n"
|
||||
out += " in {\n"
|
||||
" devShell = pkgs.gcc15Stdenv.mkDerivation {\n"
|
||||
" name = \"shell\";\n"
|
||||
" version = \"1.0\";\n"
|
||||
" nativeBuildInputs = [\n"
|
||||
" pkgs.ninja\n"
|
||||
" pkgs.cmake\n"
|
||||
" pkgs.clang-tools\n"
|
||||
" ];\n"
|
||||
" buildInputs = [\n";
|
||||
out += emit_build_inputs(bindings);
|
||||
out += " ];\n"
|
||||
" env.NIX_CFLAGS_COMPILE = toString [\n"
|
||||
" \"-stdlib=libc++\"\n"
|
||||
" \"-Wno-unused-command-line-argument\"\n"
|
||||
" \"-B${pkgs.lib.getLib pkgs.libcxx}/lib\"\n"
|
||||
" \"-isystem ${pkgs.lib.getDev pkgs.libcxx}/include/c++/v1\"\n"
|
||||
" ];\n"
|
||||
" hardeningDisable = [\n"
|
||||
" \"all\"\n"
|
||||
" ];\n"
|
||||
|
||||
Reference in New Issue
Block a user