[PATCH] D119049: [LLD] Allow usage of LLD as a library

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 20 15:07:17 PST 2023


aganea added inline comments.


================
Comment at: lld/Common/DriverDispatcher.cpp:162
+  Driver d = whichDriver(args, drivers);
+  int r = !d(args, stdoutOS, stderrOS, exitEarly, inTestOutputDisabled);
+
----------------
MaskRay wrote:
> `d(...)` returns a `bool`, not an `int`. `exitLld(r)` passes the bool to `CrashRecoveryContext::throwIfCrash` (`isCrash` expects an exit code) which seems incorrect.
Actually the bool to int conversion is correct. The drivers and thus `d` returns false on error, true on success. We invert the result and that makes `r` equal 1 on error, and 0 on success, which is the value that will be returned by the application. `throwIfCrash` will be really useful when getting back from the `CrashRecoveryHandler` below in `lld::lldMain`, but on this particular codepath in `unsafeLldMain` that will never be hit.
I've added an extra comment to clarify. Please let me know if you think more should be done.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119049/new/

https://reviews.llvm.org/D119049



More information about the llvm-commits mailing list