我正在尝试使用 libc++ 从源代码构建 Clang。我试图将 libc++ 放入树内,同时使用其他组件在树外构建它。我使用的食谱如下。
如果我简单地放置libcxx
and libcxxabi
in-tree,然后配置does not拿起它们,它们不是自动构建的。我把它们放在llvm/projects
per LLVM 的 libc++ 标准库 http://libcxx.llvm.org/.
另外,添加make cxx
食谱并不像宣传的那样起作用LLVM 的 libc++ 标准库 http://libcxx.llvm.org/页。其结果是:
llvm[0]: Constructing LLVMBuild project information.
make: *** No rule to make target `cxx'. Stop.
当我配置 LLVM/Clang 时--with-libcxx
and --with-libcxxabi
:
# Issued from a scratch 'build' directory, which is next to the 'llvm' directory.
../llvm/configure --enable-optimized --enable-cxx11 --with-libcxx --with-libcxxabi \
$OTHER_OPTIONS --prefix=/usr/local
然后我收到以下信息:
configure: WARNING: Unknown project (libcxx) won't be configured automatically
configure: WARNING: Unknown project (libcxxabi) won't be configured automatically
libcxx
and libcxxabi
实际上是 LLVM 所说的,所以我不确定如果它们不正确应该使用什么名称。
我试图检查configure
包名称应该是什么,但它不是很有帮助。逻辑见下文。
如何使用 libc++ 配置和构建 Clang(当 libc++ 和 libc++ ABI 位于树内时)?
配置逻辑--with-XXX
如下所示。
这是我能找到的全部(它不是很有帮助):
-with-* | --with-*)
ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
{ echo "$as_me: error: invalid package name: $ac_package" >&2
{ (exit 1); exit 1; }; }
ac_package=`echo $ac_package| sed 's/-/_/g'`
eval with_$ac_package=\$ac_optarg ;;
相关链接:
- LLVM/Clang 下载页面 http://llvm.org/releases/download.html
- LLVM 的 libc++ 标准库页面 http://libcxx.llvm.org/
与此堆栈溢出问题相关:从源代码构建 Clang 时什么时候需要 libc++ 源代码? https://stackoverflow.com/q/27812611
CFE-Dev 邮件列表的讨论:关于 Linux 版 libc++ 及其 git 存储库的问题(如果有) http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-July/thread.html。该线程说将 libcxx 解包到llcm/projects
确保标头被复制到 Clang 期望的位置make install
。但它并没有解决--with-XXX
问题,它没有讨论为什么libc++
没有构建,也没有讨论如何获得make install
实际安装库。
获取和构建 Clang 的配方。当not包括libcxx
and libcxxabi
.
#! /bin/sh
# Clang 3.5 recipe.
# The script should be run from a scratch directory.
# Fetch
if [ ! -e llvm-3.5.0.src.tar.xz ]; then
wget http://llvm.org/releases/3.5.0/llvm-3.5.0.src.tar.xz
fi
if [ ! -e cfe-3.5.0.src.tar.xz ]; then
wget http://llvm.org/releases/3.5.0/cfe-3.5.0.src.tar.xz
fi
if [ ! -e compiler-rt-3.5.0.src.tar.xz ]; then
wget http://llvm.org/releases/3.5.0/compiler-rt-3.5.0.src.tar.xz
fi
if [ ! -e libcxx-3.5.0.src.tar.xz ]; then
wget http://llvm.org/releases/3.5.0/libcxx-3.5.0.src.tar.xz
fi
if [ ! -e libcxxabi-3.5.0.src.tar.xz ]; then
wget http://llvm.org/releases/3.5.0/libcxxabi-3.5.0.src.tar.xz
fi
if [ ! -e clang-tools-extra-3.5.0.src.tar.xz ]; then
wget http://llvm.org/releases/3.5.0/clang-tools-extra-3.5.0.src.tar.xz
fi
# Cleanup
echo "Cleaning up artifacts"
rm -rf llvm build llvm-3.5.0.src
# LLVM
echo "Unpacking LLVM"
tar xf llvm-3.5.0.src.tar.xz
mv llvm-3.5.0.src/ llvm
# Clang Front End
echo "Unpacking Clang Front End"
cd llvm/tools
tar xf ../../cfe-3.5.0.src.tar.xz
mv cfe-3.5.0.src clang
cd ../../
# Compiler RT
echo "Unpacking Compiler RT"
cd llvm/projects
tar xf ../../compiler-rt-3.5.0.src.tar.xz
mv compiler-rt-3.5.0.src/ compiler-rt
cd ../../
# Extra Tools
echo "Unpacking Extra Tools"
cd llvm/tools/clang/tools/
tar xf ../../../../clang-tools-extra-3.5.0.src.tar.xz
mv clang-tools-extra-3.5.0.src extra
cd ../../../../
# libc++
echo "Unpacking libc++"
cd llvm/projects
tar xf ../../libcxx-3.5.0.src.tar.xz
mv libcxx-3.5.0.src/ libcxx
cd ../../
# libc++ ABI
echo "Unpacking libc++ ABI"
cd llvm/projects
tar xf ../../libcxxabi-3.5.0.src.tar.xz
mv libcxxabi-3.5.0.src/ libcxxabi
cd ../../
# Determine if Apple
IS_DARWIN=`uname -s | egrep -i -c "Darwin"`
if [ $IS_DARWIN -ne 0 ]; then
OTHER_OPTIONS=" --enable-libcpp"
fi
# Configure
echo "Configuring build"
mkdir -p build
cd build
../llvm/configure --enable-optimized --enable-cxx11 --with-libcxx --with-libcxxabi $OTHER_OPTIONS --prefix=/usr/local
# Build
# 'make cxx' for libc++ is from http://libcxx.llvm.org/
echo "Running make"
make cxx
make -j2
RET=$?
if [ $RET -eq 0 ];then
echo "****************************************"
read -p "Press [ENTER] to install, or [CTRL]+C to quit"
sudo make install
fi
# ****************************************
# ****************************************
# Install does not install scan-build and scan-view
# Perform the copy, and/or put them on-path
#sudo cp llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py /usr/local/bin
#sudo 2to3 -w /usr/local/bin/asan_symbolize.py
#sudo mkdir /usr/local/bin/scan-build
#sudo cp -r llvm/tools/clang/tools/scan-build /usr/local/bin
#sudo mkdir /usr/local/bin/scan-view
#sudo cp -r llvm/tools/clang/tools/scan-view /usr/local/bin