Improve gcc detection in llvm. (#20189)

Co-authored-by: Tom Scogland <tom.scogland@gmail.com>
Co-authored-by: Thomas Green <ca-tgreen@gw4a64fxlogin00.head.gw4.metoffice.gov.uk>
This commit is contained in:
Thomas Green 2021-01-15 08:22:58 +00:00 committed by GitHub
parent 56904d5834
commit 58d5b73ba4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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