From 29f1e8395c16831d2fe06cfa9aa8c49dc8cc96a6 Mon Sep 17 00:00:00 2001 From: Sergey Kosukhin Date: Sat, 29 Oct 2022 20:17:43 +0200 Subject: [PATCH] mpich: fix rpath flags in mpif90 when building with oneapi (#33319) Co-authored-by: eugeneswalker <38933153+eugeneswalker@users.noreply.github.com> --- .../mpich/mpich-oneapi-config-rpath.patch | 30 ------------------- .../mpich-oneapi-config-rpath/step1.patch | 9 ++++++ .../mpich-oneapi-config-rpath/step2.patch | 6 ++++ .../repos/builtin/packages/mpich/package.py | 10 +++++-- 4 files changed, 23 insertions(+), 32 deletions(-) delete mode 100644 var/spack/repos/builtin/packages/mpich/mpich-oneapi-config-rpath.patch create mode 100644 var/spack/repos/builtin/packages/mpich/mpich-oneapi-config-rpath/step1.patch create mode 100644 var/spack/repos/builtin/packages/mpich/mpich-oneapi-config-rpath/step2.patch diff --git a/var/spack/repos/builtin/packages/mpich/mpich-oneapi-config-rpath.patch b/var/spack/repos/builtin/packages/mpich/mpich-oneapi-config-rpath.patch deleted file mode 100644 index 94eafda34f..0000000000 --- a/var/spack/repos/builtin/packages/mpich/mpich-oneapi-config-rpath.patch +++ /dev/null @@ -1,30 +0,0 @@ -diff -ruN spack-src/confdb/config.rpath spack-src-patched/confdb/config.rpath ---- spack-src/confdb/config.rpath 2022-03-29 15:13:49.000000000 -0700 -+++ spack-src-patched/confdb/config.rpath 2022-07-25 17:54:14.638367460 -0700 -@@ -76,7 +76,7 @@ - ecc*) - wl='-Wl,' - ;; -- icc* | ifort*) -+ icc* | icx* | ifort* | ifx*) - wl='-Wl,' - ;; - lf95*) -@@ -233,7 +233,7 @@ - enable_dtags_flag="${wl}--enable-new-dtags" - disable_dtags_flag="${wl}--disable-new-dtags" - else -- case $cc_basename in ifort*) -+ case $cc_basename in ifort* | ifx*) - enable_dtags_flag="${wl}--enable-new-dtags" - disable_dtags_flag="${wl}--disable-new-dtags" - ;; -@@ -380,7 +380,7 @@ - ;; - darwin* | rhapsody*) - hardcode_direct=no -- if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then -+ if { case $cc_basename in ifort* | ifx*) true;; *) test "$GCC" = yes;; esac; }; then - : - else - ld_shlibs=no diff --git a/var/spack/repos/builtin/packages/mpich/mpich-oneapi-config-rpath/step1.patch b/var/spack/repos/builtin/packages/mpich/mpich-oneapi-config-rpath/step1.patch new file mode 100644 index 0000000000..90f53b61cf --- /dev/null +++ b/var/spack/repos/builtin/packages/mpich/mpich-oneapi-config-rpath/step1.patch @@ -0,0 +1,9 @@ +# This patch is applicable starting at least version 3.0. +--- a/confdb/config.rpath ++++ b/confdb/config.rpath +@@ -79 +79 @@ else +- icc* | ifort*) ++ icc* | icx* | ifort* | ifx*) +@@ -383 +383 @@ else +- if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then ++ if { case $cc_basename in ifort* | ifx*) true;; *) test "$GCC" = yes;; esac; }; then diff --git a/var/spack/repos/builtin/packages/mpich/mpich-oneapi-config-rpath/step2.patch b/var/spack/repos/builtin/packages/mpich/mpich-oneapi-config-rpath/step2.patch new file mode 100644 index 0000000000..ea14a28eb8 --- /dev/null +++ b/var/spack/repos/builtin/packages/mpich/mpich-oneapi-config-rpath/step2.patch @@ -0,0 +1,6 @@ +# This patch is applicable starting version 3.1.1. +--- a/confdb/config.rpath ++++ b/confdb/config.rpath +@@ -236 +236 @@ if test "$with_gnu_ld" = yes; then +- case $cc_basename in ifort*) ++ case $cc_basename in ifort* | ifx*) diff --git a/var/spack/repos/builtin/packages/mpich/package.py b/var/spack/repos/builtin/packages/mpich/package.py index 701ba95856..8692cf0636 100644 --- a/var/spack/repos/builtin/packages/mpich/package.py +++ b/var/spack/repos/builtin/packages/mpich/package.py @@ -150,8 +150,14 @@ class Mpich(AutotoolsPackage, CudaPackage, ROCmPackage): filter_compiler_wrappers("mpicc", "mpicxx", "mpif77", "mpif90", "mpifort", relative_root="bin") - # https://github.com/spack/spack/issues/31678 - patch("mpich-oneapi-config-rpath.patch", when="@4.0.2 %oneapi") + # Set correct rpath flags for Intel Fortran Compiler (%oneapi) + # See https://github.com/pmodels/mpich/pull/5824 + # and https://github.com/spack/spack/issues/31678 + # We do not fetch the patch from the upstream repo because it cannot be applied to older + # versions. + with when("%oneapi"): + patch("mpich-oneapi-config-rpath/step1.patch", when="@:4.0.2") + patch("mpich-oneapi-config-rpath/step2.patch", when="@3.1.1:4.0.2") # Fix using an external hwloc # See https://github.com/pmodels/mpich/issues/4038