<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hello,<div><br></div><div>Thanks for the reply Teresa and Steven,</div><div><br></div><div>I uploaded the snapshot to GDrive: <a href="https://drive.google.com/file/d/11Ngst9FOnVL4fWYlKalzoFXL--B1SaOb/view?usp=sharing">https://drive.google.com/file/d/11Ngst9FOnVL4fWYlKalzoFXL--B1SaOb/view?usp=sharing</a></div><div><br></div><div>My ld version is:</div><div><br></div><div><div>➜ ld -v</div><div>@(#)PROGRAM:ld  PROJECT:ld64-530</div><div>BUILD 18:57:17 Dec 13 2019</div><div>configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em</div><div>LTO support using: LLVM version 11.0.0, (clang-1100.0.33.17) (static support for 23, runtime is 23)</div><div>TAPI support using: Apple TAPI version 11.0.0 (tapi-1100.0.11)</div></div><div><br></div><div>Since that said it was using LTO from Xcode I thought that might be the problem - but when I run clang with -v to see the linker invocation it seems to pass the correct libLTO.dylib:</div><div> </div><div>"/usr/bin/ld" -demangle -object_path_lto /var/folders/5c/85r7gp0909j5jbytzds1j7b40000gn/T/thinlto-a8ae97 -lto_library /Users/tobias/tmp/clang+llvm-10.0.1-x86_64-apple-darwin/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 10.15.0 10.15 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -o test /var/folders/5c/85r7gp0909j5jbytzds1j7b40000gn/T/test-d0eb14.o src/.libs/libogg.a -debug_snapshot -lc++ -lSystem /Users/tobias/tmp/clang+llvm-10.0.1-x86_64-apple-darwin/lib/clang/10.0.1/lib/darwin/libclang_rt.osx.a<br></div><div><br></div><div>Thanks again,</div><div>Tobias</div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 22, 2020 at 7:20 PM Steven Wu <<a href="mailto:stevenwu@apple.com">stevenwu@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;">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><br></div><div>Steven<br><div><br><blockquote type="cite"><div>On Jul 22, 2020, at 8:41 AM, Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>> wrote:</div><br><div><div dir="ltr" style="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;text-decoration:none">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><br></div><div>Teresa</div></div><br style="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;text-decoration:none"><div class="gmail_quote" style="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;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">tobias@plexapp.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">David,<br><br>Thanks for looking into this. I did a small reproduction on my machine<br>outside of my build system. So here is how to reproduce:<br><br>Download<span> </span><a href="https://downloads.xiph.org/releases/ogg/libogg-1.3.4.tar.xz" rel="noreferrer" target="_blank">https://downloads.xiph.org/releases/ogg/libogg-1.3.4.tar.xz</a><br>Download llvm-10.0.1 macOS binary<br><br>export PATH=<path to llvm/bin>:$PATH<br>export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk<br><br>untar libogg<br>AR=llvm-ar CC=clang CXX=clang++ CFLAGS="-flto=thin<br>-mmacosx-version-min=10.9" LDFLAGS=-flto=thin ./configure<br>--disable-shared --enable-static<br>make -j20<br><br>Then try to link to the library in a small C++ program - I used this:<br><br>#include <iostream><br>#include "ogg/ogg.h"<br><br>using namespace std;<br><br>int main()<br>{<br>ogg_stream_state os;<br>if (ogg_stream_init(&os, 123) == 0)<br>cout << "Initialized stream succesfully" << endl;<br><br>return 0;<br>}<br><br>And from the libogg directory I linked to it like this:<br><br>clang++ -o test -flto=thin test.cpp src/.libs/libogg.a -I include<br><br>undef: _ogg_stream_init<br>Undefined symbols for architecture x86_64:<br>"_ogg_stream_init", referenced from:<br>_main in 0.x86_64.thinlto.o<br>ld: symbol(s) not found for architecture x86_64<br>clang-10: error: linker command failed with exit code 1 (use -v to see<br>invocation)<br><br>hope this helps - thanks!<br><br>On Wed, Jul 22, 2020 at 9:11 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>><br>> Got a link to the source/build instructions?<br>><br>> This sort of thing happens more often in C++ with templates where one<br>> object depends (incorrectly) on an implicit instantiation created in<br>> another object, rather than carrying its own instantiation.<br>><br>> Not sure what might cause it in C code.<br>><br>> On Tue, Jul 21, 2020 at 11:47 PM Tobias Hieta via llvm-dev<br>> <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>> ><br>> > Hello,<br>> ><br>> > I am building libogg with clang (10.0.1) on macOS and if I pass<br>> > "-flto=thin" to C and LDFLAGS it will not link correctly claiming<br>> > missing symbols when linking to the archive (libogg.a).<br>> ><br>> > undef: _ogg_stream_init<br>> > Undefined symbols for architecture x86_64:<br>> > "_ogg_stream_init", referenced from:<br>> > _main in lto.o<br>> ><br>> > Removing lto=thin fixes the problem. Inspecting the AR libs with<br>> > llvm-nm I see the symbol there (but without address):<br>> ><br>> > not working archive:<br>> > ---------------- T _ogg_stream_init<br>> ><br>> > working archive:<br>> > 0000000000000200 T _ogg_stream_init<br>> ><br>> > My guess is that this output is correct since the archive contains<br>> > bitcode in the thin lto case and otherwise it's the finished object.<br>> ><br>> > It seems to me that the LTO decides to not include this symbol? It's<br>> > defined like this:<br>> ><br>> > extern int ogg_stream_init(ogg_stream_state *os,int serialno);<br>> ><br>> > llvm-ar is used to create the archive.<br>> ><br>> > Is there any good way to debug this?<br>> ><br>> > Thanks,<br>> > Tobias<br>> > _______________________________________________<br>> > LLVM Developers mailing list<br>> ><span> </span><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>> ><span> </span><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br></blockquote></div><br clear="all" style="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;text-decoration:none"><div style="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;text-decoration:none"><br></div><span style="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;text-decoration:none;float:none;display:inline">--<span> </span></span><br style="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;text-decoration:none"><div dir="ltr" style="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;text-decoration:none"><div dir="ltr"><div><span style="font-family:Times;font-size:inherit"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td></tr></tbody></table></span></div></div></div></div></blockquote></div><br></div></div></blockquote></div>