<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - error library not found"
   href="https://bugs.llvm.org/show_bug.cgi?id=50597">50597</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>error library not found
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>MachO
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>schuett@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>gkm@fb.com, jezreel@gmail.com, llvm-bugs@lists.llvm.org, smeenai@fb.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>On Big Sur I get:
: ld64.lld: error: library not found for -lSystem
          ld64.lld: error: library not found for -lresolv
          ld64.lld: error: library not found for -lc
          ld64.lld: error: library not found for -lm
          ld64.lld: error: library not found for -liconv

I believe the root cause is:

New in macOS Big Sur 11.0.1, the system ships with a built-in dynamic linker
cache of all system-provided libraries. As part of this change, copies of
dynamic libraries are no longer present on the filesystem. Code that attempts
to check for dynamic library presence by looking for a file at a path or
enumerating a directory will fail. Instead, check for library presence by
attempting to dlopen() the path, which will correctly check for the library in
the cache. (62986286)

lld currently uses fs::exists:
<a href="https://github.com/llvm/llvm-project/blob/6881f29a36a97102e5c89653a343f656231bc2f2/lld/MachO/DriverUtils.cpp#L252">https://github.com/llvm/llvm-project/blob/6881f29a36a97102e5c89653a343f656231bc2f2/lld/MachO/DriverUtils.cpp#L252</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>