git: 184e7a37179e - stable/12 - Reapply r327026 (partially):

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Wed, 22 Dec 2021 10:05:33 UTC
The branch stable/12 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=184e7a37179eb1693fc3d40feaf7da9062d0791c

commit 184e7a37179eb1693fc3d40feaf7da9062d0791c
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2020-08-02 18:34:29 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-12-22 09:58:14 +0000

    Reapply r327026 (partially):
    
    Merge lld trunk r321017 to contrib/llvm/tools/lld.
    
    (Note that in this merge, I foolishly combined upstream changes with
    this local change. But only this ifdef part is really needed, as we
    always default to ELF link mode.)
    
    (cherry picked from commit 59948e95d8deadafca3acd659b6dfc78b708f117)
---
 contrib/llvm-project/lld/tools/lld/lld.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/contrib/llvm-project/lld/tools/lld/lld.cpp b/contrib/llvm-project/lld/tools/lld/lld.cpp
index 8a8f8d04bbda..c1a117e9cc3e 100644
--- a/contrib/llvm-project/lld/tools/lld/lld.cpp
+++ b/contrib/llvm-project/lld/tools/lld/lld.cpp
@@ -142,6 +142,9 @@ int main(int argc, const char **argv) {
   InitLLVM x(argc, argv);
 
   std::vector<const char *> args(argv, argv + argc);
+#ifdef __FreeBSD__
+  return !elf::link(args, canExitEarly(), llvm::outs(), llvm::errs());
+#else
   switch (parseFlavor(args)) {
   case Gnu:
     if (isPETarget(args))
@@ -160,4 +163,5 @@ int main(int argc, const char **argv) {
         "Invoke ld.lld (Unix), ld64.lld (macOS), lld-link (Windows), wasm-ld"
         " (WebAssembly) instead");
   }
+#endif
 }