fix clr build

This commit is contained in:
2025-06-27 11:16:48 +04:00
parent 11c02027e9
commit 0e8f2c67da
2 changed files with 37 additions and 27 deletions

6
flake.lock generated
View File

@@ -20,11 +20,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1748370509, "lastModified": 1750776420,
"narHash": "sha256-QlL8slIgc16W5UaI3w7xHQEP+Qmv/6vSNTpoZrrSlbk=", "narHash": "sha256-/CG+w0o0oJ5itVklOoLbdn2dGB0wbZVOoDm4np6w09A=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "4faa5f5321320e49a78ae7848582f684d64783e9", "rev": "30a61f056ac492e3b7cdcb69c1e6abdcf00e39cf",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -56,6 +56,8 @@ let
stdenv.cc.bintools stdenv.cc.bintools
gcc-unwrapped gcc-unwrapped
stdenvToBuildRocmLlvm stdenvToBuildRocmLlvm
stdenvToBuildRocmLlvm.cc
stdenvToBuildRocmLlvm.cc.cc
]; ];
gcc-prefix = gcc-prefix =
let let
@@ -146,7 +148,14 @@ let
let let
linked = symlinkJoin { inherit name paths; }; linked = symlinkJoin { inherit name paths; };
in in
runCommand name { } '' runCommand name
{
# If this is erroring, try why-depends --precise on the symlinkJoin of inputs to look for the problem
# nix why-depends --precise .#rocmPackages.llvm.rocmcxx.linked /store/path/its/not/allowed
disallowedRequisites = disallowedRefsForToolchain;
passthru.linked = linked;
}
''
set -x set -x
mkdir -p $out/ mkdir -p $out/
cp --reflink=auto -rL ${linked}/* $out/ cp --reflink=auto -rL ${linked}/* $out/
@@ -154,23 +163,22 @@ let
mkdir -p $out/usr mkdir -p $out/usr
ln -s $out/ $out/usr/local ln -s $out/ $out/usr/local
mkdir -p $out/nix-support/ mkdir -p $out/nix-support/
rm -rf $out/lib64 # we don't need mixed 32 bit # we don't need mixed 32 bit, the presence of lib64 is used by LLVM to decide it's a multilib sysroot
rm -rf $out/lib64
echo 'export CC=clang' >> $out/nix-support/setup-hook echo 'export CC=clang' >> $out/nix-support/setup-hook
echo 'export CXX=clang++' >> $out/nix-support/setup-hook echo 'export CXX=clang++' >> $out/nix-support/setup-hook
mkdir -p $out/lib/clang/${llvmMajorVersion}/lib/linux/ mkdir -p $out/lib/clang/${llvmMajorVersion}/lib/linux/
ln -s $out/lib/linux/libclang_rt.* $out/lib/clang/${llvmMajorVersion}/lib/linux/ ln -s $out/lib/linux/libclang_rt.* $out/lib/clang/${llvmMajorVersion}/lib/linux/
file $out/bin/.clang-wrapped
file $out/bin/.clang++-wrapped
find $out -type f -exec sed -i "s|${cc.out}|$out|g" {} + find $out -type f -exec sed -i "s|${cc.out}|$out|g" {} +
find $out -type f -exec sed -i "s|${cc.dev}|$out|g" {} + find $out -type f -exec sed -i "s|${cc.dev}|$out|g" {} +
file $out/bin/.clang-wrapped
file $out/bin/.clang++-wrapped
# our /include now has more than clang expects, so this specific dir still needs to point to cc.dev # our /include now has more than clang expects, so this specific dir still needs to point to cc.dev
# FIXME: could copy into a different subdir? # FIXME: could copy into a different subdir?
sed -i 's|set(CLANG_INCLUDE_DIRS.*$|set(CLANG_INCLUDE_DIRS "${cc.dev}/include")|g' $out/lib/cmake/clang/ClangConfig.cmake sed -i 's|set(CLANG_INCLUDE_DIRS.*$|set(CLANG_INCLUDE_DIRS "${cc.dev}/include")|g' $out/lib/cmake/clang/ClangConfig.cmake
${lib.getExe rdfind} -makesymlinks true $out/ # create links *within* the sysroot to save space ${lib.getExe rdfind} -makesymlinks true $out/ # create links *within* the sysroot to save space
''; '';
findClangNostdlibincPatch = findClangNostdlibincPatch =
x: x:
( (
@@ -417,6 +425,8 @@ rec {
+ '' + ''
find $lib -type f -exec remove-references-to -t ${stdenv.cc.cc} {} + find $lib -type f -exec remove-references-to -t ${stdenv.cc.cc} {} +
find $lib -type f -exec remove-references-to -t ${stdenv.cc.bintools} {} + find $lib -type f -exec remove-references-to -t ${stdenv.cc.bintools} {} +
find $lib -type f -exec remove-references-to -t ${stdenvToBuildRocmLlvm.cc} {} +
find $lib -type f -exec remove-references-to -t ${stdenv.cc} {} +
''; '';
preConfigure = preConfigure =
(old.preConfigure or "") (old.preConfigure or "")