zig: add cc wrapper
This commit is contained in:
parent
2c5b5ebf5e
commit
65c81d4eae
@ -89,6 +89,9 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
|
||||
passthru = {
|
||||
hook = callPackage ./hook.nix { zig = finalAttrs.finalPackage; };
|
||||
cc = callPackage ../cc.nix {
|
||||
zig = finalAttrs.finalPackage;
|
||||
};
|
||||
tests = {
|
||||
version = testers.testVersion {
|
||||
package = finalAttrs.finalPackage;
|
||||
|
@ -83,6 +83,9 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
|
||||
passthru = {
|
||||
hook = callPackage ./hook.nix { zig = finalAttrs.finalPackage; };
|
||||
cc = callPackage ../cc.nix {
|
||||
zig = finalAttrs.finalPackage;
|
||||
};
|
||||
tests = {
|
||||
version = testers.testVersion {
|
||||
package = finalAttrs.finalPackage;
|
||||
|
@ -95,6 +95,9 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
|
||||
passthru = {
|
||||
hook = callPackage ./hook.nix { zig = finalAttrs.finalPackage; };
|
||||
cc = callPackage ../cc.nix {
|
||||
zig = finalAttrs.finalPackage;
|
||||
};
|
||||
tests = {
|
||||
version = testers.testVersion {
|
||||
package = finalAttrs.finalPackage;
|
||||
|
@ -91,6 +91,9 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
|
||||
passthru = {
|
||||
hook = callPackage ./hook.nix { zig = finalAttrs.finalPackage; };
|
||||
cc = callPackage ../cc.nix {
|
||||
zig = finalAttrs.finalPackage;
|
||||
};
|
||||
tests = {
|
||||
version = testers.testVersion {
|
||||
package = finalAttrs.finalPackage;
|
||||
|
42
pkgs/development/compilers/zig/cc.nix
Normal file
42
pkgs/development/compilers/zig/cc.nix
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
lib,
|
||||
wrapCCWith,
|
||||
makeWrapper,
|
||||
runCommand,
|
||||
targetPlatform,
|
||||
targetPackages,
|
||||
zig,
|
||||
}:
|
||||
wrapCCWith {
|
||||
cc =
|
||||
runCommand "zig-cc-${zig.version}"
|
||||
{
|
||||
pname = "zig-cc";
|
||||
inherit (zig) version meta;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
passthru.isZig = true;
|
||||
inherit zig;
|
||||
}
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
for tool in ar cc c++ objcopy; do
|
||||
makeWrapper "$zig/bin/zig" "$out/bin/$tool" \
|
||||
--add-flags "$tool" \
|
||||
--run "export ZIG_GLOBAL_CACHE_DIR=\$(mktemp -d)"
|
||||
done
|
||||
|
||||
mv $out/bin/c++ $out/bin/clang++
|
||||
mv $out/bin/cc $out/bin/clang
|
||||
'';
|
||||
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-target"
|
||||
"${targetPlatform.parsed.cpu.name}-${targetPlatform.parsed.kernel.name}-${targetPlatform.parsed.abi.name}"
|
||||
]
|
||||
++ lib.optional (
|
||||
targetPlatform.isLinux && !(targetPackages.isStatic or false)
|
||||
) "-Wl,-dynamic-linker=${targetPackages.stdenv.cc.bintools.dynamicLinker}";
|
||||
}
|
@ -71,6 +71,9 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
hook = callPackage ./hook.nix {
|
||||
zig = finalAttrs.finalPackage;
|
||||
};
|
||||
cc = callPackage ./cc.nix {
|
||||
zig = finalAttrs.finalPackage;
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
|
Loading…
Reference in New Issue
Block a user