New Issue: Should LLVM-based compiles be indicated through CHPL_TARGET_COMPILER rather than '--llvm'?

17795, "bradcray", "Should LLVM-based compiles be indicated through CHPL_TARGET_COMPILER rather than '--llvm'?", "2021-05-20T22:27:17Z"

Traditionally, CHPL_TARGET_COMPILER has been used to indicate which C compiler should be used to compile the C code generated by the chpl compiler as well as the runtime and third-party libraries that we link that code against. However, when using the LLVM back-end (by building with CHPL_LLVM!=none and compiling with --llvm, we tend to essentially ignore CHPL_TARGET_COMPILER, using clang-included when CHPL_LLVM == bundled and clang when CHPL_LLVM=system. This can potentially lead to confusion due to having too many options that specify how code is generated and compiled depending on the relative settings of CHPL_TARGET_COMPILER, CHPL_LLVM and the --[no-]llvm flag arguably leading to sources of confusion as have been noted in this Discourse thread or issues Move/remove `clang-included` from the Chapel Docs · Issue #17606 · chapel-lang/chapel · GitHub, Disallow CHPL_TARGET_COMPILER=clang-included when CHPL_LLVM=system · Issue #17598 · chapel-lang/chapel · GitHub, and What does CHPL_HOST_COMPILER=clang-included do? · Issue #17584 · chapel-lang/chapel · GitHub

In this issue, I'm proposing that we unify these settings as follows:

  • CHPL_TARGET_COMPILER:
    • setting this to gnu, intel, clang, etc. would indicate that the C back-end should be used with the specified compiler
    • setting it to llvm would indicate that the LLVM back-end should be used
      • when C code needs to be compiled (e.g., the runtime, third-party libraries, or any .c files specified on the chpl command line or the code's require statements), clang will be used. Similar to today, the bundled version of clang will be used when CHPL_LLVM=bundled and the version in the user's path when CHPL_LLVM=system

This would effectively eliminate the need for the --[no-]llvm flag since the --target-compiler flag would essentially give the same control while reducing confusion about the meaning of CHPL_TARGET_COMPILER in an LLVM-based compilation, as well as the need for clang vs. clang-included as user-facing settings.

  • CHPL_LLVM: this would now say where to get LLVM from in the event that it's needed
    • system: use the system-installed version
    • bundled: use the bundled version
    • none: this would effectively result in an error if CHPL_TARGET_COMPILER were set to llvm
    • unset: the need for this option might be reduced in this world

This would also have the effect of making the CHPL_LLVM flag slightly more like the current CHPL_RE2 and CHPL_GMP variables in the sense of "Someone has requested LLVM (via their CHPL_TARGET_COMPILER or --target-compiler setting), so where should I get it from?"