From efbce7bf34a983d772438541d8f7a8aed2acb9d2 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Tue, 30 Jul 2024 19:45:34 -0700 Subject: [PATCH] zig.cc: add bintools --- pkgs/development/compilers/zig/cc.nix | 36 ++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/zig/cc.nix b/pkgs/development/compilers/zig/cc.nix index 115a71ca490090..763cf6033e683f 100644 --- a/pkgs/development/compilers/zig/cc.nix +++ b/pkgs/development/compilers/zig/cc.nix @@ -1,7 +1,9 @@ { lib, wrapCCWith, + wrapBintoolsWith, makeWrapper, + stdenv, runCommand, stdenv, targetPackages, @@ -21,7 +23,7 @@ wrapCCWith { } '' mkdir -p $out/bin - for tool in ar cc c++ objcopy; do + for tool in cc c++; do makeWrapper "$zig/bin/zig" "$out/bin/$tool" \ --add-flags "$tool" \ --run "export ZIG_GLOBAL_CACHE_DIR=\$(mktemp -d)" @@ -31,6 +33,38 @@ wrapCCWith { mv $out/bin/cc $out/bin/clang ''; + bintools = + let + targetPrefix = lib.optionalString ( + stdenv.hostPlatform != stdenv.targetPlatform + ) "${stdenv.targetPlatform.config}-"; + in + wrapBintoolsWith { + bintools = + runCommand "zig-bintools-${zig.version}" + { + pname = "zig-bintools"; + inherit (zig) version meta; + + nativeBuildInputs = [ makeWrapper ]; + + passthru = { + isZig = true; + inherit targetPrefix; + }; + + inherit zig; + } + '' + mkdir -p $out/bin + for tool in ar objcopy; do + makeWrapper "$zig/bin/zig" "$out/bin/${targetPrefix}-$tool" \ + --add-flags "$tool" \ + --run "export ZIG_GLOBAL_CACHE_DIR=\$(mktemp -d)" + done + ''; + }; + nixSupport.cc-cflags = [ "-target"