[cfe-dev] How to compile Clang for ARM Linux on x86_64 Linux?
Anton Smirnov
dev at antonsmirnov.name
Sat Sep 28 11:29:29 PDT 2013
Hey. i've tried both options.
Unfortunately none of them works.
I will add detailed information below each of it.
2013/9/28 Renato Golin <renato.golin at linaro.org>
> On 28 September 2013 04:20, Anton Smirnov <dev at antonsmirnov.name> wrote:
>
>> Then configure and getting an error:
>> /usr/bin/c++ -target armv7a-linux-gnueabihf -mcpu=cortex-a9
>> -I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/
>> -I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name
>> arm-linux-gnueabihf-gcc -o
>> CMakeFiles/cmTryCompileExec1473115348.dir/testCXXCompiler.cxx.o -c
>> /home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
>>
>
> Yes, it's choosing the system compiler, which is clearly wrong.
>
> Since you should have "arm-linux-gnueabihf-gcc" on your path, I believe
> the CMake variable "LLVM_DEFAULT_TARGET_TRIPLE" doesn't work in the way I
> thought it would, in which case you'd have to force CC and CXX. During my
> examples, I was mainly using Clang to cross-compile, so I may have skipped
> a few steps to compile with GCC, in which case I'll have to fix the docs
> accordingly.
>
> You have two options now:
> 1. Fully compile Clang+LLVM to your host platform and use "CC=clang
> CXX=clang++ cmake ... " to configure your directory.
>
both clang and clang++ compiled for host are on path and working:
asmirnov at vmb:~/llvm_cmake_build$ CC=clang
asmirnov at vmb:~/llvm_cmake_build$ CXX=clang++
asmirnov at vmb:~/llvm_cmake_build$
PATH=/home/asmirnov/llvm_host_installed/bin:$PATH
asmirnov at vmb:~/llvm_cmake_build$ clang
clang: error: no input files
asmirnov at vmb:~/llvm_cmake_build$ clang++
clang: error: no input files
asmirnov at vmb:~/llvm_cmake_build$
But they are not able to configure using documented cmake:
asmirnov at vmb:~/llvm_cmake_build$ cmake ../llvm -DCMAKE_CROSSCOMPILING=True
-DCMAKE_INSTALL_PREFIX=/home/asmirnov/llvm_cmake_installed
-DLLVM_TABLEGEN=/home/asmirnov/llvm_host_build/Release+Asserts/bin/llvm-tblgen
-DCLANG_TABLEGEN=/home/asmirnov/llvm_host_build/Release+Asserts/bin/clang-tblgen
-DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM
-DLLVM_TARGETS_TO_BUILD=ARM -DCMAKE_CXX_FLAGS='-target
armv7a-linux-gnueabihf -mcpu=cortex-a9
-I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/
-I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name
arm-linux-gnueabihf-gcc'
-- The CXX compiler identification is unknown
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++ --
broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:54
(message):
The C++ compiler "/usr/bin/arm-linux-gnueabihf-g++" is not able to compile
a simple test program.
It fails with the following output:
Change Dir: /home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec3118678986/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec3118678986.dir/build.make
CMakeFiles/cmTryCompileExec3118678986.dir/build
make[1]: Entering directory
`/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object
CMakeFiles/cmTryCompileExec3118678986.dir/testCXXCompiler.cxx.o
/usr/bin/arm-linux-gnueabihf-g++ -target armv7a-linux-gnueabihf
-mcpu=cortex-a9
-I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/
-I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name
arm-linux-gnueabihf-gcc -o
CMakeFiles/cmTryCompileExec3118678986.dir/testCXXCompiler.cxx.o -c
/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
arm-linux-gnueabihf-g++: error: unrecognized command line option
‘-target’
arm-linux-gnueabihf-g++: error: armv7a-linux-gnueabihf: No such file or
directory
arm-linux-gnueabihf-g++: error: unrecognized command line option
‘-ccc-gcc-name’
arm-linux-gnueabihf-g++: error: arm-linux-gnueabihf-gcc: No such file or
directory
make[1]: Leaving directory
`/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp'
make[1]: ***
[CMakeFiles/cmTryCompileExec3118678986.dir/testCXXCompiler.cxx.o] Error 1
make: *** [cmTryCompileExec3118678986/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
-- Configuring incomplete, errors occurred!
> 2. Use "CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ cmake ...
> ", and if that works, I'll update the docs to say it's required.
>
asmirnov at vmb:~/llvm_cmake_build$ CC=arm-linux-gnueabihf-gcc
asmirnov at vmb:~/llvm_cmake_build$ CXX=arm-linux-gnueabihf-g++
asmirnov at vmb:~/llvm_cmake_build$ cmake ../llvm -DCMAKE_CROSSCOMPILING=True
-DCMAKE_INSTALL_PREFIX=/home/asmirnov/llvm_cmake_installed
-DLLVM_TABLEGEN=/home/asmirnov/llvm_host_build/Release+Asserts/bin/llvm-tblgen
-DCLANG_TABLEGEN=/home/asmirnov/llvm_host_build/Release+Asserts/bin/clang-tblgen
-DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM
-DLLVM_TARGETS_TO_BUILD=ARM -DCMAKE_CXX_FLAGS='-target
armv7a-linux-gnueabihf -mcpu=cortex-a9
-I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/
-I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name
arm-linux-gnueabihf-gcc'
-- The CXX compiler identification is unknown
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++ --
broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:54
(message):
The C++ compiler "/usr/bin/arm-linux-gnueabihf-g++" is not able to compile
a simple test program.
It fails with the following output:
Change Dir: /home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec2487419787/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec2487419787.dir/build.make
CMakeFiles/cmTryCompileExec2487419787.dir/build
make[1]: Entering directory
`/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object
CMakeFiles/cmTryCompileExec2487419787.dir/testCXXCompiler.cxx.o
/usr/bin/arm-linux-gnueabihf-g++ -target armv7a-linux-gnueabihf
-mcpu=cortex-a9
-I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/
-I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name
arm-linux-gnueabihf-gcc -o
CMakeFiles/cmTryCompileExec2487419787.dir/testCXXCompiler.cxx.o -c
/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
arm-linux-gnueabihf-g++: error: unrecognized command line option
‘-target’
arm-linux-gnueabihf-g++: error: armv7a-linux-gnueabihf: No such file or
directory
arm-linux-gnueabihf-g++: error: unrecognized command line option
‘-ccc-gcc-name’
arm-linux-gnueabihf-g++: error: arm-linux-gnueabihf-gcc: No such file or
directory
make[1]: Leaving directory
`/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp'
make[1]: ***
[CMakeFiles/cmTryCompileExec2487419787.dir/testCXXCompiler.cxx.o] Error 1
make: *** [cmTryCompileExec2487419787/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
-- Configuring incomplete, errors occurred!
In both cases g++ is targeted to compile for ARM and of coarse it fails to
check compilation possibility for host (as far as i understand the output).
It seems that this checking should be skipped because cross compilation
flag is set. Or i don't understand why it fails indeed.
> cheers,
> --renato
>
Thanks for suggestions, Renato.
I understand that's a little difficult to fix it in such way, but i agree
to do all you suggest in order to compile clang for ARM finally.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130929/05e5ddf7/attachment.html>
More information about the cfe-dev
mailing list