本文介绍了用于ARM/RaspberryPi的LLVM构建选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻求有关Raspbian上LLVM 3.2的最佳构建选项的说明

I'm seeking clarification of what the best build options are for LLVM 3.2 on Raspbian

我已经获取了3.2的LLVM源,我的配置是:

I've fetched the LLVM source of 3.2, and my config is:

cd llvm-3.2.src
./configure --build=armv6-unknown-linux-gnueabi \
--host=armv6-unknown-linux-gnueabi \
--target=armv6-unknown-linux-gnueabi --with-cpu=arm1176jzf-s \
--with-float=hard --with-abi=aapcs-vfp --with-fpu=neon \
--enable-targets=arm --enable-optimized --enable-assertions
make REQUIRES_RTTI=1
sudo make install

我听说要花很多时间才能完成.它已经运行了几个小时,很高兴让它运行.

I've heard it takes quite a number of hours to build. It's been running a few hours now, happy to just let it run though.

这是一个长期的构建项目,因此,如果需要的话,我对重新构建不感到沮丧:)

It's a long term build project so I have no qualms about redoing the build if needed :)

推荐答案

我建议为Raspbian交叉编译LLVM.在Pi本身上构建它需要花费很多时间.

I'd recommend cross-compiling LLVM for Raspbian. Building it on Pi itself takes ages.

首先,使用debootstrap获得有效的root fs(或者,仅克隆现有的Raspbian安装或解压缩下载的映像).您可能需要用相对替换一些绝对符号链接,当心构建错误.

First, get a working root fs using debootstrap (alternatively, just clone your existing Raspbian installation or unpack a downloaded image). You may need to replace some absolute symlinks with relative, watch out for build errors.

确保您已经安装了最新的clang,并且可以正常使用(不要忘了使用ARM目标支持对其进行构建).

Make sure you have a working and recent enough installation of clang (don't forget to build it with ARM target support).

然后,使用以下CMake工具链定义交叉编译LLVM(在此阶段,您不应将root更改为root fs!):

Then, cross-compile LLVM with the following CMake toolchain definition (you should not chroot into your root fs at this stage!):


set(toolchain_dir /path/to/your/chroot-raspbian-armhf/ )
set(toolchain_bin_dir ${toolchain_dir}/usr/bin)
set(toolchain_inc_dir ${toolchain_dir}/usr/include) # was /include
set(toolchain_lib_dir ${toolchain_dir}/usr/lib)

set(CMAKE_SYSTEM_NAME Linux CACHE INTERNAL "system name")
set(CMAKE_SYSTEM_PROCESSOR arm CACHE INTERNAL "processor")
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_C_FLAGS "-O2 -integrated-as -target armv6-linux-gnueabihf -mfloat-abi=hard --sysroot=${toolchain_dir}" CACHE INTERNAL "c compiler flags")
set(CMAKE_CXX_FLAGS "-O2 -integrated-as -target armv6-linux-gnueabihf -mfloat-abi=hard --sysroot=${toolchain_dir}" CACHE INTERNAL "cxx compiler flags")

set(link_flags "-L${toolchain_lib_dir} -ldl")

set(CMAKE_EXE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "exe link flags")
set(CMAKE_MODULE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "module link flags")
set(CMAKE_SHARED_LINKER_FLAGS ${link_flags} CACHE INTERNAL "shared link flags")
set(CMAKE_FIND_ROOT_PATH ${toolchain_lib_dir} CACHE INTERNAL "cross root directory")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH CACHE INTERNAL "")
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY CACHE INTERNAL "")
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY CACHE INTERNAL "")

(使用cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/the/file/above.txt)

请注意,目标应该是armv6-linux-gnueabihf,而不是armv6-linux-gnueabi.

Please note that target should be armv6-linux-gnueabihf, not armv6-linux-gnueabi.

这篇关于用于ARM/RaspberryPi的LLVM构建选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-17 00:26