Skip to content

LLVM_RUNTIME_TARGETS option #137018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ye-luo opened this issue Apr 23, 2025 · 4 comments
Open

LLVM_RUNTIME_TARGETS option #137018

ye-luo opened this issue Apr 23, 2025 · 4 comments
Assignees
Labels
cmake Build system in general and CMake in particular

Comments

@ye-luo
Copy link
Contributor

ye-luo commented Apr 23, 2025

LLVM_ prefix makes it sounds like global in the whole LLVM build.
Searching the code base
https://github.com/search?q=repo%3Allvm%2Fllvm-project%20LLVM_RUNTIME_TARGETS&type=code
indicates that is an option per runtime.

If I'm building 3 runtime -DLLVM_ENABLE_RUNTIMES="a;b;c"
however, if a only supports arch1 and arch2, b only support arch3, c supports arch1 and arc3,
I'm not sure how I should use LLVM_RUNTIME_TARGETS option
and what happens if I put -DLLVM_RUNTIME_TARGETS="arch1;arch2;arch3"

#136729 mentioned additional variables to control the resolution

    -DLLVM_RUNTIME_TARGETS='default;amdgcn-amd-amdhsa;nvptx64-nvidia-cuda'     \
    -DRUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES=openmp \
    -DRUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES=openmp

I found it cumbersome.

Instead, I'd like to see

    -DLLVM_ENABLE_RUNTIMES=openmp \
    -DRUNTIME_openmp_TARGETS="nvptx64-nvidia-cuda" # to select a subset if added

In short, I prefer the runtime name as the primary key rather than its supported targets in the user facing CMake options.

@jhuber6
Copy link
Contributor

jhuber6 commented Apr 23, 2025

This is something I'd need to discuss with @petrhosek. Right now LLVM_RUNTIME_TARGETS enables the targets, which then lets you enable them individually. default is kind of a weird special case I'm hoping we could improve later. So, basically -DLLVM_RUNTIME_TARGETS=a;b;c will enable separate runtimes builds with --target=a and so forth. You pass arguments to these invocations manually with -DRUNTIMES_a_<option> so, to set the runtimes list you do -DRUNTIMES_a_LLVM_ENABLE_RUNTIMES=openmp.

The normal -DLLVM_ENABLE_RUNTIMES is kind of a legacy thing that only applies to the default target. I think we should probably improve this, but I'd need to have a longer discussion. I have #136591 which (somewhat) tries to improve that, but it's broken currently.

@jhuber6
Copy link
Contributor

jhuber6 commented Apr 23, 2025

There also really should be some documentation on this. I should spend some time detailing the LLVM runtime build.

@EugeneZelenko EugeneZelenko added cmake Build system in general and CMake in particular and removed new issue labels Apr 23, 2025
@ye-luo
Copy link
Contributor Author

ye-luo commented Apr 23, 2025

Requiring -DRUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES=openmp to turn on openmp runtime is too heavy and unnecessary burden. LLVM_ENABLE_RUNTIMES really should stay. RUNTIMES_<target>_LLVM_ENABLE_RUNTIMES should really be internally derived based on LLVM_ENABLE_RUNTIMES and supported or requested triples if possible.

I also prefer RUNTIME_<runtime>_TARGETS to RUNTIMES_<target>_LLVM_ENABLE_RUNTIMES which can be derived based on RUNTIME_<runtime>_TARGETS.

In addition, the design you mentioned still doesn't allow specifying a compiler option only for a specific runtime on a specific target.
Need something like RUNTIME_openmp_TARGET_a_<option> expanded beyond semi-global options RUNTIME_TARGET_a_<option> for all the runtimes of a give target and RUNTIME_openmp_<option> for all the targets of a given runtime.

All what I described above are user facing option choices not actual CMake handling of their consumption.

@jhuber6
Copy link
Contributor

jhuber6 commented Apr 23, 2025

Requiring -DRUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES=openmp to turn on openmp runtime is too heavy and unnecessary burden. LLVM_ENABLE_RUNTIMES really should stay. RUNTIMES_<target>_LLVM_ENABLE_RUNTIMES should really be internally derived based on LLVM_ENABLE_RUNTIMES and supported or requested triples if possible.

Yeah, it's definitely a little annoying to type out, but this is why we suggest people use CMake cache files if they want a 'default' experience.

I also prefer RUNTIME_<runtime>_TARGETS to RUNTIMES_<target>_LLVM_ENABLE_RUNTIMES which can be derived based on RUNTIME_<runtime>_TARGETS.

In addition, the design you mentioned still doesn't allow specifying a compiler option only for a specific runtime on a specific target. Need something like RUNTIME_openmp_TARGET_a_<option> expanded beyond semi-global options RUNTIME_TARGET_a_<option> for all the runtimes of a give target and RUNTIME_openmp_<option> for all the targets of a given runtime.

There's -DRUNTIMES_<triple>_CMAKE_ARGS="-DFOO;-DBAR" and -DRUNTIMES_<triple>_CMAKE_BUILD_TYPE=Debug for example.

All what I described above are user facing option choices not actual CMake handling of their consumption.

I think the biggest issue is the weirdness between -DLLVM_ENABLE_RUNTIMES and -DRUNTIMES_x86_64-unknown-linux-gnu_LLVM_ENABLE_RUNTIMES for example. They can mean the same thing, but users will find it confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular
Projects
None yet
Development

No branches or pull requests

4 participants