From 4eb54b6358c5825d69558662d0ef1787e75a24ab Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Fri, 13 Dec 2019 17:01:45 -0800 Subject: bugfix: `pgcc -V` returns 2 on power machines `pgcc -V` was failing on power machines because it returns 2 (despite correctly printing version information). On x86_64 machines the same command returns 0 and doesn't cause an error. - [x] Ignore return value of 2 for pgcc when doign a version check --- lib/spack/spack/compiler.py | 11 ++++++++--- lib/spack/spack/compilers/pgi.py | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index f2b62dc3f9..1a6b33af0c 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -32,7 +32,7 @@ def _verify_executables(*paths): @llnl.util.lang.memoized -def get_compiler_version_output(compiler_path, version_arg): +def get_compiler_version_output(compiler_path, version_arg, ignore_errors=()): """Invokes the compiler at a given path passing a single version argument and returns the output. @@ -41,7 +41,8 @@ def get_compiler_version_output(compiler_path, version_arg): version_arg (str): the argument used to extract version information """ compiler = spack.util.executable.Executable(compiler_path) - output = compiler(version_arg, output=str, error=str) + output = compiler( + version_arg, output=str, error=str, ignore_errors=ignore_errors) return output @@ -199,6 +200,9 @@ class Compiler(object): #: Compiler argument that produces version information version_argument = '-dumpversion' + #: Return values to ignore when invoking the compiler to get its version + ignore_version_errors = () + #: Regex used to extract version from compiler's output version_regex = '(.*)' @@ -412,7 +416,8 @@ class Compiler(object): @classmethod def default_version(cls, cc): """Override just this to override all compiler version functions.""" - output = get_compiler_version_output(cc, cls.version_argument) + output = get_compiler_version_output( + cc, cls.version_argument, tuple(cls.ignore_version_errors)) return cls.extract_version_from_output(output) @classmethod diff --git a/lib/spack/spack/compilers/pgi.py b/lib/spack/spack/compilers/pgi.py index 90560f7c63..2798210bca 100644 --- a/lib/spack/spack/compilers/pgi.py +++ b/lib/spack/spack/compilers/pgi.py @@ -30,6 +30,7 @@ class Pgi(Compiler): PrgEnv_compiler = 'pgi' version_argument = '-V' + ignore_version_errors = [2] # `pgcc -V` on PowerPC annoyingly returns 2 version_regex = r'pg[^ ]* ([0-9.]+)-[0-9]+ (LLVM )?[^ ]+ target on ' @classmethod -- cgit v1.2.3-70-g09d2