Skip to content

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

@goodov

Description

@goodov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions