[libclc] [libclc] Move __clc_ldexp to CLC library (PR #126078)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 13 05:09:53 PST 2025


jhuber6 wrote:



> I think the correct place is the clang resource directory

Tough to say, the compiler resource directory is for things the compiler emits as a part of the language, yet we don't store `libomp` there. I'd say it makes sense, if you had `lib/clang/21/lib/amdgcn-amd-amdhsa/libclang_rt.clc.a` it would be in-line with things like builtins and instrumentation.

> Regarding triples, libclc doesn't currently have a `amdgcn-amd-amdhsa` target, per se. It's got `amdgcn--` or `amdgcn--amdhsa`. Again I don't know how the runtimes triples work and how strict the triple matching would be or if libclc would have to massage triples into its own internal set. If a triple isn't found, like `x86_64-unknown-linux-gnu` is it silently ignored, warned, errored?

Yeah, `amdgcn-amd-amdhsa` should be roughly equivalent to `amdgcn--`. The one problem I see is that if we do the per-target install directories, then `amdgcn--` and `amdgcn-amd-amdhsa` will have different directories. I wonder if we could just unify those somehow, or just accept `amdgcn-amd-amdhsa` in `libclc` as the same thing.

> Oh, also for context, there was #124709 a few weeks ago. So it appears that there are other people interested in moving libclc to the runtimes infrastructure.

Yep, part of why I'm bringing it up. So, the runtimes build is basically a CMake [ExternalProject](https://cmake.org/cmake/help/latest/module/ExternalProject.html) that points to the project. The file `./runtimes/CMakeLists.txt` is the entry point for that build. So, the `llvm/runtimes/CMakeListst.txt` basically creates sub-jobs by pointing them to `./runtimes/CMakeLists.txt`. This is mostly helpful because it guarantees you're going to be using an up-to-date clang compiler for the build.

Right now what `libclc` does would be pretty easy to port to a normal `LLVM_ENABLE_RUNTIMES=libclc` build, because we currently create a few jobs and compile them with `--target=`. So, that should likely still work. You can also do cross-compiling through the runtimes interface, which is my request. So likely we'd have `LLVM_ENABLE_RUNTIMES=libclc` work as it does now, But also for `-DRUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES=libclc` to basically just enable `amdgcn--` currently.

I have an unfortunate amount of experience mangling the runtimes builds, so if you need help feel free to ask.

https://github.com/llvm/llvm-project/pull/126078


More information about the cfe-commits mailing list