From d5bbe7d3482ba55abb957385fdd92f7ad11f6b8c Mon Sep 17 00:00:00 2001
From: Sergey Kosukhin <sergey.kosukhin@mpimet.mpg.de>
Date: Thu, 18 Apr 2019 08:45:07 +0200
Subject: [PATCH] Give the compiler a chance to clean its temporary files when
 requesting its version at the configure time.

---
 configure.ac | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 14154c18f..f4eb9fb09 100644
--- a/configure.ac
+++ b/configure.ac
@@ -115,7 +115,15 @@ case "$CC" in
   clang*) COMP_VERSION=`$CC --version | head -n 1`;;
   sxc*)   COMP_VERSION=`$CC -V 2>&1   | tail -n 1`;;
   xlc*)   COMP_VERSION=`$CC -qversion 2>&1   | head -n 1`;;
-  *)      COMP_VERSION=`$CC -V 2>&1   | head -n 1`;;
+  *)
+     # 'head -n 1' exits after printing the first line, which closes the pipe
+     # and kills the compiler's process leaving it no chance to clean any
+     # temporary files it might have created (e.g. Intel compiler creates
+     # 'a.out' when it is called with additional flags like -I, -L, etc.,
+     # which is the case when $CC is an MPI wrapper). Therefore, we have to
+     # run the processes one after another:
+     COMP_VERSION=`$CC -V 2>&1`
+     COMP_VERSION=`echo "$COMP_VERSION" | head -n 1` ;;
 esac
 
 if test -z "$COMP_VERSION" ; then COMP_VERSION="unknown"; fi;
-- 
GitLab