frasercrmck wrote:

> Yes, the article you link to is highly relevant. Without this PR we're 
> hitting the problem described in example #4.
> 
> We can promote the issue to a build failure by choosing a custom command 
> which can't run concurrently with itself:
> 
> ```cmake
> cmake_minimum_required(VERSION 3.2)
> 
> add_custom_command(
>     OUTPUT gen
>     # Try to grab a lock and fail immediately if we can't:
>     COMMAND flock -x -n gen.lock sleep 1
>     COMMAND cmake -E echo Hello > gen
>     )
> 
> add_custom_target(
>     my-all-1 ALL DEPENDS gen
>     )
> 
> add_custom_target(
>     my-all-2 ALL DEPENDS gen
>     )
> ```
> 
> With the above `make` will succeed, but `make -j2` will fail. The issue is 
> not exposed with Ninja. This is the same behavior I see in libclc today, 
> except more jobs are needed. Adding an intermediate target and depending on 
> both the new target and the file does seem to fix all of our problems.
> 
> I've added the file dependencies back in 
> [b707fc7](https://github.com/llvm/llvm-project/commit/b707fc7dea2e5e57bc3e4f01e27b9ca7bbf0e398),
>  and I think it fixes the build issue while preserving the incremental build 
> behavior you described. Could you please give it a try?

Brilliant, thanks. I have played around and see that incremental builds appear 
to work as intended. I've tried deleting and `touch`ing various files and full 
rebuilds and partial rebuilds do what I'd expect.

Thanks also for pointing out I've already read about this exact issue (example 
#4) and missed it! It's a real shame there isn't a better framework for testing 
CMake and build generators themselves.

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

Reply via email to