This is an archive of the discontinued LLVM Phabricator instance.

[Support] Modernize process launching API
AbandonedPublic

Authored by aganea on May 23 2019, 2:32 PM.

Details

Summary

As discussed previously, and before adding /MP

The objective here is to stop doing user logic based on process return values, and instead provide a simple process lifetime API. Without this, it is a bit harder to compose programs launching, in order to handle /MP.

The other part of this patch is the explicit llvm::sys::ReturnCodes, which makes it easier to understand/find where LLVM programs return something.

For now I've left there the 'old' API (ie. llvm::sys::ExecuteAndWait, llvm::sys::Wait) which is now superseeded/temporarily.stubbed by the 'new' stateful API (ie. llvm::sys::Program::executeAndWait and llvm::sys::Program::waitCompletion). The plan is however to progressively remove usage of the 'old' API just after this patch is commited. Let me know if you want to see in advance how that looks.

I've tested this patch on several configurations - let me know if I should test more:

  • Windows 10, compiled with MSVC 15.9.11, in Debug, with assertions on.
  • Windows 10, compiled with Clang 8.0, Release, no assertions.
  • WSL / Ubuntu 18.04, compiled with GCC 7.3, Release, no assertions.
  • On a real Ubuntu 18.04 box, compiled with GCC 7.4, Release, no assertions.

Diff Detail

Repository
rL LLVM

Event Timeline

aganea created this revision.May 23 2019, 2:32 PM
$ pbpaste | diffstat
 10 files changed, 497 insertions(+), 276 deletions(-)

The "modernized" api is a good chunk wordier. Can you outline how composing launching would look like with and without this change?

include/llvm/Support/Program.h
68

Do we need so many different failure types? Isn't "Failure" enough?

lib/Support/Unix/Program.inc
180

clang-format

lib/Support/Windows/Program.inc
371

clang-format

405

clang-format

433

Both if and else now end in a return; can move that after the branches

aganea marked 5 inline comments as done.May 24 2019, 12:16 PM

The "modernized" api is a good chunk wordier. Can you outline how composing launching would look like with and without this change?

You're right, I'll reduce it. There are a few unrelated changes that could be done after. I'll have to get back to you regarding the "without this change".

include/llvm/Support/Program.h
68

The API needs at least that many states, that was the goal in the first place - to stop doing 'if's and 'switch'es based on the return value and/or the PID and/or whether there's an ErrorString or not. I'll see if I can simplify.

aganea abandoned this revision.Jan 9 2020, 2:05 PM

Dropping this, I'll just deal with the existing process launching API.