From 6b430a5a3f89b34e1dcf418b80f848b092070dd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Bon=C3=A9?= Date: Fri, 18 Jul 2025 18:48:22 +0200 Subject: [PATCH] Remove wrapper flags when clang called from intel --- pkgs/intel-oneapi/patch_intel.nix | 4 ++++ pkgs/llvm-ompss2/default.nix | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pkgs/intel-oneapi/patch_intel.nix b/pkgs/intel-oneapi/patch_intel.nix index ef95d55..2bff369 100644 --- a/pkgs/intel-oneapi/patch_intel.nix +++ b/pkgs/intel-oneapi/patch_intel.nix @@ -147,6 +147,10 @@ stdenvNoCC.mkDerivation (finalAttrs: { ln -s $out/bin/icpx $out/bin/c++ ln -s $out/bin/icx $out/bin/cc + # 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 # oneMath looks for sycl libraries in bin/../lib diff --git a/pkgs/llvm-ompss2/default.nix b/pkgs/llvm-ompss2/default.nix index 43f7c13..cc0db2c 100644 --- a/pkgs/llvm-ompss2/default.nix +++ b/pkgs/llvm-ompss2/default.nix @@ -3,6 +3,7 @@ , lib , gcc , clangOmpss2Unwrapped +, writeShellScript , openmp ? null , wrapCCWith , llvmPackages_latest @@ -37,6 +38,19 @@ let inherit gcc; cc = clangOmpss2Unwrapped; gccVersion = with versions; let v = gcc.version; in concatStringsSep "." [(major v) (minor v) (patch v)]; + + resetIntelCCFlags = let tconf = builtins.replaceStrings ["-"] ["_"] targetConfig; + in writeShellScript "remove-intel.sh" '' + if [ "''${NIX_CC_WRAPPER_INTEL:-0}" = 1 ]; then + unset NIX_CFLAGS_COMPILE_${tconf} + unset NIX_CC_WRAPPER_FLAGS_SET_${tconf} + + if (( "${NIX_DEBUG:-0}" >= 1 )); then + echo "ompss2: cleaned NIX_CFLAGS_COMPILE_${tconf} (invokation from intel compiler detected)" + fi + fi + ''; + in wrapCCWith { inherit cc bintools; # extraPackages adds packages to depsTargetTargetPropagated @@ -61,7 +75,10 @@ in wrapCCWith { wrap clang++ $wrapper $ccPath/clang++ - '' + optionalString (openmp != null) '' + sed -i 's|# Flirting.*|source ${resetIntelCCFlags}\n\n&|' $out/bin/clang + sed -i 's|# Flirting.*|&\nsource ${resetIntelCCFlags}\n\n&|' $out/bin/clang++ + + '' + lib.optionalString (openmp != null) '' echo "export OPENMP_RUNTIME=${ompname}" >> $out/nix-support/cc-wrapper-hook '' + optionalString (ompss2rt != null) '' echo "export OMPSS2_RUNTIME=${rtname}" >> $out/nix-support/cc-wrapper-hook