llvm build failed while Linking CXX shared library ../../../lib/libc++.so

Hello everybody,

I am very new to llvm and I am struggling to install it on my 15.10 Xubuntu with kernel 4.2.0-34-generic #39-Ubuntu SMP x86_64 GNU/Linux.

I essentially intend to use the clang static analyzer, but it seems that I have to build it on top of llvm and clang.

Unfortunately I run into the following problem.

CXX shared library …/…/…/lib/libc++.so

at around 52% of the procedure (while building target gtest_main)

followed by a handful of undefined references

the last lines consist of the following messages:
collect2: error: ld returned 1 exit status
projects/libcxx/lib/CMakeFiles/cxx.dir/build.make:735: recipe for target ‘lib/libc++.so.1.0’ failed
make[2]: *** [lib/libc++.so.1.0] Error 1
CMakeFiles/Makefile2:11552: recipe for target ‘projects/libcxx/lib/CMakeFiles/cxx.dir/all’ failed
make[1]: *** [projects/libcxx/lib/CMakeFiles/cxx.dir/all] Error 2
Makefile:136: recipe for target ‘all’ failed
make: *** [all] Error 2

Can someone please help me go further?

Hi Ioannis,

If you only want the clang static analyzer, there is no need to check out and build libc++ as part of the process. The rest of the build can just use the system C++ library, which will be libstdc++ on Xubuntu.

That said, without the full build log, it is hard to say what went wrong. Specifically, which references were undefined?

-Dimitry

Hi Dimitry,

I do not particularly need to build libc++ from the package. Is the name of the package’s libc++, libcxx, because this is where the installation starts finding undefined references, during linking CXX shared library …/…/…/lib/libc++.so. Please check below the first part of the log when the first error appear, I omited repeating results. Furthermore, the undefined references are thousands!

If you say that libc++ is not need it how can I skip it’s interference. Shall I check out the package again without the particular libc++, of invoke cmake with a particular parameter?

.
.
[ 52%] Built target gtest
[ 52%] Built target gtest_main
Linking CXX shared library …/…/…/lib/libc++.so
CMakeFiles/cxx.dir/__/src/ios.cpp.o: In function std::__1::iostream_category()': /opt/llvm/llvm/projects/libcxx/src/ios.cpp:71: undefined reference to __cxa_guard_acquire’
/opt/llvm/llvm/projects/libcxx/src/ios.cpp:71: undefined reference to __cxa_guard_release' CMakeFiles/cxx.dir/__/src/ios.cpp.o: In function std::1::ios_base::clear(unsigned int)’:
CMakeFiles/cxx.dir/
/src/ios.cpp.o: In function std::__1::basic_istream<char, std::__1::char_traits<char> >::operator>>(std::__1::basic_streambuf<char, std::__1::char_traits<char> >*)': /opt/llvm/llvm/projects/libcxx/include/istream:900: undefined reference to __cxa_begin_catch’
/opt/llvm/llvm/projects/libcxx/include/istream:900: undefined reference to `__cxa_end_catch’
.
.
.

Best

Hi Ioannis,

Just delete the projects/libcxx directory, then rebuild from scratch. You should only need to checkout llvm (in the top level directory) and cfe (into the tools/clang subdirectory).

-Dimitry

Hi Dimitry, this definitely worked. I am passed by the linking errors regarding libc++ or similar. My build stopped now at 95% while linking a clang extra, I am not pretty sure which because i do not have my laptop, possible the clang-rename, if such exists.
No undefined references here, however, my hdd’s free space run out, so this might be the cause. I have to move or expand now, alas!! The build is too big.

I will keep you posted as soon as i’ll get down to it. Thank you so far.

FIXED!

Dimitry thank you for your advice!

To formalize it a bit.
In order to build Clang Static Analyzer one does not need to download the libcxx, or compiler-rt (as long as he has a native version of a libc eg glibc) as instructed by the following link http://clang.llvm.org/get_started.html#build.

Notice: The latter link should maybe be amended to reflect that Clang Static Analyzer fails if all the components are installed. That is prudent, as the fromer link ultimately redirects to the latter for building instructions.