mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Fix compiler check (#120492)
Fixes #119304 1. Add try catch to handle the compiler version check. 2. Retry to query compiler version info. 3. Return False if can't get compiler info twice. Pull Request resolved: https://github.com/pytorch/pytorch/pull/120492 Approved by: https://github.com/ezyang
This commit is contained in:
committed by
PyTorch MergeBot
parent
0f20cc1e0e
commit
3e382456c1
@ -1350,7 +1350,13 @@ def check_compiler_is_gcc(compiler):
|
||||
|
||||
env = os.environ.copy()
|
||||
env['LC_ALL'] = 'C' # Don't localize output
|
||||
version_string = subprocess.check_output([compiler, '-v'], stderr=subprocess.STDOUT, env=env).decode(*SUBPROCESS_DECODE_ARGS)
|
||||
try:
|
||||
version_string = subprocess.check_output([compiler, '-v'], stderr=subprocess.STDOUT, env=env).decode(*SUBPROCESS_DECODE_ARGS)
|
||||
except Exception as e:
|
||||
try:
|
||||
version_string = subprocess.check_output([compiler, '--version'], stderr=subprocess.STDOUT, env=env).decode(*SUBPROCESS_DECODE_ARGS)
|
||||
except Exception as e:
|
||||
return False
|
||||
# Check for 'gcc' or 'g++' for sccache wrapper
|
||||
pattern = re.compile("^COLLECT_GCC=(.*)$", re.MULTILINE)
|
||||
results = re.findall(pattern, version_string)
|
||||
|
Reference in New Issue
Block a user