[cfe-dev] Trouble cross compiling clang/llvm using clang/llvm

Vince Harron vharron at google.com
Mon Dec 8 20:49:54 PST 2014


Hi all,

Long time fan, first time caller.

I'm trying to generate an arm->arm clang using the instructions here:

http://llvm.org/docs/HowToCrossCompileLLVM.html

I've had to make some minor modifications for my environment

CC='clang' \

CXX='clang++' \

cmake -G Ninja \

../llvm \

-DCMAKE_CROSSCOMPILING=True \

-DCMAKE_INSTALL_PREFIX:PATH=$ROOT_DIR/install \

-DLLVM_TABLEGEN=$HOME/bin/llvm-tblgen \

-DCLANG_TABLEGEN=$HOME/bin/clang-tblgen \

-DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf \

-DLLVM_TARGET_ARCH=ARM \

-DLLVM_TARGETS_TO_BUILD=ARM \

-DCMAKE_CXX_FLAGS='-target arm-linux-gnueabihf -mcpu=cortex-a9
-I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/
-I/usr/arm-linux-gnueabihf/include/c++/4.7.3/
-I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name
arm-linux-gnueabihf-gcc-4.7' \

-DCMAKE_BUILD_TYPE=Release \

-DLLVM_ENABLE_PIC=False \

-Wno-dev

I've tried clang 3.5, clang tot
I've tried arm-linux-gnueabihf 4.7.3 (ubuntu) and 4.9.2 (Linaro)

I'm getting this error:

-- Performing Test LLVM_NO_OLD_LIBSTDCXX

-- Performing Test LLVM_NO_OLD_LIBSTDCXX - Failed

CMake Error at cmake/modules/HandleLLVMOptions.cmake:38 (message):

 Host Clang must be able to find libstdc++4.7 or newer!

Call Stack (most recent call first):

 CMakeLists.txt:339 (include)

Checking into the cmake logs, it's trying to compile this program, which I
can build just fine:

vharron at tifa:~/ll/cross/build$ cat test.cpp
#include <atomic>
std::atomic<float> x(0.0f);
int main() { return (float)x; }

vharron at tifa:~/ll/cross/build$ clang++ -std=c++0x test.cpp -target
arm-linux-gnueabihf -mcpu=cortex-a9
-I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/
-I/usr/arm-linux-gnueabihf/include/c++/4.7.3/
-I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name
arm-linux-gnueabihf-gcc-4.7

vharron at tifa:~/ll/cross/build$ file a.out
a.out: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), dynamically
linked (uses shared libs), for GNU/Linux 2.6.32,
BuildID[sha1]=c998b71c4d3a063e0f8804f24b47303455318cf2, not stripped


The docs for check_cxx_source_compiles
http://www.cmake.org/cmake/help/v3.0/module/CheckCXXSourceCompiles.html
say that you can modify the way check is run by setting CMAKE_REQUIRED_FLAGS
so I tried that, but it didn't help.

How can I figure out what command line check_cxx_source_compiles is using?

diff --git a/cmake/modules/HandleLLVMOptions.cmake
b/cmake/modules/HandleLLVMOptions.cmake
index 2ee0dd5..c949f5d 100644
--- a/cmake/modules/HandleLLVMOptions.cmake
+++ b/cmake/modules/HandleLLVMOptions.cmake
@@ -28,7 +28,8 @@ if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)
     if(NOT LLVM_ENABLE_LIBCXX)
       set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
       set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
-      set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
+      set(CMAKE_REQUIRED_FLAGS "-std=c++0x " ${CMAKE_CXX_FLAGS} )
+      message( CMAKE_REQUIRED_FLAGS = ${CMAKE_REQUIRED_FLAGS} )
       check_cxx_source_compiles("
 #include <atomic>
 std::atomic<float> x(0.0f);

There are several more check_cxx_source_compiles failures.  I can get past
them if I hack them all out but I'm looking for the "right" way.

Thanks,

Vince


-- 

Vince Harron | Technical Lead Manager | vharron at google.com | 858-442-0868
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141208/59c2eea2/attachment.html>


More information about the cfe-dev mailing list