Use nixSupport instead of extraBuildCommands

This commit is contained in:
Aleix Boné 2025-12-10 15:52:49 +01:00
parent 8f0f327683
commit 01d7133a5d
No known key found for this signature in database

View File

@ -47,6 +47,7 @@ lib.makeOverridable (
wrapIntel =
{
cc,
nixSupport ? { },
extraBuildCommands ? "",
extraInstall ? "",
...
@ -57,37 +58,31 @@ lib.makeOverridable (
(
wrapCCWith {
inherit cc;
nixSupport = lib.mergeAttrsConcatenateValues {
cc-ldflags = [
"-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}"
"-L${gcc.cc.lib}/lib"
"-L${cc}/lib"
];
cc-cflags = [
"--gcc-toolchain=${gcc.cc}"
"-isystem \"$(dirname $(realpath ${cc}/lib/clang/*/include/stddef.h))\""
"-isystem ${cc}/include"
"-isystem ${cc}/include/intel64"
"-isystem ${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}/include"
];
libcxx-cxxflags = [
# "--gcc-toolchain=${gcc.cc}"
"-isystem ${gcc.cc}/include/c++/${gcc.version}"
"-isystem ${gcc.cc}/include/c++/${gcc.version}/${targetConfig}"
];
} nixSupport;
extraBuildCommands = ''
echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags
echo "-L${gcc.cc.lib}/lib" >> $out/nix-support/cc-ldflags
echo "-L${cc}/lib" >> $out/nix-support/cc-ldflags
# echo "--gcc-toolchain=${gcc.cc}" >> $out/nix-support/libcxx-cxxflags
echo "--gcc-toolchain=${gcc.cc}" >> $out/nix-support/cc-cflags
# For some reason, If we don't resolve the realpath things go wrong
for stddef in ${cc}/lib/clang/*/include/stddef.h ; do
dir=$(dirname $(realpath "$stddef"))
echo "-isystem $dir" >> $out/nix-support/cc-cflags
done
echo "-isystem ${cc}/include" >> $out/nix-support/cc-cflags
echo "-isystem ${cc}/include/intel64" >> $out/nix-support/cc-cflags
for dir in ${gcc.cc}/lib/gcc/${targetConfig}/*/include; do
echo "-isystem $dir" >> $out/nix-support/cc-cflags
done
for dir in ${gcc.cc}/include/c++/*; do
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
done
for dir in ${gcc.cc}/include/c++/*/${targetConfig}; do
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
done
# FIXME: We should find a better way to modify the PATH instead of using
# this ugly hack. See https://jungle.bsc.es/git/rarias/bscpkgs/issues/9
echo 'path_backup="${gcc.cc}/bin:$path_backup"' >> $out/nix-support/cc-wrapper-hook
echo 'path_backup="${gcc.cc}/bin:$path_backup"' >>$out/nix-support/cc-wrapper-hook
# Disable hardening by default
echo "" > $out/nix-support/add-hardening.sh
@ -98,6 +93,7 @@ lib.makeOverridable (
"cc"
"extraBuildCommands"
"extraInstall"
"nixSupport"
])
).overrideAttrs
(old: {
@ -178,6 +174,7 @@ lib.makeOverridable (
cc = wrapIntel {
cc = finalAttrs.finalPackage.pkgs.compiler;
extraBuildCommands = ''
wrap icx $wrapper $ccPath/icx
wrap icpx $wrapper $ccPath/icpx
@ -186,11 +183,11 @@ lib.makeOverridable (
ln -s $out/bin/icpx $out/bin/c++
ln -s $out/bin/icx $out/bin/cc
sed -i 's/.*isCxx=0/isCxx=1/' $out/bin/icpx
# Use this to detect when a compiler subprocess is called
# from icpx (--fsycl-host-compiler)
echo 'export "NIX_CC_WRAPPER_INTEL=1"' >> $out/nix-support/cc-wrapper-hook
sed -i 's/.*isCxx=0/isCxx=1/' $out/bin/icpx
echo 'export NIX_CC_WRAPPER_INTEL=1' >>$out/nix-support/cc-wrapper-hook
# oneMath looks for sycl libraries in bin/../lib
ln -s ${finalAttrs.finalPackage.pkgs.compiler}/lib $out/lib