Avoid building a llvm based bootstrap step

This commit is contained in:
Sameer Rahmani 2023-11-09 08:17:34 +00:00
parent 7577fcba1f
commit 17e4c6814c
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
4 changed files with 113 additions and 49 deletions

View File

@ -1,34 +1,12 @@
{
nixPkgsVersion ? "f606c027310f06df398875960e04038db1f0129f", # release 23.0 # "3e52e76b70d5508f3cec70b882a29199f4d1ee85", # unstable
currentSystem
}:
let let
tmpPkgs = import ../nixpkgs {};
getNixPkgs = args: import (builtins.fetchGit { pkgs = import ../nixpkgs {
name = "nixpkg-serene-${nixPkgsVersion}"; crossSystem = tmpPkgs.stdenv.hostPlatform // {
url = "https://github.com/nixos/nixpkgs/"; config = "x86_64-unknown-linux-musl";
# `git ls-remote https://github.com/nixos/nixpkgs nixos-unstable` useLLVM = true;
ref = "refs/heads/release-23.05"; # refs/heads/nixos-unstable linker = "lld";
rev = nixPkgsVersion; isMusl = true;
}) args; isStatic = true;
};
nixpkgs = getNixPkgs { system = currentSystem; };
system = import ./system.nix {
pkgs = nixpkgs;
inherit currentSystem;
}; };
# staticMuslPkgs = getNixPkgs system; in { inherit pkgs tmpPkgs; }
# llvm = staticMuslPkgs.llvmPackages_16.override { stdenv = staticMuslPkgs.llvmPackages_16.libcxxStdenv; };
replaceStdenv = { pkgs }:
let
llvm = pkgs.llvmPackages_16.override { stdenv = pkgs.llvmPackages_16.libcxxStdenv; };
in
llvm.libcxxStdenv;
createPkgSet = _:
getNixPkgs (system // { config = { inherit replaceStdenv; }; });
in {
inherit createPkgSet;
}

39
flake.lock Normal file
View File

@ -0,0 +1,39 @@
{
"nodes": {
"h": {
"flake": false,
"locked": {
"lastModified": 1,
"narHash": "sha256-FghzEGAvDzfNDjS4QPKu635KMnCbPAbMLoZBJDVrj9g=",
"path": "/nix/store/1qdpdwjgrz119dm0nr7fq4wiwiks8br7-source/test-drv.nix",
"type": "path"
},
"original": {
"path": "/nix/store/1qdpdwjgrz119dm0nr7fq4wiwiks8br7-source/test-drv.nix",
"type": "path"
}
},
"nixpkgs": {
"locked": {
"dirtyRev": "68ba5fd2ed8be749cf1865ed9a71667dfda944a7-dirty",
"dirtyShortRev": "68ba5fd2ed8b-dirty",
"lastModified": 1697211831,
"narHash": "sha256-baRp/RgDaU3rVlybOpTPzo/+FdsfTyKp3iv4igguHkY=",
"type": "git",
"url": "file:///home/lxsameer/src/nixpkgs"
},
"original": {
"type": "git",
"url": "file:///home/lxsameer/src/nixpkgs"
}
},
"root": {
"inputs": {
"h": "h",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

View File

@ -1,22 +1,19 @@
{ {
description = "Serene Toolchain"; description = "Serene Toolchain";
outputs = inputs: inputs.nixpkgs.url = "/home/lxsameer/src/nixpkgs/";
let inputs.h = {
toolchain = import /home/lxsameer/src/toolchain/test-stdenv.nix {}; flake = false;
nixpkgs = import /home/lxsameer/src/nixpkgs {}; url = "./test-drv.nix";
myenv = toolchain.createPkgSet; };
in
{ outputs = {self, nixpkgs, h}:
testClang = myenv.stdenv.mkDerivation { let
name = "testClang"; h' = import h.outPath;
unpackPhase = "echo AA $CC; echo '--'; env; NIX_DEBUG=1 $CC -v; echo '--'; exit 1"; hello = h'.hello;
}; in {
testGcc = nixpkgs.stdenv.mkDerivation { packages.x86_64-linux.h = h;
name = "testGcc"; packages.x86_64-linux.hello = hello;
unpackPhase = "NIX_DEBUG=1 $CC --version; echo $CC; $CC -v; exit 1";
};
inherit myenv;
}; };
} }

50
test-drv.nix Normal file
View File

@ -0,0 +1,50 @@
# let
# toolchain = import /home/lxsameer/src/toolchain/test-stdenv.nix {};
# nixpkgs = import /home/lxsameer/src/nixpkgs {};
# myenv = toolchain.createPkgSet;
# in myenv.ninja #.stdenv
# nix build --impure --expr 'with import ./. { crossSystem = (import ./lib).systems.examples.musl64 // { useLLVM = true; }; }; bash'
let
tmpPkgs = import /home/lxsameer/src/nixpkgs {};
# pkgs = import /home/lxsameer/src/nixpkgs {
# crossSystem = tmpPkgs.stdenv.hostPlatform // {
# config = "x86_64-unknown-linux-musl";
# useLLVM = true;
# linker = "lld";
# isMusl = true;
# isStatic = true;
# };
# };
static = tmpPkgs.pkgsMusl.pkgsStatic;
#stdenv = static.llvmPackages_16.libcxxStdenv;
monorepoSrc = tmpPkgs.fetchgit {
url = "https://devheroes.codes/Serene/llvm-project.git";
rev = "b2c0361bcc08afdf466a605a23924bcd64fa2b86";
hash = "sha256-wUKHwWYYlKa0v5zEJXxndleYtK7wzJKi0vqr3lNkGMI=";
};
overrideSrc = { inherit monorepoSrc; };
buildLlvm = static.llvmPackages_16.override overrideSrc;
targetLlvm = static.llvmPackages_16.override overrideSrc;
# pkgsStaticLlvm.
llvm = static.llvmPackages_16.override (prev: overrideSrc // {
buildLlvmTools = buildLlvm.tools;
targetLlvmLibraries = targetLlvm.libraries or {};
targetLlvm = targetLlvm.llvm or {};
officialRelease = null;
gitRelease = {
version = "16.0.6";
rev = "b2c0361bcc08afdf466a605a23924bcd64fa2b86";
rev-version = "17-disable-shared-1";
};
});
stdenv = llvm.libcxxStdenv;
in tmpPkgs.hello.override { inherit stdenv; }