<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">This is usually a problem that is not using llvm-ar. I cannot reproduce this problem with either llvm 10.0 or TOT version. Which linker version are you using? You can also try pass "-Wl,-debug_snapshot" to the command where the error produces and then locate the "*.ld-snapshot" in /tmp directory and attach that as a reproducer.<div class=""><br class=""></div><div class="">Steven<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jul 22, 2020, at 8:41 AM, Teresa Johnson <<a href="mailto:tejohnson@google.com" class="">tejohnson@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Adding Steven Wu who can hopefully help as this is MacOS. Unfortunately, I don't have a way to run the MacOS compiler myself, and it uses the old LTO API which I am less familiar with. Typically these issues happen if you don't use llvm-ar, but it looks like you are using that so I'm not sure.<div class=""><br class=""></div><div class="">Teresa</div></div><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class="gmail_quote" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div dir="ltr" class="gmail_attr">On Wed, Jul 22, 2020 at 12:29 AM Tobias Hieta <<a href="mailto:tobias@plexapp.com" target="_blank" class="">tobias@plexapp.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">David,<br class=""><br class="">Thanks for looking into this. I did a small reproduction on my machine<br class="">outside of my build system. So here is how to reproduce:<br class=""><br class="">Download<span class="Apple-converted-space"> </span><a href="https://downloads.xiph.org/releases/ogg/libogg-1.3.4.tar.xz" rel="noreferrer" target="_blank" class="">https://downloads.xiph.org/releases/ogg/libogg-1.3.4.tar.xz</a><br class="">Download llvm-10.0.1 macOS binary<br class=""><br class="">export PATH=<path to llvm/bin>:$PATH<br class="">export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk<br class=""><br class="">untar libogg<br class="">AR=llvm-ar CC=clang CXX=clang++ CFLAGS="-flto=thin<br class="">-mmacosx-version-min=10.9" LDFLAGS=-flto=thin ./configure<br class="">--disable-shared --enable-static<br class="">make -j20<br class=""><br class="">Then try to link to the library in a small C++ program - I used this:<br class=""><br class="">#include <iostream><br class="">#include "ogg/ogg.h"<br class=""><br class="">using namespace std;<br class=""><br class="">int main()<br class="">{<br class="">ogg_stream_state os;<br class="">if (ogg_stream_init(&os, 123) == 0)<br class="">cout << "Initialized stream succesfully" << endl;<br class=""><br class="">return 0;<br class="">}<br class=""><br class="">And from the libogg directory I linked to it like this:<br class=""><br class="">clang++ -o test -flto=thin test.cpp src/.libs/libogg.a -I include<br class=""><br class="">undef: _ogg_stream_init<br class="">Undefined symbols for architecture x86_64:<br class="">"_ogg_stream_init", referenced from:<br class="">_main in 0.x86_64.thinlto.o<br class="">ld: symbol(s) not found for architecture x86_64<br class="">clang-10: error: linker command failed with exit code 1 (use -v to see<br class="">invocation)<br class=""><br class="">hope this helps - thanks!<br class=""><br class="">On Wed, Jul 22, 2020 at 9:11 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>> wrote:<br class="">><br class="">> Got a link to the source/build instructions?<br class="">><br class="">> This sort of thing happens more often in C++ with templates where one<br class="">> object depends (incorrectly) on an implicit instantiation created in<br class="">> another object, rather than carrying its own instantiation.<br class="">><br class="">> Not sure what might cause it in C code.<br class="">><br class="">> On Tue, Jul 21, 2020 at 11:47 PM Tobias Hieta via llvm-dev<br class="">> <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class="">> ><br class="">> > Hello,<br class="">> ><br class="">> > I am building libogg with clang (10.0.1) on macOS and if I pass<br class="">> > "-flto=thin" to C and LDFLAGS it will not link correctly claiming<br class="">> > missing symbols when linking to the archive (libogg.a).<br class="">> ><br class="">> > undef: _ogg_stream_init<br class="">> > Undefined symbols for architecture x86_64:<br class="">> > "_ogg_stream_init", referenced from:<br class="">> > _main in lto.o<br class="">> ><br class="">> > Removing lto=thin fixes the problem. Inspecting the AR libs with<br class="">> > llvm-nm I see the symbol there (but without address):<br class="">> ><br class="">> > not working archive:<br class="">> > ---------------- T _ogg_stream_init<br class="">> ><br class="">> > working archive:<br class="">> > 0000000000000200 T _ogg_stream_init<br class="">> ><br class="">> > My guess is that this output is correct since the archive contains<br class="">> > bitcode in the thin lto case and otherwise it's the finished object.<br class="">> ><br class="">> > It seems to me that the LTO decides to not include this symbol? It's<br class="">> > defined like this:<br class="">> ><br class="">> > extern int ogg_stream_init(ogg_stream_state *os,int serialno);<br class="">> ><br class="">> > llvm-ar is used to create the archive.<br class="">> ><br class="">> > Is there any good way to debug this?<br class="">> ><br class="">> > Thanks,<br class="">> > Tobias<br class="">> > _______________________________________________<br class="">> > LLVM Developers mailing list<br class="">> ><span class="Apple-converted-space"> </span><a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class="">> ><span class="Apple-converted-space"> </span><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class=""></blockquote></div><br clear="all" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class=""></div><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">--<span class="Apple-converted-space"> </span></span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div dir="ltr" class=""><div class=""><span style="font-family: Times; font-size: inherit;" class=""><table cellspacing="0" cellpadding="0" class=""><tbody class=""><tr style="color: rgb(85, 85, 85); font-family: sans-serif; font-size: small;" class=""><td nowrap="" style="border-top-width: 2px; border-top-style: solid; border-top-color: rgb(213, 15, 37);" class="">Teresa Johnson |</td><td nowrap="" style="border-top-width: 2px; border-top-style: solid; border-top-color: rgb(51, 105, 232);" class=""> Software Engineer |</td><td nowrap="" style="border-top-width: 2px; border-top-style: solid; border-top-color: rgb(0, 153, 57);" class=""> <a href="mailto:tejohnson@google.com" target="_blank" class="">tejohnson@google.com</a> |</td></tr></tbody></table></span></div></div></div></div></blockquote></div><br class=""></div></body></html>