<div dir="ltr">Eric,<div><br></div><div>I initially started from configuration using "-<span style="font-size:small;white-space:pre-wrap">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">-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON" fails the same way when I use "</span>-static-libstdc++"</div><div><span style="font-size:small;white-space:pre-wrap"><br></span></div><div><pre style="user-select: text; top: -99px;">clang++ -std=c++11 -stdlib=libc++ -v test.cc
clang version 4.0.0 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a> 832a07c9d566c5aad19e1ba5c3c924d8d384499f) (<a href="http://llvm.org/git/llvm.git">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 style="user-select: text; top: -99px;"> "/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><span style="font-size:small;white-space:pre-wrap"><br></span></div><div><span style="font-size:small;white-space:pre-wrap"><br></span></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 17, 2016 at 8:00 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_extra gmail_msg"><div class="gmail_quote gmail_msg">On Thu, Nov 17, 2016 at 5:20 PM, Mike Aizatsky via cfe-dev <span dir="ltr" class="gmail_msg"><<a href="mailto:cfe-dev@lists.llvm.org" class="gmail_msg" target="_blank">cfe-dev@lists.llvm.org</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"><div class="gmail_msg">Hello!<br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I've recently encountered a bug (<a href="https://llvm.org/bugs/show_bug.cgi?id=30919" class="m_8476873066920233286m_-6343617678378391008cremed 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="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">It seems that right now libc++abi is not handled by Tools.cpp. Normal linking works because:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg">$ cat ~/out/llvm/default/lib/libc++.so</div><div class="gmail_msg">INPUT(libc++.so.1 -lc++abi)</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">And if I use -static-libstdc++ then c++abi is not automatically linked in at all. </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="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="gmail_msg"><br class="gmail_msg"></div></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><div class="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="gmail_msg"><br class="gmail_msg"></div><div class="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="gmail_msg" target="_blank">LIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON</a>.</div><div class="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="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">/Eric</div><div class="gmail_msg"><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"></blockquote></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote 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"><span class="m_8476873066920233286HOEnZb gmail_msg"><font color="#888888" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div></div></font></span></div><span class="m_8476873066920233286HOEnZb gmail_msg"><font color="#888888" class="gmail_msg"><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>
</font></span><br class="gmail_msg"></blockquote></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br class="gmail_msg">
cfe-dev mailing list<br class="gmail_msg">
<a href="mailto:cfe-dev@lists.llvm.org" class="gmail_msg" target="_blank">cfe-dev@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br class="gmail_msg">
<br class="gmail_msg"></blockquote></div><br class="gmail_msg"></div></div>
</blockquote></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr">Mike<br>Sent from phone</div></div>