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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 19 23:17:58 PST 2023


MaskRay added inline comments.


================
Comment at: lld/Common/Args.cpp:95
+
+void lld::args::skipFrontArgs(ArrayRef<const char *> &args) {
+  args = args.drop_front(1); // skip argv[0]
----------------
This code introduces a new function. We can strip `-flavor` near `whichDriver` or its caller to move all `-flavor` handling to a single place and avoid polluting the common code.


================
Comment at: lld/Common/DriverDispatcher.cpp:159
+                  llvm::ArrayRef<DriverDef> drivers, bool exitEarly) {
+
+  // Run the driver. If an error occurs, false will be returned.
----------------
delete blank line


================
Comment at: lld/Common/DriverDispatcher.cpp:162
+  Driver d = whichDriver(args, drivers);
+  int r = !d(args, stdoutOS, stderrOS, exitEarly, inTestOutputDisabled);
+
----------------
`d(...)` returns a `bool`, not an `int`. `exitLld(r)` passes the bool to `CrashRecoveryContext::throwIfCrash` (`isCrash` expects an exit code) which seems incorrect.


================
Comment at: lld/unittests/AsLibAll/AllDrivers.cpp:16
+
+LLD_HAS_DRIVER(coff);
+LLD_HAS_DRIVER(elf);
----------------
`warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]`


================
Comment at: lld/unittests/AsLibELF/ROCm.cpp:36
+
+LLD_HAS_DRIVER(elf);
+
----------------
`warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]`


================
Comment at: lld/unittests/AsLibELF/SomeDrivers.cpp:17
+
+LLD_HAS_DRIVER(elf);
+
----------------
`warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]`


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