From 58d5b73ba4111ee1abd9d668086b2b2aa17fcf16 Mon Sep 17 00:00:00 2001 From: Thomas Green Date: Fri, 15 Jan 2021 08:22:58 +0000 Subject: [PATCH] Improve gcc detection in llvm. (#20189) Co-authored-by: Tom Scogland Co-authored-by: Thomas Green --- var/spack/repos/builtin/packages/llvm/package.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py index 14433c1aa1..1f9f4c8313 100644 --- a/var/spack/repos/builtin/packages/llvm/package.py +++ b/var/spack/repos/builtin/packages/llvm/package.py @@ -499,7 +499,16 @@ def cmake_args(self): cmake_args.append("-DLIBOMP_TSAN_SUPPORT=ON") if self.compiler.name == "gcc": - gcc_prefix = ancestor(self.compiler.cc, 2) + compiler = Executable(self.compiler.cc) + gcc_output = compiler('-print-search-dirs', output=str, error=str) + + for line in gcc_output.splitlines(): + if line.startswith("install:"): + # Get path and strip any whitespace + # (causes oddity with ancestor) + gcc_prefix = line.split(":")[1].strip() + gcc_prefix = ancestor(gcc_prefix, 4) + break cmake_args.append("-DGCC_INSTALL_PREFIX=" + gcc_prefix) if spec.satisfies("@4.0.0:"):