This is an archive of the discontinued LLVM Phabricator instance.

[Support] Avoid wait4 on Fuchsia
ClosedPublic

Authored by phosek on Jul 20 2023, 12:51 AM.

Details

Summary

Fuchsia doesn't provide wait4.

Diff Detail

Event Timeline

phosek created this revision.Jul 20 2023, 12:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2023, 12:51 AM
phosek requested review of this revision.Jul 20 2023, 12:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2023, 12:51 AM

What is implementing waitpid there? I'm not aware of any Fuchsia implementation of that API. The function in libc is an ENOSYS stub. If there were an emulation implementation of waitpid, there could as well be one for wait4 since some of the information analogous to struct rusage is accessible by other means on Fuchsia. But since there isn't AFAIK any waitpid et al that is actually useful on Fuchsia today, I'm a bit confused by this change. It seems like perhaps it's just getting something to compile and link that doesn't actually work. IMHO unless and until we provide a more full posix_spawn+wait* emulation library for Fuchsia--and perhaps even if we had one--the LLVM support should probably use the more direct Fuchsia mechanisms instead. For spawning subprocesses, that means fdio_spawn and then the direct Zircon syscall APIs to wait for process termination.

phosek updated this revision to Diff 543340.Jul 23 2023, 5:34 PM
phosek edited the summary of this revision. (Show Details)

What is implementing waitpid there? I'm not aware of any Fuchsia implementation of that API. The function in libc is an ENOSYS stub. If there were an emulation implementation of waitpid, there could as well be one for wait4 since some of the information analogous to struct rusage is accessible by other means on Fuchsia. But since there isn't AFAIK any waitpid et al that is actually useful on Fuchsia today, I'm a bit confused by this change. It seems like perhaps it's just getting something to compile and link that doesn't actually work. IMHO unless and until we provide a more full posix_spawn+wait* emulation library for Fuchsia--and perhaps even if we had one--the LLVM support should probably use the more direct Fuchsia mechanisms instead. For spawning subprocesses, that means fdio_spawn and then the direct Zircon syscall APIs to wait for process termination.

I'm aware that this implementation is not usable, right now the goal is just to make it compile to enable uses of other parts of LLVM that don't need this functionality (for example the DWARF parsing). I intend to replace all of this with native Fuchsia implementation in subsequent changes. For now I simplified this patch to avoid wait4 and waitpid altogether.

mcgrathr accepted this revision.Jul 26 2023, 4:14 PM

Fuchsia also doesn't actually provide wait or waitpid, so some more comments to that effect at least in the log would be useful. It also doesn't have signals, so the calls earlier in the function won't actually do anything.
It probably makes more sense to just define llvm::sys::Wait so that it always fails without any real implementation contents under #ifdef __Fuchsia__.

llvm/lib/Support/Unix/Program.inc
465

Probably makes sense to set ProcStat->reset(); rather than not touching the output when we have no data.

This revision is now accepted and ready to land.Jul 26 2023, 4:14 PM
This revision was automatically updated to reflect the committed changes.