Skip to content

Commit

Permalink
Avoid Overriding Clang Sysroot (#26761)
Browse files Browse the repository at this point in the history
If clang is already set up with a config file that has some of these
options we should avoid overriding them.

[contributed by @insertinterestingnamehere, reviewed and merged by @jabraham17]
  • Loading branch information
jabraham17 authored Feb 27, 2025
2 parents 325debc + 9e19351 commit 6542f57
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions util/chplenv/chpl_llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,11 @@ def _determine_gcc_flag_to_use():

return flag_to_use

@memoize
def _get_clang_cfg_args(clang_command):
clang_cfg = get_clang_cfg_file(clang_command)
return parse_clang_cfg_file(clang_cfg)

# On some systems, we need to give clang some arguments for it to
# find the correct system headers.
# * when PrgEnv-gnu is loaded on an XC, we should provide
Expand All @@ -942,11 +947,17 @@ def _determine_gcc_flag_to_use():
def get_clang_basic_args(clang_command):
clang_args = [ ]

# Check that the clang configure file doesn't already supply
# info about the sysroot or gcc install so we don't end up overriding it.
clang_cfg_args = _get_clang_cfg_args(clang_command)
if (any(arg.startswith("--sysroot") for arg in clang_cfg_args) or
any(arg.startswith("--gcc-install-dir") for arg in clang_cfg_args) or
any(arg.startswith("--gcc-toolchain") for arg in clang_cfg_args)):
return clang_args

@memoize
def _get_gcc_prefix_dir():
# read the args that clang will use by default from the config file
clang_cfg = get_clang_cfg_file(clang_command)
clang_cfg_args = parse_clang_cfg_file(clang_cfg)
return get_gcc_prefix_dir(clang_cfg_args)

gcc_prefix_flags = {
Expand Down

0 comments on commit 6542f57

Please sign in to comment.