From 8cce884078d924425f0755712ccd4cff525622ef Mon Sep 17 00:00:00 2001
From: eugeneswalker <38933153+eugeneswalker@users.noreply.github.com>
Date: Thu, 5 Mar 2020 13:54:25 -0800
Subject: [PATCH] unifyfs: add patch to fix #15292 (#15315)

It was reported that UnifyFS had a bug with the --enable-mpi-mount
config option, which corresponds to the auto-mount variant. This bug
was fixed in the UnifyFS dev branch, however remains broken for the
0.9.0 version.

This adds a patch to the unifyfs package to fix the auto-mount
variant when installing with version 0.9.0.

This also removes the openssl dependency as unifyfs does not directly
depend on it. This was said to be a non-explicit dependency in #15258.
However, if it is needed, it is likely a non-explicit dependency of
one of unifyfs's dependencies and should be added there.

Fixes: #15292
---
 .../builtin/packages/unifyfs/auto-mount.patch | 25 +++++++++++++++++++
 .../repos/builtin/packages/unifyfs/package.py |  6 ++++-
 2 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 var/spack/repos/builtin/packages/unifyfs/auto-mount.patch

diff --git a/var/spack/repos/builtin/packages/unifyfs/auto-mount.patch b/var/spack/repos/builtin/packages/unifyfs/auto-mount.patch
new file mode 100644
index 0000000000..a621f7dd11
--- /dev/null
+++ b/var/spack/repos/builtin/packages/unifyfs/auto-mount.patch
@@ -0,0 +1,25 @@
+diff --git a/client/src/pmpi_wrappers.c b/client/src/pmpi_wrappers.c
+index ac86d39..38755f5 100644
+--- a/client/src/pmpi_wrappers.c
++++ b/client/src/pmpi_wrappers.c
+@@ -14,7 +14,6 @@
+ 
+ #include "pmpi_wrappers.h"
+ #include "unifyfs.h"
+-#include <mpi.h>
+ #include <stdio.h>
+ 
+ int unifyfs_mpi_init(int* argc, char*** argv)
+diff --git a/client/src/pmpi_wrappers.h b/client/src/pmpi_wrappers.h
+index b90057c..995e44b 100644
+--- a/client/src/pmpi_wrappers.h
++++ b/client/src/pmpi_wrappers.h
+@@ -15,6 +15,8 @@
+ #ifndef UNIFYFS_PMPI_WRAPPERS_H
+ #define UNIFYFS_PMPI_WRAPPERS_H
+ 
++#include <mpi.h>
++
+ /* MPI_Init PMPI wrapper */
+ int unifyfs_mpi_init(int* argc, char*** argv);
+ int MPI_Init(int* argc, char*** argv);
diff --git a/var/spack/repos/builtin/packages/unifyfs/package.py b/var/spack/repos/builtin/packages/unifyfs/package.py
index 044f8782b3..77b4014741 100644
--- a/var/spack/repos/builtin/packages/unifyfs/package.py
+++ b/var/spack/repos/builtin/packages/unifyfs/package.py
@@ -28,7 +28,6 @@ class Unifyfs(AutotoolsPackage):
     variant('pmi', default='False', description='Enable PMI2 build options')
     variant('pmix', default='False', description='Enable PMIx build options')
 
-    depends_on('openssl')
     depends_on('autoconf',  type='build')
     depends_on('automake',  type='build')
     depends_on('libtool',   type='build')
@@ -44,6 +43,7 @@ class Unifyfs(AutotoolsPackage):
     depends_on('margo')
     depends_on('mercury+bmi+sm')
     depends_on('mpi')
+    depends_on('openssl')
 
     # Optional dependencies
     depends_on('hdf5', when='+hdf5')
@@ -54,6 +54,10 @@ class Unifyfs(AutotoolsPackage):
     conflicts('%intel', when='+fortran')
     conflicts('%xl', when='+fortran')
 
+    # Fix broken --enable-mpi-mount config option for version 0.9.0
+    # See https://github.com/LLNL/UnifyFS/issues/467
+    patch('auto-mount.patch', when='@0.9.0')
+
     # Parallel disabled to prevent tests from being run out-of-order when
     # installed with the --test={root, all} option.
     parallel = False
-- 
GitLab