Skip to content

Commit

Permalink
Remove xcrun-based clang finding
Browse files Browse the repository at this point in the history
Not needed, since clangd will just discover the system default one way or another.
  • Loading branch information
cpsauer committed Dec 5, 2022
1 parent 1f154d0 commit a797a78
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions refresh.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,17 +685,6 @@ def _get_apple_DEVELOPER_DIR():
# Traditionally stored in DEVELOPER_DIR environment variable, but not provided by Bazel. See https://github.com/bazelbuild/bazel/issues/12852


@functools.lru_cache(maxsize=None)
def _get_apple_active_clang():
"""Get path to xcode-select'd clang version."""
return subprocess.check_output(
('xcrun', '--find', 'clang'),
stderr=subprocess.DEVNULL, # Suppress superfluous error messages like "Requested but did not find extension point with identifier..."
encoding=locale.getpreferredencoding()
).rstrip()
# Unless xcode-select has been invoked (like for a beta) we'd expect, e.g., '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' or '/Library/Developer/CommandLineTools/usr/bin/clang'.


def _apple_platform_patch(compile_args: typing.List[str]):
"""De-Bazel the command into something clangd can parse.
Expand All @@ -707,7 +696,7 @@ def _apple_platform_patch(compile_args: typing.List[str]):
# Undo Bazel's Apple platform compiler wrapping.
# Bazel wraps the compiler as `external/local_config_cc/wrapped_clang` and exports that wrapped compiler in the proto. However, we need a clang call that clangd can introspect. (See notes in "how clangd uses compile_commands.json" in ImplementationReadme.md for more.)
# Removing the wrapper is also important because Bazel's Xcode (but not CommandLineTools) wrapper crashes if you don't specify particular environment variables (replaced below). We'd need the wrapper to be invokable by clangd's --query-driver if we didn't remove the wrapper.
compile_args[0] = _get_apple_active_clang()
compile_args[0] = 'clang'

# We have to manually substitute out Bazel's macros so clang can parse the command
# Code this mirrors is in https://github.com/bazelbuild/bazel/blob/master/tools/osx/crosstool/wrapped_clang.cc
Expand Down

0 comments on commit a797a78

Please sign in to comment.