This commit is contained in:
2024-11-23 11:39:24 +08:00
parent 2eb20cf492
commit 5e4200f4b4

View File

@@ -5,11 +5,11 @@ let
name = "gcc-combined";
paths =
[
gcc gfortran glibc_multi.out gcc.cc.lib
gcc gfortran glibc_multi gcc.cc.lib
# wrapped binaries
# stdenv.cc gfortran glibc glibc.dev binutils iconv
# not wrapped binaries
gcc.cc gfortran.cc gfortran.cc.lib
# gcc.cc gfortran.cc gfortran.cc.lib
];
};
unwrapped = stdenv.mkDerivation
@@ -25,22 +25,21 @@ let
installPhase =
''
# install component
mkdir -p $out
cp -r install_components/Linux_x86_64/${src.version}/compilers/{bin,include,lib,share} $out
# NVHPC use very complex mechanism to identify the location of compilers, headers, etc.
# we should keep the original structure
mkdir -p $out/opt/nvhpc/Linux_x86_64/${src.version}
cp -r install_components/Linux_x86_64/${src.version}/compilers $out/opt/nvhpc/Linux_x86_64/${src.version}
ln -s $out/opt/nvhpc/Linux_x86_64/${src.version}/compilers/bin $out
# create localrc
patchShebangs $out/bin/makelocalrc
sed -i '/makelocalrc executed by/d' $out/bin/makelocalrc
$out/bin/makelocalrc $out/bin -x
# $out/bin/tools could not be moved to $out/share
patchShebangs $out/opt/nvhpc/Linux_x86_64/${src.version}/compilers/bin/makelocalrc
sed -i '/makelocalrc executed by/d' $out/opt/nvhpc/Linux_x86_64/${src.version}/compilers/bin/makelocalrc
$out/opt/nvhpc/Linux_x86_64/${src.version}/compilers/bin/makelocalrc -x
'';
};
# fix /usr/lib/crt1.o impure path used in link
customLocalrc = writeText "localrc"
''
set LLVMDIR=${unwrapped}/share/llvm;
set COMPBIN=${unwrapped}/bin;
set PGILD="-T${unwrapped}/lib/nvhpc.ld";
set DEFLIBDIR=${gcc-combined}/lib;
set DEFSTDOBJDIR=${gcc-combined}/lib;
'';
@@ -51,10 +50,10 @@ let
cc = unwrapped;
extraBuildCommands =
''
echo "-isystem ${unwrapped}/include" >> $out/nix-support/cc-cflags
# echo "-isystem ${unwrapped}/include" >> $out/nix-support/cc-cflags
# echo "-L${stdenv.cc.cc}/lib/gcc/${stdenv.targetPlatform.config}/${stdenv.cc.version}" >> $out/nix-support/cc-ldflags
# echo "-L${stdenv.cc.cc.lib}/lib" >> $out/nix-support/cc-ldflags
echo "-L${unwrapped}/lib -L${gcc-combined}/lib --verbose" >> $out/nix-support/cc-ldflags
# echo "-L${unwrapped}/lib -L${gcc-combined}/lib --verbose" >> $out/nix-support/cc-ldflags
echo "-tp=${config.nvhpcArch}" >> $out/nix-support/cc-cflags-before
echo "-gpu=${cudaCapability} -#" >> $out/nix-support/cc-cflags-before