From f237c81060b81a7ac9e58b3ad9ce1b83808cc75d Mon Sep 17 00:00:00 2001
From: "Seth R. Johnson" <johnsonsr@ornl.gov>
Date: Tue, 2 Apr 2019 20:34:25 -0400
Subject: [PATCH] openmpi: Add stub mpirun script for
 openmpi~legacylaunchers+slurm (#11059)

This adds a stub script for mpirun and other standard executables
when installing OpenMPI with slurm. The purpose is to make the
removal less of a surprise to administrators/users: it explains why
they were removed and how to restore them.
---
 .../repos/builtin/packages/openmpi/nolegacylaunchers.sh  | 9 +++++++++
 var/spack/repos/builtin/packages/openmpi/package.py      | 4 ++++
 2 files changed, 13 insertions(+)
 create mode 100755 var/spack/repos/builtin/packages/openmpi/nolegacylaunchers.sh

diff --git a/var/spack/repos/builtin/packages/openmpi/nolegacylaunchers.sh b/var/spack/repos/builtin/packages/openmpi/nolegacylaunchers.sh
new file mode 100755
index 0000000000..b6defd69f0
--- /dev/null
+++ b/var/spack/repos/builtin/packages/openmpi/nolegacylaunchers.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+echo "This version of Spack (openmpi ~legacylaunchers schedulers=slurm) "
+echo "is installed without the mpiexec/mpirun commands to prevent "
+echo "unintended performance issues. See https://github.com/spack/spack/pull/10340 "
+echo "for more details."
+echo "If you understand the potential consequences of a misconfigured `mpirun`, you can"
+echo "use spack to install `openmpi+legacylaunchers` to restore the executables."
+echo "Otherwise, use `srun` to launch your MPI executables."
+exit 2
diff --git a/var/spack/repos/builtin/packages/openmpi/package.py b/var/spack/repos/builtin/packages/openmpi/package.py
index dd8d313694..bdc1626c06 100644
--- a/var/spack/repos/builtin/packages/openmpi/package.py
+++ b/var/spack/repos/builtin/packages/openmpi/package.py
@@ -484,8 +484,12 @@ def delete_mpirun_mpiexec(self):
                         self.prefix.bin.shmemrun,
                         self.prefix.bin.oshrun
                         ]
+            script_stub = join_path(os.path.dirname(__file__),
+                                    "nolegacylaunchers.sh")
             for exe in exe_list:
                 try:
                     os.remove(exe)
                 except OSError:
                     tty.debug("File not present: " + exe)
+                else:
+                    copy(script_stub, exe)
-- 
GitLab