<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Tom, <div><br></div><div>Thanks for your replies. </div><div><br></div><div>Following are the commands that I used to build clang/libcxx/libcxxabi:</div><div>clang:</div><div><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,0,0)">  cmake -DLLVM_ENABLE_PROJECTS=</code><code class="gmail-bash gmail-string" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,51,102)">"clang;libcxx;libcxxabi"</code><span style="color:rgb(51,51,51);font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;white-space:nowrap"> </span><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,0,0)">-G </code><code class="gmail-bash gmail-string" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,51,102)">"Unix Makefiles"</code><span style="color:rgb(51,51,51);font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;white-space:nowrap"> </span><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,0,0)">-DCMAKE_BUILD_TYPE=Release -DLLVM_LIBDIR_SUFFIX=64 ..</code><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,0,0)">/llvm</code><br></div><div><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,0,0)"><br></code></div><div>libcxx:</div><div><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,0,0)"><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit">  cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=</code><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit">/usr</code><span style="color:rgb(51,51,51)"> </span><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit">-DLLVM_LIBDIR_SUFFIX=64 -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..</code><br></code></div><div><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,0,0)"><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit"><br></code></code></div><div>libcxxabi:<br></div><div><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,0,0)">  cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=</code><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,0,0)">/usr</code><span style="color:rgb(51,51,51);font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;white-space:nowrap"> </span><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,0,0)">-DLLVM_LIBDIR_SUFFIX=64 -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLIBCXXABI_LIBCXX_INCLUDES=../..</code><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,0,0)">/libcxx/include</code><span style="color:rgb(51,51,51);font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;white-space:nowrap"> </span><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,0,0)">..</code><br></div><div><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,0,0)"><br></code></div><div><code class="gmail-bash gmail-plain" style="border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit"><font face="Arial, Helvetica, sans-serif">And based on what I searched on google, libcxx and libcxxabi might have circular dependency (please see the post here: </font></code><a href="https://stackoverflow.com/questions/25840088/how-to-build-libcxx-and-libcxxabi-by-clang-on-centos-7">https://stackoverflow.com/questions/25840088/how-to-build-libcxx-and-libcxxabi-by-clang-on-centos-7</a>), so after I built libcxx with clang, build libcxxabi based on libcxx, I rebuilt libcxx again with libcxxabi with the following command:</div><div><code class="gmail-bash gmail-plain" style="border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit"><div>cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DLLVM_LIBDIR_SUFFIX=64 -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_CXX_ABI_INCLUDE_PATHS=../../libcxxabi/include ..</div><div><br></div><div><font face="Arial, Helvetica, sans-serif">I've tried what you suggested in your previous email (add linker flag: -lc++abi), but unfortunately I got the same error while building my project. Am I missing anything?</font></div><div><font face="Arial, Helvetica, sans-serif"><br></font></div><div><font face="Arial, Helvetica, sans-serif">Thank you all,</font></div><div><font face="Arial, Helvetica, sans-serif">Aichi</font></div><div><br></div></code></div><div><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap;color:rgb(0,0,0)"><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit"><table border="0" cellpadding="0" cellspacing="0" style="white-space:normal;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:1625.265625px;box-sizing:content-box;min-height:inherit;color:rgb(51,51,51)"><tbody style="border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit"><tr style="border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit"><td class="gmail-code" style="border:0px;overflow:visible;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;float:none;height:auto;line-height:20px;outline:0px;padding:0px 0px 0px 15px;vertical-align:baseline;width:1610.265625px;box-sizing:content-box;font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;min-height:inherit"><div class="gmail-container" title="Hint: double-click to select code" style="margin:15px 0px 0px;padding:0px 0px 15px 0em;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;outline:0px;overflow:visible;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:pre-wrap"><div class="gmail-line gmail-number1 gmail-index0 gmail-alt2" style="margin:0px;padding:0px 1em 0px 0em;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;outline:0px;overflow:visible;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap"></div><div class="gmail-line gmail-number1 gmail-index0 gmail-alt2" style="margin:0px;padding:0px 1em 0px 0em;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;outline:0px;overflow:visible;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap"><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;color:rgb(0,0,0)"><br></code></div><div class="gmail-line gmail-number1 gmail-index0 gmail-alt2" style="margin:0px;padding:0px 1em 0px 0em;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;outline:0px;overflow:visible;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;white-space:nowrap"><code class="gmail-bash gmail-plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;background-image:none;border:0px;float:none;height:auto;line-height:20px;margin:0px;outline:0px;overflow:visible;padding:0px;vertical-align:baseline;width:auto;box-sizing:content-box;min-height:inherit;color:rgb(0,0,0)"><br></code></div></div></td></tr></tbody></table></code></code></div></div></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 12, 2019 at 6:38 PM Tom Stellard <<a href="mailto:tstellar@redhat.com">tstellar@redhat.com</a>> wrote:<br></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">On 04/12/2019 06:31 PM, Tom Stellard via llvm-dev wrote:<br>
> On 04/12/2019 04:28 PM, AiChi via llvm-dev wrote:<br>
>> Hi,<br>
>><br>
>> I'm currently working on one of my team's project to build LLVM full clang toolchain (Clang, libcxx, libcxxabi) on a CentOS machine. <br>
>><br>
>> Previously we compiled our codebase with llvm-toolset-7/clang++, which by default takes stdlibc++ to compile and link. And now we'd like to switch to use LLVM clang with libc++. I have built libc++ and libc++abi from source (5.0.1 release) and set up related flags to compile our code base, but it turned out having some issue in the "linker" phase:<br>
>><br>
>> Flags set for complier:<br>
>> -stdlib=libc++ -std=c++14<br>
>><br>
>> Flags set for linker:<br>
>> -stdlib=libc++<br>
>><br>
>> Error:<br>
>> /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../bin/ld: product.o: undefined reference to symbol '__cxa_free_exception@@CXXABI_1.3'<br>
>> //lib64/libstdc++.so.6: error adding symbols: DSO missing from command line<br>
>> clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)<br>
>><br>
>> My question is:<br>
>> 1. We plan to replace stdlibc++ with libc++, and we've set up compiler and linker to run with "-stdlib=libc++', why is it complaining about libstdc++?<br>
> <br>
> Can you post the full linker invocation with all the arguments? <br>
> <br>
> What cmake arguments did you use when building libcxx and libcxxabi?<br>
> <br>
>> 2. How can we resolve this error? (any ideas would be appreciated!)<br>
> <br>
> Not sure exactly, I would try passing -DLIBCXX_CXX_ABI=libcxxabi to cmake<br>
> when configuring libcxx if you have not already.<br>
> <br>
<br>
If you are looking for a quick fix though, you might want to also try adding<br>
-lc++abi to your linker flags.<br>
<br>
-Tom<br>
<br>
>> 3. Is there anything missing if we'd like to replace stdlibc++ with libc++?<br>
>> 4. I also noticed when it's in linker phase, these flags were set in the ld command (-lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc ), which we didn't have them setup anywhere in our project, just out of curiosity, are they added automatically? Why are they needed?<br>
> <br>
> When you are using clang++ or g++ as the linker driver, then it automatically<br>
> adds the flags for you.<br>
> <br>
> -Tom<br>
> <br>
>><br>
>> A little bit more details:<br>
>> Environment: CentOS Linux release 7.6.1810 (Core) <br>
>> Clang version: <br>
>><br>
>>     clang version 5.0.1 (tags/RELEASE_501/final)<br>
>>     Target: x86_64-unknown-linux-gnu<br>
>>     Thread model: posix<br>
>><br>
>><br>
>> Thanks for any ideas,<br>
>> Aichi<br>
>><br>
>><br>
>> _______________________________________________<br>
>> LLVM Developers mailing list<br>
>> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>> <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>
>><br>
> <br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
> <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>
> <br>
<br>
</blockquote></div></div></div></div>