diff --git a/pkgs/intel-oneapi/patch_intel.nix b/pkgs/intel-oneapi/patch_intel.nix index 62df434..66c7938 100644 --- a/pkgs/intel-oneapi/patch_intel.nix +++ b/pkgs/intel-oneapi/patch_intel.nix @@ -45,59 +45,65 @@ lib.makeOverridable ( # } __components; wrapIntel = - { - cc, - nixSupport ? { }, - extraBuildCommands ? "", - extraInstall ? "", - ... - }@args: + cc: let targetConfig = stdenv.targetPlatform.config; in - ( - wrapCCWith { - inherit cc; + (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 \"${cc.original}/lib/clang/*/include\"" - "-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; + nixSupport = { + 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 \"${cc.original}/lib/clang/*/include\"" + "-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}" + ]; + }; - extraBuildCommands = '' - # 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 + extraBuildCommands = '' + # 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 - # Disable hardening by default - echo "" > $out/nix-support/add-hardening.sh - '' - + extraBuildCommands; - } - // (removeAttrs args [ - "cc" - "extraBuildCommands" - "extraInstall" - "nixSupport" - ]) - ).overrideAttrs + # Disable hardening by default + echo "" > $out/nix-support/add-hardening.sh + + wrap icx $wrapper $ccPath/icx + wrap icpx $wrapper $ccPath/icpx + wrap ifx $wrapper $ccPath/ifx + + 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 + + # oneMath looks for sycl libraries in bin/../lib + ln -s ${cc}/lib $out/lib + ln -s ${cc}/include $out/include + ''; + }).overrideAttrs (old: { - installPhase = old.installPhase + extraInstall; + installPhase = old.installPhase + '' + export named_cc="icx" + export named_cxx="icpx" + export named_fc="ifx" + ''; }); in @@ -176,33 +182,7 @@ lib.makeOverridable ( stdenv = overrideCC stdenv finalAttrs.finalPackage.cc; - cc = wrapIntel { - cc = finalAttrs.finalPackage.pkgs.compiler; - - extraBuildCommands = '' - wrap icx $wrapper $ccPath/icx - wrap icpx $wrapper $ccPath/icpx - wrap ifx $wrapper $ccPath/ifx - - 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 - - # oneMath looks for sycl libraries in bin/../lib - ln -s ${finalAttrs.finalPackage.pkgs.compiler}/lib $out/lib - ln -s ${finalAttrs.finalPackage.pkgs.compiler}/include $out/include - ''; - extraInstall = '' - export named_cc="icx" - export named_cxx="icpx" - export named_fc="ifx" - ''; - }; + cc = wrapIntel finalAttrs.finalPackage.pkgs.compiler; }; })