Skip to content

Commit bafa22b

Browse files
authored
Prevent users setting CHPL_LLVM_CONFIG to a bad value (#29036)
Adds a check to prevent users setting CHPL_LLVM_CONFIG to a bad value, resulting in confusing errors later. For example, if a user set `CHPL_LLVM_CONFIG=$(which llvm-config)`, they would expect it to work. But if that llvm is too old, they could get strange errors that do not tell them what actually went wrong (and might look like a bug in Chapel). Or, a user could set `CHPL_LLVM_CONFIG` to some garbage value. Fixed by just validating `CHPL_LLVM_CONFIG` with a quick check that it exists and is the correct version. Full validation is done at a later step. [Reviewed by @arifthpe]
2 parents 573196c + edb27f5 commit bafa22b

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

util/chplenv/chpl_llvm.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,13 @@ def check_llvm_packages(llvm_config):
279279
def find_system_llvm_config():
280280
llvm_config = overrides.get("CHPL_LLVM_CONFIG", "none")
281281
if llvm_config != "none":
282+
_, config_err = check_llvm_config(llvm_config)
283+
if config_err:
284+
error(
285+
"Problem with llvm-config at {0} -- {1}".format(
286+
llvm_config, config_err
287+
)
288+
)
282289
return llvm_config
283290

284291
llvm_config = chpl_gpu.get_llvm_override()
@@ -377,6 +384,16 @@ def get_llvm_config():
377384
if llvm_val == "system" or llvm_support_val == "system":
378385
llvm_config = find_system_llvm_config()
379386

387+
else:
388+
# check that the provided llvm-config is valid
389+
_, config_err = check_llvm_config(llvm_config)
390+
if config_err:
391+
error(
392+
"Problem with llvm-config at {0} -- {1}".format(
393+
llvm_config, config_err
394+
)
395+
)
396+
380397
return llvm_config
381398

382399

0 commit comments

Comments
 (0)