<div dir="ltr">Yes, this fixes my issue and works splendidly with -DLIBCXX_ENABLE_SHARED=OFF -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON. Thanks a lot. Closing the issue.</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Nov 18, 2016 at 12:11 PM Eric Fiselier <<a href="mailto:eric@efcs.ca">eric@efcs.ca</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_msg">Hi Mike,</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I think i fixed LIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON. I added a `merge_archives.py` utility to libc++ and changed LIBCXX_ENABLE_STATIC_ABI_LIBRARY to merge the ABI library into libc++.a.<br class="gmail_msg"></div><div class="gmail_msg">Could you confirm that this fixes the issue?</div></div><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">/Eric</div></div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg">On Thu, Nov 17, 2016 at 9:35 PM, Mike Aizatsky <span dir="ltr" class="gmail_msg"><<a href="mailto:aizatsky@google.com" class="gmail_msg" target="_blank">aizatsky@google.com</a>></span> wrote:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Eric,<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I initially started from configuration using "-<span style="font-size:small;white-space:pre-wrap" class="gmail_msg">DLIBCXX_ENABLE_SHARED=OFF -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON". Clang built with this configuration can not produce binaries at all (see below). Clang with just "</span><span style="font-size:small;white-space:pre-wrap" class="gmail_msg">-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON" fails the same way when I use "</span>-static-libstdc++"</div><div class="gmail_msg"><span style="font-size:small;white-space:pre-wrap" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><pre class="gmail_msg">clang++ -std=c++11 -stdlib=libc++  -v test.cc 
clang version 4.0.0 (<a href="http://llvm.org/git/clang.git" class="gmail_msg" target="_blank">http://llvm.org/git/clang.git</a> 832a07c9d566c5aad19e1ba5c3c924d8d384499f) (<a href="http://llvm.org/git/llvm.git" class="gmail_msg" target="_blank">http://llvm.org/git/llvm.git</a> fde9b8bfc220c589f9103b3919d1
07cd3e944cc6)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/usr/local/bin/clang-4.0" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main
-file-name test.cc -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -f
use-init-array -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/local/bin/../lib/clang/4.0.0 -internal-isystem /usr/loc
al/bin/../include/c++/v1 -internal-isystem /usr/local/include -internal-isystem /usr/local/bin/../lib/clang/4.0.0/include -internal-externc-isystem /us
r/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++11 -fdeprecated-macro -fdebug-compilation-
dir / -ferror-limit 19 -fmessage-length 151 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o /tmp/test-fa0ac9.o -x c++ tes
t.cc
clang -cc1 version 4.0.0 based upon LLVM 4.0.0svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/bin/../include/c++/v1
 /usr/local/include
 /usr/local/bin/../lib/clang/4.0.0/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
test.cc:10:5: warning: expression result unused [-Wunused-value]
    dynamic_cast<B*>(v); // well-defined: v of type V*, V base of B, results in B*
    ^~~~~~~~~~~~~~~~~~~
test.cc:11:5: warning: expression result unused [-Wunused-value]
    dynamic_cast<B*>(a); // undefined behavior: a has type A*, A not a base of B
    ^~~~~~~~~~~~~~~~~~~
2 warnings generated.</pre><pre class="gmail_msg"> "/usr/bin/ld" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/lib/gcc/x86_64-linux-gn
u/5.4.0/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/5.4.0/crtbe
gin.o -L/usr/lib/gcc/x86_64-linux-gnu/5.4.0 -L/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/
usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../.. -L/usr/local/bin/../lib -L/lib -L/usr/lib /tmp/test-fa0ac9.o -lc++ -lm -lgcc_s 
-lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/5.4.0/crtend.o /usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu/crtn.o
/usr/local/bin/../lib/libc++.a(ios.cpp.o): In function `std::__1::iostream_category()':
ios.cpp:(.text._ZNSt3__117iostream_categoryEv+0x24): undefined reference to `__cxa_guard_acquire'
ios.cpp:(.text._ZNSt3__117iostream_categoryEv+0x34): undefined reference to `__cxa_guard_release'
/usr/local/bin/../lib/libc++.a(ios.cpp.o): In function `std::__1::ios_base::clear(unsigned int)':
ios.cpp:(.text._ZNSt3__18ios_base5clearEj+0x48): undefined reference to `__cxa_allocate_exception'
ios.cpp:(.text._ZNSt3__18ios_base5clearEj+0x84): undefined reference to `__cxa_throw'
ios.cpp:(.text._ZNSt3__18ios_base5clearEj+0x94): undefined reference to `__cxa_free_exception'</pre></div><div class="gmail_msg"><span style="font-size:small;white-space:pre-wrap" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><span style="font-size:small;white-space:pre-wrap" class="gmail_msg"><br class="gmail_msg"></span></div></div><div class="m_-6296939620425956068HOEnZb gmail_msg"><div class="m_-6296939620425956068h5 gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Thu, Nov 17, 2016 at 8:00 PM Eric Fiselier <<a href="mailto:eric@efcs.ca" class="gmail_msg" target="_blank">eric@efcs.ca</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div class="gmail_extra m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div class="gmail_quote m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">On Thu, Nov 17, 2016 at 5:20 PM, Mike Aizatsky via cfe-dev <span dir="ltr" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><<a href="mailto:cfe-dev@lists.llvm.org" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><blockquote class="gmail_quote m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">Hello!<br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">I've recently encountered a bug (<a href="https://llvm.org/bugs/show_bug.cgi?id=30919" class="m_-6296939620425956068m_-7751722471650725923m_8476873066920233286m_-6343617678378391008cremed m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg" target="_blank">https://llvm.org/bugs/show_bug.cgi?id=30919</a>) and I would like an advice on how to approach it.</div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">It seems that right now libc++abi is not handled by Tools.cpp. Normal linking works  because:</div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">$ cat ~/out/llvm/default/lib/libc++.so</div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">INPUT(libc++.so.1 -lc++abi)</div></div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">And if I use -static-libstdc++ then c++abi is not automatically linked in at all. </div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">Is there a similar magic for .a files like for .so? Should Tools.cpp know about lc++abi? Are there any alternatives?</div></div></blockquote><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div></div></div></div><div dir="ltr" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div class="gmail_extra m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div class="gmail_quote m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">First, Tools.cpp shouldn't know about libc++abi/libsupc++/libcxxrt or w/e C++ ABI library your STL is using.</div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">There are two alternatives to your problem.  If you want to use a static libc++abi you can build libc++ with <a href="http://libcxx.llvm.org/docs/BuildingLibcxx.html#cmdoption-arg-LIBCXX_ENABLE_STATIC_ABI_LIBRARY" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg" target="_blank">LIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON</a>.</div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">Alternatively you can define libc++.a as a linker script just like libc++.so. (Ex INPUT(libc++static.a -lc++abi)) </div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">/Eric</div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div><blockquote class="gmail_quote m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote></div></div></div><div dir="ltr" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div class="gmail_extra m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div class="gmail_quote m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><blockquote class="gmail_quote m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><span class="m_-6296939620425956068m_-7751722471650725923m_8476873066920233286HOEnZb m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><font color="#888888" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div></div></font></span></div><span class="m_-6296939620425956068m_-7751722471650725923m_8476873066920233286HOEnZb m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><font color="#888888" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div dir="ltr" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">-- <br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div><div data-smartmail="gmail_signature" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div dir="ltr" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">Mike<br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">Sent from phone</div></div>
</font></span><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></blockquote></div></div></div><div dir="ltr" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div class="gmail_extra m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><div class="gmail_quote m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"><blockquote class="gmail_quote m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">
cfe-dev mailing list<br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">
<a href="mailto:cfe-dev@lists.llvm.org" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg" target="_blank">cfe-dev@lists.llvm.org</a><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg">
<br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></blockquote></div><br class="m_-6296939620425956068m_-7751722471650725923gmail_msg gmail_msg"></div></div>
</blockquote></div><div dir="ltr" class="gmail_msg">-- <br class="gmail_msg"></div><div data-smartmail="gmail_signature" class="gmail_msg"><div dir="ltr" class="gmail_msg">Mike<br class="gmail_msg">Sent from phone</div></div>
</div></div></blockquote></div><br class="gmail_msg"></div>
</blockquote></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr">Mike<br>Sent from phone</div></div>