frasercrmck wrote:

> The changes make sense for just adding it, but does it actually work?

Truth be told I haven't grasped exactly how the runtimes system works. This 
"works" in that `-DLLVM_ENABLE_RUNTIMES=libclc` will build all libclc targets 
in, e.g., `build/runtimes/runtimes-bins/libclc/amdgcn--amdhsa.bc` and CMake 
options appear to be passed through to libclc correctly: 
`-DLIBCLC_TARGETS_TO_BUILD=amdgcn--amdhsa` will build only that libclc target.

That said, I don't believe it "works" in the way it's supposed to. It still 
grabs the host tools using `get_host_tool_path` in CMake, and custom commands 
to build with that. I take it we're supposed to use `CMAKE_C_COMPILER` as if we 
were a regular CMake project? Are we able to use `opt` and `llvm-link` and 
other LLVM tools?

> The CMake I've seen in `libclc` does multiple compilations and some with 
> `--target=amdgcn` for example, which is a little different from how the 
> runtimes builds handle it.

Yes the libclc build system is a little quirky. It uses custom commands to 
compile OpenCL C to LLVM IR. This was to allow in-tree builds without requiring 
the compiler to be built before configure time. Now it seems that perhaps, 
ironically, that this is exactly how the runtimes build works and so we might 
be best to undo all of that. It was done partly also as OpenCL C and LLVM IR 
(the two source languages) aren't recognized by CMake as languages and so 
needed some unsafe & undocumented CMake code to get working. I hope we'd be 
able to avoid that.

> Do you have an example of how to actually build this stuff?

I've been using this command to test:

```
cmake -S llvm -B build -G Ninja -DLLVM_ENABLE_ASSERTIONS=ON 
-DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_RUNTIMES="libclc" 
-DLIBCLC_TARGETS_TO_BUILD=amdgcn--amdhsa -DCMAKE_BUILD_TYPE=Release
```

That's about it as far as libclc is concerned. It's not integrated into clang 
and there's no tests for it. That's something I'm hoping to change.

One question you might be able to answer: how can I treat the runtimes build 
more like a "regular" build? For instance `ninja -v` doesn't forward `-v` onto 
the build so I can't inspect what's happening while building libclc. I also 
can't build specific libclc targets such as `ninja prepare-amdgcn--amdhsa.bc`.

https://github.com/llvm/llvm-project/pull/141574
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to