Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed clang Release+Asserts dir cleanup may lead to incorrect headers being used remotely #15

Open
goodov opened this issue Sep 12, 2024 · 0 comments

Comments

@goodov
Copy link
Contributor

goodov commented Sep 12, 2024

This logic may choose an incorrect clang directory if gclient sync fails to remove an old directory:

# Find "include" directory inside clang installation. This directory
# will be symlinked by remote wrapper for cross-compilation to work. The
# path is clang-version dependent, so don't hardcode it.
clang_include_dir_glob = glob.glob(
f'{Paths.clang_base_path}/lib/**/include', recursive=True)
if not clang_include_dir_glob:
raise RuntimeError(
f'Cannot find lib/**/include dir in {Paths.clang_base_path}. '
f'If clang directory structure has changed, please update '
f'{Paths.abspath(__file__)} and {template_file} if required.')
clang_include_dir_abs = Paths.normpath(clang_include_dir_glob[0])
assert os.path.isdir(clang_include_dir_abs), clang_include_dir_abs
clang_include_dir = Paths.relpath(clang_include_dir_abs,
Paths.build_dir)
linux_clang_include_dir = Paths.relpath(
clang_include_dir_abs.replace(Paths.clang_base_path,
Paths.linux_clang_base_path),
Paths.build_dir)

This leads to clang_remote_wrapper trying to run a compiler with a symlink pointing nowhere, i.e. instead of:

clang_include_dir="../../third_party/llvm-build/Release+Asserts/lib/clang/20/include"
linux_clang_include_dir="../../third_party/llvm-build/Release+Asserts_linux/lib/clang/20/include"

we get:

clang_include_dir="../../third_party/llvm-build/Release+Asserts/lib/clang/19/include"
linux_clang_include_dir="../../third_party/llvm-build/Release+Asserts_linux/lib/clang/19/include"

A more robust approach is to search for the lib/**/include directory remotely and symlink it right in the clang_remote_wrapper script.

Another approach is to sort found directories and choose the last one instead of the first one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant