[PATCH] D70378: [LLD][COFF] Cover usage of LLD as a library

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 15:43:02 PDT 2020


MaskRay added a comment.

Thanks for working on this. I think making `lldMain` "reentrancy safe" is useful.

Printing `LLD_IN_TEST (new LLD session)` can disturb tests with `-NOT:` CHECK lines (~20 test/ELF tests failed due to this problem). I suggest we do it only when `--verbose` (port specific; inside coff::link, elf::link, ...) is specified. Alternatively, is it possible to suppress output for the previous N-1 invocations of `lldMain`?

I noticed a problem in `llvm::timeTraceProfilerInitialize`.

I just fixed an ELF problem related to  `InputFile::isInGroup` (b358daddea04ea3c52e0e5bd5e851cee47f7f27f <https://reviews.llvm.org/rGb358daddea04ea3c52e0e5bd5e851cee47f7f27f>)



================
Comment at: lld/test/COFF/guardcf-lto.ll:11
 ; RUN: llvm-as %s -o %t.bc
-; RUN: lld-link -entry:main -guard:cf -dll %t.bc %t.lib %t.ldcfg.obj -out:%t.dll
-; RUN: llvm-readobj --coff-load-config %t.dll | FileCheck %s
+; RUN: lld-link -entry:main -guard:cf -dll %t.bc %t.lib %t.ldcfg.obj -out:%t2.dll
+; RUN: llvm-readobj --coff-load-config %t2.dll | FileCheck %s
----------------
Why can't `%t.ll` be used?


================
Comment at: lld/tools/lld/lld.cpp:134
+static unsigned inTestVerbosity() {
+  unsigned V{};
+  StringRef(getenv("LLD_IN_TEST")).getAsInteger(10, V);
----------------
`= 0`


================
Comment at: lld/tools/lld/lld.cpp:174
+  Optional<int> ret;
+  unsigned i = inTestVerbosity() > 0 ? inTestVerbosity() : 1;
+  while (i-- > 0) {
----------------
Probably int to avoid unsigned underflow

or `for (; i > 0; --i) {`


================
Comment at: lld/tools/lld/lld.cpp:185
+      assert(r == *ret);
+    cl::ResetAllOptionOccurrences();
+  }
----------------
Not all ports support `-mllvm` or similar options. This should be moved into individual ports, right before cl::Parse* is called.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70378



More information about the llvm-commits mailing list