我尝试clang++
通过两种方式从中继(〜3.7)构建:通过gcc
(4.8)和(旧)clang++
(数据包管理器的3.4和3.5)。两者都包含相同的步骤:
export CC=clang
export CXX=clang++
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:$HOME/llvm/projects/libcxxabi/include"
sudo apt-get install git
cd
git clone --single-branch --branch master --depth=1 http://llvm.org/git/llvm
cd llvm/projects/
git clone --single-branch --branch master --depth=1 http://llvm.org/git/libcxxabi
git clone --single-branch --branch master --depth=1 http://llvm.org/git/libcxx
git clone --single-branch --branch master --depth=1 http://llvm.org/git/compiler-rt
cd ../tools
git clone --single-branch --branch master --depth=1 http://llvm.org/git/clang
git clone --single-branch --branch master --depth=1 http://llvm.org/git/clang-tools-extra extra
git clone --single-branch --branch master --depth=1 http://llvm.org/git/lld
git clone --single-branch --branch master --depth=1 http://llvm.org/git/lldb
git clone --single-branch --branch master --depth=1 http://llvm.org/git/polly
sudo apt-get install python-dev libedit-dev libncurses-dev swig libgmp-dev libgmp3-dev dh-autoreconf libunwind8 libunwind8-dev cmake
cd
cd llvm/tools/polly/utils
mkdir -p ~/build-cloog
bash checkout_cloog.sh ~/build-cloog
mkdir -p ~/build-isl
bash checkout_isl.sh ~/build-isl
cd ~/build-isl/
./configure
make
sudo make install
cd ~/build-cloog/
./configure --with-isl=system
make
sudo make install
cd
mkdir build-llvm
cd build-llvm
bash ../llvm/configure --enable-optimized --disable-assertions --enable-libcpp --enable-jit --enable-targets=x86,x86_64 --enable-polly --enable-cxx1y --with-gmp=/usr/local --with-isl=/usr/local --with-cloog=/usr/local --with-binutils-include=/usr/include
make -j`nproc`
sudo make install
对于CC=clang
并且CXX=clang++
在链接包含std::istringstream
实例的简单示例时遇到错误:
#include <sstream>
#include <cstdlib>
int
main()
{
std::istringstream iss("1.1");
double x;
iss >> x;
return EXIT_SUCCESS;
}
错误:
user@ubuntu:~$ clang++ -stdlib=libc++ -std=gnu++1z -Ofast -march=native test.cpp -o /tmp/test
/tmp/test-785a74.o: In function `std::__1::basic_istringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_istringstream()':
test.cpp:(.text._ZNSt3__119basic_istringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEED0Ev[_ZNSt3__119basic_istringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEED0Ev]+0x5b): undefined reference to `operator delete(void*, unsigned long)'
/tmp/test-785a74.o: In function `virtual thunk to std::__1::basic_istringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_istringstream()':
test.cpp:(.text._ZTv0_n24_NSt3__119basic_istringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEED0Ev[_ZTv0_n24_NSt3__119basic_istringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEED0Ev]+0x69): undefined reference to `operator delete(void*, unsigned long)'
/tmp/test-785a74.o: In function `std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_stringbuf()':
test.cpp:(.text._ZNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEED0Ev[_ZNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEED0Ev]+0x26): undefined reference to `operator delete(void*, unsigned long)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
但是,如果CC=gcc
和,则不会发生错误CXX=g++
。两种情况下都ld
来自链接器GNU Binutils
。
来自对象的示例样本#include <iostream>
没有这样的问题。
错误原因是什么?我可以在不重建整个clang/llvm
项目树的情况下进行修复吗?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句