<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Undefined reference to `environ' when linking libgtest.so on FreeBSD"
   href="https://bugs.webkit.org/show_bug.cgi?id=138420#c5">Comment # 5</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Undefined reference to `environ' when linking libgtest.so on FreeBSD"
   href="https://bugs.webkit.org/show_bug.cgi?id=138420">bug 138420</a>
              from <span class="vcard"><a class="email" href="mailto:lantw44&#64;gmail.com" title="Ting-Wei Lan &lt;lantw44&#64;gmail.com&gt;"> <span class="fn">Ting-Wei Lan</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=138420#c4">comment #4</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=256294&amp;action=diff" name="attach_256294" title="Patch">attachment 256294</a> <a href="attachment.cgi?id=256294&amp;action=edit" title="Patch">[details]</a></span>
&gt; Patch
&gt; 
&gt; This bug should probably be fixed upstream and</span >

The upstream project doesn't have this problem because they don't use -Wl,--no-undefined.

<span class="quote">&gt; the fix should probably not leave symbols unresolved.</span >

I leave it unresolved because I can't find other ways to solve the problem. The environ symbol doesn't exist in any shared library, so it can't be resolved by adding -l arguments. I also tried to add crt1.o to the linking arguments, but it also doesn't work.

If I use /usr/lib/crt1.o:
ld: /usr/lib/crt1.o: relocation R_X86_64_32 against `_DYNAMIC' can not be used when making a shared object; recompile with -fPIC
/usr/lib/crt1.o: error adding symbols: Bad value
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

If I use /usr/lib/gcrt1.o:
ld: /usr/lib/gcrt1.o: relocation R_X86_64_32 against `_DYNAMIC' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcrt1.o: error adding symbols: Bad value
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

If I use /usr/lib/Scrt1.o:
/usr/lib/Scrt1.o: In function `_start':
/usr/src/lib/csu/amd64/crt1.c:(.text+0xa4): undefined reference to `__preinit_array_start'
ld: /usr/lib/Scrt1.o: relocation R_X86_64_PC32 against undefined hidden symbol `__preinit_array_start' can not be used when making a shared object
ld: final link failed: Bad value
clang++: error: linker command failed with exit code 1 (use -v to see invocation)</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>