<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:i@maskray.me" title="Fangrui Song <i@maskray.me>"> <span class="fn">Fangrui Song</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - unexpected lld error: undefined symbol: clntudp_create"
   href="https://bugs.llvm.org/show_bug.cgi?id=45318">bug 45318</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>i@maskray.me
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>INVALID
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - unexpected lld error: undefined symbol: clntudp_create"
   href="https://bugs.llvm.org/show_bug.cgi?id=45318#c2">Comment # 2</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - unexpected lld error: undefined symbol: clntudp_create"
   href="https://bugs.llvm.org/show_bug.cgi?id=45318">bug 45318</a>
              from <span class="vcard"><a class="email" href="mailto:i@maskray.me" title="Fangrui Song <i@maskray.me>"> <span class="fn">Fangrui Song</span></a>
</span></b>
        <pre>You can get a reproduce file via LLD_REPRODUCE= or -Wl,--reproduce=
After deleting the first line --chroot . from response.txt, you can link it
with GNU ld. GNU ld errors as well

% aarch64-linux-gnu-ld @response.txt -y clntudp_create -y
<a href="mailto:clntudp_create@GLIBC_2.17">clntudp_create@GLIBC_2.17</a> --no-undefined
aarch64-linux-gnu-ld: tmp/c/lld.error/libsigar.a(sigar_util.o): reference to
clntudp_create
aarch64-linux-gnu-ld: tmp/c/lld.error/sysroot/lib/libc.so.6: definition of
<a href="mailto:clntudp_create@GLIBC_2.17">clntudp_create@GLIBC_2.17</a>
aarch64-linux-gnu-ld: tmp/c/lld.error/libsigar.a(sigar_util.o): in function
`sigar_rpc_ping':
sigar_util.c:(.text+0x11cc): undefined reference to `clntudp_create'
aarch64-linux-gnu-ld: sigar_util.c:(.text+0x11dc): undefined reference to
`xdr_void'
aarch64-linux-gnu-ld: sigar_util.c:(.text+0x11ec): undefined reference to
`xdr_void'
aarch64-linux-gnu-ld: sigar_util.c:(.text+0x1238): undefined reference to
`clnttcp_create'

I agree that the 'did you mean: ' diagnostic is confusing.

% ld.lld @response.txt -y clntudp_create -y <a href="mailto:clntudp_create@GLIBC_2.17">clntudp_create@GLIBC_2.17</a>
--no-undefined
tmp/c/lld.error/libsigar.a(sigar_util.o): reference to clntudp_create
tmp/c/lld.error/sysroot/lib/libc.so.6: shared definition of
<a href="mailto:clntudp_create@GLIBC_2.17">clntudp_create@GLIBC_2.17</a>
ld.lld: error: undefined symbol: clntudp_create
<span class="quote">>>> referenced by sigar_util.c
>>>               sigar_util.o:(sigar_rpc_ping) in archive tmp/c/lld.error/libsigar.a
>>> did you mean: clntudp_create
>>> defined in: tmp/c/lld.error/sysroot/lib/libc.so.6</span >


The definition in libc.so.6 is actually '<a href="mailto:clntudp_create@GLIBC_2.17">clntudp_create@GLIBC_2.17</a>'
(VERSYM_HIDDEN), not 'clntudp_create' . It cannot resolve an unversioned
reference named 'clntudp_create'. This mechanism is a bit obscure but the
intention is that the linker should reject it.

A proper fix is to annotate the source code with .symver
clntudp_create,<a href="mailto:clntudp_create@GLIBC_2.17">clntudp_create@GLIBC_2.17</a>

If you don't do that, you can drop -Wl,--no-undefined as a workaround. There is
an obscure runtime behavior making this hack work. According to Linux Standard
Base 10.7.6 Symbol Resolution:

<span class="quote">> The object with the reference does not use versioning, while the object with the definitions does. In this instance, only the definitions with index numbers 1 and 2 will be used in the reference match, the same identified by the static linker as the base definition. In cases where the static linker was not used, such as in calls to dlopen(), a version that does not have the base definition index shall be acceptable if it is the only version for which the symbol is defined.</span >

GLIBC_2.17 has index number 2 so glibc ld.so can resolve it at runtime.</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>