<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/142798>142798</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            LLD: Support --unresolved-symbols=@path/to/file option for lld
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            lld
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Nechda
      </td>
    </tr>
</table>

<pre>
    ### lt;dr
Let's add another use case for the `--unresolved-symbols` linker flag. This flag will read a list of symbols that may be undefined at linking time. The usage would be `--unresolved-symbols=@/path/to/file`.

### Context:
The common problem when linking statically with CUDA-like libraries, such as cuDNN and TensorRT, is related to undefined symbols that should be defined in the libc++ standard library (libcstd++.so). This can cause issues if the symbols are not present on the development host, but are present in the production environment.

Previously, our approach was straightforward: we simply created a library with empty stubs. The static linking worked fine, and the stubs were not used in the development environment. However, the latest update of TensorRT requires a more complex function that cannot be replaced with a simple stub - the inner implementation of std::thread. 

A naive approach to solving this problem would be to simply update libcstd++.so on all development hosts. However, this approach is difficult to complete in a short period of time and is also not scalable for the long term.

### Proposal
Let's extend the behavior of the `--unresolved-symbols` flag to include one more use case: `--unresolved-symbols=@/path/to/file`. This will read a list of symbols from the specified file and ignore errors related to any unresolved symbols mentioned in the list.

The default usage of the `--unresolved-symbols=ignore-all` flag is not appropriate in this case, as it may hide the actual problem with unresolved symbols.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVduO2zgPfhrlhkjgOJlkcuGLmQbBf1EUxb-zD0BLdKytLHklKmnefkE5h2kH7QILGEhgyyS_Az9jSvboiRr19Kqe9jPM3IfYfCHdG5y1wVwaVa-mCxyr1auJqnr5TKzqbQI0BtAH7ilCTgQaE0EXInBPoDbVfJ59pBTcicw8XYY2uKQ2FTjrv1GEzuFxAW-9TeUvnK1zEAkNIDibGEIH17eAe2QY8AItQfaGOuvJAHK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