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:"):