[llvm-dev] compiler-rt suspect race condition in add_custom_command

Ken Cunningham via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 5 17:29:29 PDT 2021


On MacPorts we are seeing intermittent error reports from some users when
building compiler-rt from clang-12 using parallel builds on faster machines.

<https://trac.macports.org/ticket/63085>

CMake Error: failed to create symbolic link
'/opt/local/var/macports/build/_Users_blairzajac_Code_MacPorts_macports-ports.git_lang_llvm-12/clang-12/work/build/projects/compiler-rt/lib/builtins/outline_atomic_helpers.dir/outline_atomic_ldset1_2.S':
file already exists

I believe this is due to this add_custom_command invocation:

<
https://github.com/llvm/llvm-project/blob/4c92e31dd0f1bd152eda883af20ff7fbcaa14945/compiler-rt/lib/builtins/CMakeLists.txt#L534
>

I am not a cmake expert, but I believe this issue is covered by cmake here:

"Do not list the output in more than one independent target that may build
in parallel or the two instances of the rule may conflict (instead use the
add_custom_target() command to drive the command and make the other targets
depend on that one)."


<https://cmake.org/cmake/help/v3.19/command/add_custom_command.html>

If so, it seems that the proper solution to this would be to
add_custom_target a dependency on "${helper_asm}", perhaps something like
this?


add_custom_target(compiler-rt-asm ALL DEPENDS ${helper_asm})


I defer now to the cmake experts.


Ken
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210705/653dabbc/attachment.html>


More information about the llvm-dev mailing list