Skip to content

Commit

Permalink
Always use clang from Xcode toolchain as default compiler
Browse files Browse the repository at this point in the history
iOS tests should always be executed with Apple Clang.
  • Loading branch information
antoniofrighetto committed Jul 24, 2024
1 parent 0ba3907 commit db36845
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,19 @@

# The tools directory defaults to LLVM_BINARY_DIR. In order to run tests with a different compiler,
# pass the installation base path via LLVM_TOOLS_DIR at configuration time explicitly.
print("Running tests with:", os.path.join(config.llvm_tools_dir, 'clang'))
llvm_config.add_tool_substitutions(["clang", "clang++"], config.llvm_tools_dir)
# For iOS tests, always use Apple Clang as default compiler.
if sys.platform == 'darwin':
try:
xcode_path = subprocess.check_output(['xcode-select', '-p'], stderr=subprocess.PIPE).strip().decode()
compiler_dir_path = os.path.join(xcode_path, 'Toolchains/XcodeDefault.xctoolchain/usr/bin')
except (subprocess.CalledProcessError, OSError):
print("xcode-select not found. Please install Xcode.")
exit(1)
else:
compiler_dir_path = config.llvm_tools_dir

print("Running tests with:", os.path.join(compiler_dir_path, 'clang'))
llvm_config.add_tool_substitutions(["clang", "clang++"], compiler_dir_path)
llvm_config.add_tool_substitutions(["FileCheck", "count", "not"], config.llvm_tools_dir)

# The plugin is a shared library in our build-tree
Expand Down

0 comments on commit db36845

Please sign in to comment.