[libclc] [CMake][libclc] Improve dependencies to avoid build errors (PR #95018)

Fraser Cormack via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 11 02:02:53 PDT 2024


frasercrmck wrote:

Hmm, isn't CMake fun? Thanks for looking into this.

Unfortunately the file-level dependencies are there for a reason. With this patch, if I `rm builtins.link.nvptx64--.bc` and build `builtins.opt.nvptx64--` (with `ninja`), it builds the `link` target but doesn't actually rebuild the `opt` target. On `main`, it does do this. We need to preserve that behaviour, or developers will see stale builds and that will lead to all sorts of problems.

I found [example #5 of this example](https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands) interesting when I was initially implementing this. CMake's dependencies are really strange.

Going by the documentation you link, could we have _both_ the file- and the target-level dependency? Note how the [example](https://cmake.org/cmake/help/v3.29/command/add_custom_command.html#example-generating-files-for-multiple-targets) has `DEPENDS table.csv generate_table_csv` in *both* parallel targets, so the file-level dependency `foo.csv` *is* being used twice - but also supplying the target-level dependency prevents it from being a race condition?

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


More information about the cfe-commits mailing list