Skip to content

Commit

Permalink
zig.cc: add bintools
Browse files Browse the repository at this point in the history
  • Loading branch information
RossComputerGuy committed Jan 10, 2025
1 parent b2778b6 commit efbce7b
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion pkgs/development/compilers/zig/cc.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
lib,
wrapCCWith,
wrapBintoolsWith,
makeWrapper,
stdenv,
runCommand,
stdenv,
targetPackages,
Expand All @@ -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)"
Expand All @@ -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"
Expand Down

0 comments on commit efbce7b

Please sign in to comment.