未知的包libcxx和libcxxabi在构建Clang时? [英] Unknown package libcxx and libcxxabi when building Clang?

查看:817
本文介绍了未知的包libcxx和libcxxabi在构建Clang时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用libc ++从源代码构建Clang。我试图删除libc ++ in-tree,同时与其他组件构建它。



如果我只是放置 libcxx libcxxabi

code> in-tree,然后配置 不会 选择它们,而不是自动构建。我将它们放在 llvm / projects LLVM的libc ++标准库



此外,向配方中添加 make cxx 不能像 LLVM的libc ++标准库页面。它导致:

  llvm [0]:构造LLVMBuild项目信息。 
make:***没有规则使目标`cxx'。停止。

当我使用 - with-libcxx - with-libcxxabi

 #从临时'build'目录发出,它位于'llvm'目录旁边。 
../llvm/configure --enable-optimized --enable-cxx11 --with-libcxx --with-libcxxabi \
$ OTHER_OPTIONS --prefix = / usr / local


$ b


$ b

无配置:警告:不会自动配置未知项目(libcxx)
configure:警告:不会自动配置未知项目(libcxxabi)

libcxx libcxxabi 是真正的LLVM调用他们,所以我不知道什么名称,如果他们不正确使用。



我试图检查 configure 为包名应该是什么,但它不是非常有帮助。



如何使用libc ++配置和构建Clang(当libc ++和libc ++ ABI在树形结构中)?






- with-XXX 的逻辑配置如下所示。



这是我可以找到的(它不是很有帮助):

  -with- * | --with- *)
ac_package =`expr'x $ ac_option:'x- * with-\([^ =] * \)'`
#拒绝无效的名称shell变量名。
exprx $ ac_package:。* [^ -_ $ as_cr_alnum]> / dev / null&&
{echo$ as_me:error:invalid package name:$ ac_package>& 2
{(exit 1);出口1; }; }
ac_package =`echo $ ac_package | sed's / - / _ / g'`
eval with_ $ ac_package = \ $ ac_optarg ;;






相关链接:





这个Stack Overflow问题是相关的:从源码构建Clang时需要什么libc ++源码?



而这次关于CFE-Dev邮件列表的讨论:关于libc ++对linux及其git存储库(如果有)的问题。该线程表示将libcxx解压缩到 llcm / projects 中,确保在 make install 期间复制Clang期望的头。但它不解决 - with-XXX 问题,它不讨论为什么 libc ++ 没有被构建,它不讨论如何获取 make install 来实际安装库。






配方以获取和构建Clang。在 包括 libcxx libcxxabi 时,工作正常。

 #! / bin / sh 

#Clang 3.5食谱。
#脚本应该从暂存目录运行。

#Fetch

if [! -eIvv-3.5.0.src.tar.xz];那么
wget http://llvm.org/releases/3.5.0/llvm-3.5.0.src.tar.xz
fi

如果[! -e cfe-3.5.0.src.tar.xz];那么
wget http://llvm.org/releases/3.5.0/cfe-3.5.0.src.tar.xz
fi

如果[! -e compiler-rt-3.5.0.src.tar.xz];那么
wget http://llvm.org/releases/3.5.0/compiler-rt-3.5.0.src.tar.xz
fi

如果[! -e libcxx-3.5.0.src.tar.xz];然后
wget http://llvm.org/releases/3.5.0/libcxx-3.5.0.src.tar.xz
fi

如果[! -e libcxxabi-3.5.0.src.tar.xz];那么
wget http://llvm.org/releases/3.5.0/libcxxabi-3.5.0.src.tar.xz
fi

如果[! -e clang-tools-extra-3.5.0.src.tar.xz];然后
wget http://llvm.org/releases/3.5.0/clang-tools-extra-3.5.0.src.tar.xz
fi

#清理

echo清理工件
rm -rf llvm build llvm-3.5.0.src

#LLVM
echoUnpacking LLVM
tar xf llvm-3.5.0.src.tar.xz
mv llvm-3.5.0.src / llvm

#Clang前端
echoUnpacking Clang前端
cd llvm / tools
tar xf ../../cfe-3.5.0.src.tar.xz
mv cfe-3.5.0.src clang
cd ../../

#编译器RT
echoUnpacking 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 ../../

#额外工具
echo开箱额外工具
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 ++
echoUnpacking libc ++
cd llvm / projects
tar xf ../../libcxx-3.5.0.src.tar.xz
mv libcxx-3.5 .0.src / libcxx
cd ../../

#libc ++ ABI
echoUnpacking libc ++ ABI
cd llvm / projects
tar xf ../../libcxxabi-3.5.0.src.tar.xz
mv libcxxabi-3.5.0.src / libcxxabi
cd ../../

#确定Apple
IS_DARWIN =`uname -s | egrep -i -cDarwin`
if [$ IS_DARWIN -ne 0]; then
OTHER_OPTIONS =--enable-libcpp
fi

#配置
echo配置构建
mkdir -p build
cd build
../llvm/configure --enable-optimized --enable-cxx11 --with-libcxx --with-libcxxabi $ OTHER_OPTIONS --prefix = / usr / local

#Build
#libc ++的make cxx来自http://libcxx.llvm.org/
echoRunning make
make cxx
make -j2

RET = $?
if [$ RET -eq 0]; then
echo****************************** **********
read -p按[ENTER]安装,或按[CTRL] + C退出
sudo make install
fi

#****************************************
#****************************************

#安装不安装scan-build和scan-view
#执行副本和/或将它们放在路径

#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


解决方案

这是我用来构建libcxxabi和libcxx的脚本。它使用以前构建的Clang(使用GCC(在我的情况下为4.8.3)和GCC STL):

  if != 2)then 
echoUsage:[32 | 64]< directory>
exit
endif

set echo on

set CMake =< CMake executable>
set GCCDir =< recent GCC directory>
set LLVMSourceDir = $ {PWD} / llvm - $ {LLVM_VERSION} .src
set LLVMOutOfTreeSourceDir = $ {PWD}
set LLVMPass1Dir = $ {PWD} / pass1
set PythonDir =< Python目录>
set InstallDir = $ {PWD} / $ argv [2]

if($ argv [1] == 32)then
set GCC_EHDir = $ {GCCDir} / lib /gcc/x86_64-redhat-linux/4.8.3/32
set BuildMode = - m32
set LibDirSuffix =
else
set GCC_EHDir = $ {GCCDir} /lib/gcc/x86_64-redhat-linux/4.8.3
set BuildMode = - m64
set LibDirSuffix =64
endif

set BuildDir = libcxxabi.build

if(-d $ {BuildDir})then
rm -rf $ {BuildDir}
endif

mkdir $ {BuildDir }
cd $ {BuildDir}

$ {CMake} \
-DCMAKE_BUILD_TYPE =Release\
-DCMAKE_INSTALL_PREFIX:PATH = $ {InstallDir} \\ \\
-DCMAKE_C_COMPILER = $ {LLVMPass1Dir} / bin / clang \
-DCMAKE_C_FLAGS = $ {BuildMode} \
-DCMAKE_CXX_COMPILER = $ {LLVMPass1Dir} / bin / clang ++ \
-DCMAKE_CXX_FLAGS = $ {BuildMode} \
-DCMAKE_SHARED_LINKER_FLAGS = - L $ {GCC_EHDir}\
-DCMAKE_STATIC_LINKER_FLAGS =$ {GCC_EHDir} /libgcc_eh.a\
-DLLVM_FORCE_USE_OLD_TOOLCHAIN = YES \
-DLLVM_PATH = $ {LLVMSourceDir} \
-DLIBCXXABI_LIBCXX_INCLUDES = $ {LLVMOutOfTreeSourceDir} / libcxx - $ {LLVM_VERSION} .src / include \
-DLIBCXXABI_LIBCXX_PATH = $ {LLVMOutOfTreeSourceDir} / libcxx - $ {LLVM_VERSION} .src \
-DLIBCXXABI_LIBDIR_SUFFIX = $ {LibDirSuffix} \
$ {LLVMOutOfTreeSourceDir} / libcxxabi - $ {LLVM_VERSION} .src

make
make install

cd ..

set BuildDir = libcxx.build

if(-d $ { BuildDir})then
rm -rf $ {BuildDir}
endif

mkdir $ {BuildDir}
cd $ {BuildDir}

$ {CMake} \
-DCMAKE_BUILD_TYPE =Release\
-DCMAKE_INSTALL_PREFIX:PATH = $ {InstallDir} \
-DCMAKE_C_COMPILER = $ {LLVMPass1Dir} / bin / clang \
-DCMAKE_C_FLAGS = $ {BuildMode} \
-DCMAKE_CXX_COMPILER = $ {LLVMPass1Dir} / bin / clang ++ \
-DCMAKE_CXX_FLAGS = $ {BuildMode} \
-DCMAKE_SHARED_LINKER_FLAGS = -L $ {GCCDir} / lib $ {LibDirSuffix}\
-DLLVM_PATH = $ {LLVMSourceDir} \
-DLIBCXX_CXX_ABI = libcxxabi \
-DLIBCXX_CXX_ABI_INCLUDE_PATHS = $ {LLVMOutOfTreeSourceDir} /libcxxabi-${LLVM_VERSION}.src/include \
-DLIBCXX_CXX_ABI_LIBRARY_PATH = $ {InstallDir} / lib \
-DLIBCXX_LIBDIR_SUFFIX = $ {LibDirSuffix} \
-DLIT_EXECUTABLE = $ { LLVMSourceDir} /utils/lit/lit.py \
$ {LLVMOutOfTreeSourceDir} / libcxx - $ {LLVM_VERSION} .src

make
make install

cd ..


I'm trying to build Clang with libc++ from sources. And I'm trying to drop libc++ in-tree while building it out-of-tree with the other components. The recipe I use is below.

If I simply place libcxx and libcxxabi in-tree, then configure does not pick them up, and they are not built automatically. I placed them in llvm/projects per LLVM's libc++ Standard Library.

Additionally, adding make cxx to the recipe does not work as advertised on the LLVM's libc++ Standard Library page. It results in:

llvm[0]: Constructing LLVMBuild project information.
make: *** No rule to make target `cxx'.  Stop.

When I configure LLVM/Clang with --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

then I receive the following:

configure: WARNING: Unknown project (libcxx) won't be configured automatically
configure: WARNING: Unknown project (libcxxabi) won't be configured automatically

libcxx and libcxxabi are literally what LLVM calls them, so I'm not sure what names to use if they are not correct.

I tried to examine configure for what the package names should be, but its not very helpful. See below for the logic.

How do I configure and build Clang with libc++ (when libc++ and libc++ ABI are in-tree)?


Configure logic for --with-XXX is shown below.

this is all I can find (its not very helpful):

  -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 ;;


Related links:

And this Stack Overflow question is related: When is libc++ sources needed when building Clang from sources?

And this discussion of CFE-Dev mailing list: Questions about libc++ for linux and its git repository (if any). The thread says unpacking libcxx into llcm/projects ensures the headers are copied where Clang expects them during make install. But it does not address the --with-XXX question, it does not discuss why libc++ was not built, and it does not discuss how to get make install to actually install the libraries.


Recipe to fetch and build Clang. It works fine when not including 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

解决方案

This is script which I used to build libcxxabi and libcxx. It use previously built Clang (with GCC (4.8.3 in my case) and GCC STL):

if ( $#argv != 2 ) then
    echo "Usage: [32|64] <directory>"
    exit
endif

set echo on

set CMake=<CMake executable>
set GCCDir=<recent GCC directory>
set LLVMSourceDir=${PWD}/llvm-${LLVM_VERSION}.src
set LLVMOutOfTreeSourceDir=${PWD}
set LLVMPass1Dir=${PWD}/pass1
set PythonDir=<Python directory>
set InstallDir=${PWD}/$argv[2]

if ( $argv[1] == 32 ) then
    set GCC_EHDir=${GCCDir}/lib/gcc/x86_64-redhat-linux/4.8.3/32
    set BuildMode="-m32"
    set LibDirSuffix=""
else
    set GCC_EHDir=${GCCDir}/lib/gcc/x86_64-redhat-linux/4.8.3
    set BuildMode="-m64"
    set LibDirSuffix="64"
endif

set BuildDir=libcxxabi.build

if ( -d ${BuildDir} ) then
    rm -rf ${BuildDir}
endif

mkdir ${BuildDir}
cd ${BuildDir}

${CMake}                                                \
    -DCMAKE_BUILD_TYPE="Release"                                    \
    -DCMAKE_INSTALL_PREFIX:PATH=${InstallDir}                           \
    -DCMAKE_C_COMPILER=${LLVMPass1Dir}/bin/clang                            \
    -DCMAKE_C_FLAGS=${BuildMode}                                    \
    -DCMAKE_CXX_COMPILER=${LLVMPass1Dir}/bin/clang++                        \
    -DCMAKE_CXX_FLAGS=${BuildMode}                                  \
    -DCMAKE_SHARED_LINKER_FLAGS="-L ${GCC_EHDir}"                           \
    -DCMAKE_STATIC_LINKER_FLAGS="${GCC_EHDir}/libgcc_eh.a"                      \
    -DLLVM_FORCE_USE_OLD_TOOLCHAIN=YES                              \
    -DLLVM_PATH=${LLVMSourceDir}                                    \
    -DLIBCXXABI_LIBCXX_INCLUDES=${LLVMOutOfTreeSourceDir}/libcxx-${LLVM_VERSION}.src/include    \
    -DLIBCXXABI_LIBCXX_PATH=${LLVMOutOfTreeSourceDir}/libcxx-${LLVM_VERSION}.src            \
    -DLIBCXXABI_LIBDIR_SUFFIX=${LibDirSuffix}                           \
    ${LLVMOutOfTreeSourceDir}/libcxxabi-${LLVM_VERSION}.src

make
make install

cd ..

set BuildDir=libcxx.build

if ( -d ${BuildDir} ) then
    rm -rf ${BuildDir}
endif

mkdir ${BuildDir}
cd ${BuildDir}

${CMake}                                                \
    -DCMAKE_BUILD_TYPE="Release"                                    \
    -DCMAKE_INSTALL_PREFIX:PATH=${InstallDir}                           \
    -DCMAKE_C_COMPILER=${LLVMPass1Dir}/bin/clang                            \
    -DCMAKE_C_FLAGS=${BuildMode}                                    \
    -DCMAKE_CXX_COMPILER=${LLVMPass1Dir}/bin/clang++                        \
    -DCMAKE_CXX_FLAGS=${BuildMode}                                  \
    -DCMAKE_SHARED_LINKER_FLAGS="-L ${GCCDir}/lib${LibDirSuffix}"                   \
    -DLLVM_PATH=${LLVMSourceDir}                                    \
    -DLIBCXX_CXX_ABI=libcxxabi                                  \
    -DLIBCXX_CXX_ABI_INCLUDE_PATHS=${LLVMOutOfTreeSourceDir}/libcxxabi-${LLVM_VERSION}.src/include  \
    -DLIBCXX_CXX_ABI_LIBRARY_PATH=${InstallDir}/lib                         \
    -DLIBCXX_LIBDIR_SUFFIX=${LibDirSuffix}                              \
    -DLIT_EXECUTABLE=${LLVMSourceDir}/utils/lit/lit.py                      \
    ${LLVMOutOfTreeSourceDir}/libcxx-${LLVM_VERSION}.src

make
make install

cd ..

这篇关于未知的包libcxx和libcxxabi在构建Clang时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆