Skip to content

Commit 7f791e2

Browse files
authored
ccache detection: Don't crash if compiler isn't a symlink
1 parent a8fb908 commit 7f791e2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

refresh.template.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -760,13 +760,17 @@ def _all_platform_patch(compile_args: typing.List[str]):
760760
new_compile_args.append(arg)
761761
compile_args = new_compile_args
762762

763-
# replace ccache with the actual compiler
764-
compiler_path = os.readlink(compile_args[0])
765-
if compiler_path.endswith("ccache"):
766-
compiler = os.path.basename(compile_args[0])
767-
real_compiler_path = shutil.which(compiler)
768-
if real_compiler_path:
769-
compile_args[0] = real_compiler_path
763+
# Discover compilers that are actually symlinks to ccache--and replace them with the underlying compiler
764+
try:
765+
compiler_path = os.readlink(compile_args[0])
766+
except OSError:
767+
pass
768+
else:
769+
if compiler_path.endswith("ccache"):
770+
compiler = os.path.basename(compile_args[0])
771+
real_compiler_path = shutil.which(compiler)
772+
if real_compiler_path:
773+
compile_args[0] = real_compiler_path
770774

771775
# Any other general fixes would go here...
772776

0 commit comments

Comments
 (0)