Fork, as a thread function, should go in the threads folder.
Additionally, it depends on the thread mutex, and it was causing build
issues for targets where we don't support threads.
Details
- Reviewers
sivachandra lntue - Commits
- rG4d25761b076d: [libc] move fork into threads folder
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I did not go into the specifics of this patch (I am on vacation) but I have concern about it because of the subject:
Fork, as a thread function, should go in the threads folder. Additionally, it depends on the thread mutex, and it was causing build issues for targets where we don't support threads.
Two things:
- Why is fork a thread function?
- If the logic of "it depends on the thread mutex" is applied to other parts of the libc (for example File), they all should be moved into the threads directory.
I meant that the fork_callbacks utility should be moved into the threads folder since it depends on the other utilities in the threads folder and is only used by the pthreads utilities. I think having file be separate makes sense because that's a category that is more specific than threads. The goal is to group similar things so that they can be found, and while I would expect fork related utilities to be in a threads folder, I wouldn't expect file related utilities to be in a threads folder.
I still don't understand - perhaps you are thinking fork is related to threads? Also, can you explain what prompted this change? Was something failing on arm32?
yes, the windows build was failing (and anything else that doesn't have a threads implementation) because the fork_callbacks cmake target was including mutex unconditionally.
The fork callback machinery uses a mutex and is not related to threads. So, the pattern to follow would be this: https://github.com/llvm/llvm-project/blob/main/libc/src/__support/File/CMakeLists.txt#L1. Which is to exclude listing a target if mutex is not available. This patch is essentially doing that, but clubbing fork callbacks machinery with thread machinery is incorrect.
Putting fork_callback inside the target check (without the return part) and adding message Skipping ... with reason similar to unit tests sounds good to me.