Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
488 views
in Technique[技术] by (71.8m points)

mips - CMake mips64 cross toolchain issue

Summary

I didn't manage to have a working mips64 toolchain file using the codespace toolchain...
Any help will be appreciated !

Setup

Here my setup, extracted from https://github.com/Mizux/cmake-cpp/blob/main/tools/cross_compile.sh

Get the toolchain:

local -r DATE=2019.02-04
local -r CODESCAPE_URL=https://codescape.mips.com/components/toolchain/${DATE}/Codescape.GNU.Tools.Package.${DATE}.for.MIPS.IMG.Linux.CentOS-6.x86_64.tar.gz
wget "${CODESCAPE_URL}"

ref:

Generated toolchain file toolchain_mips64.cmake:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR mips64)

set(CMAKE_SYSROOT /.../mips-img-linux-gnu/2019.02-04/sysroot/mips-r6-hard)
set(CMAKE_STAGING_PREFIX /.../mips-img-linux-gnu/2019.02-04/sysroot/mips-r6-hard-stage)

set(tools /.../mips-img-linux-gnu/2019.02-04)
set(CMAKE_C_COMPILER ${tools}/bin/mips-img-linux-gnu-gcc)
set(CMAKE_C_COMPILER_ARG "-EB -mabi=64")
set(CMAKE_CXX_COMPILER ${tools}/bin/mips-img-linux-gnu-g++)
#set(CMAKE_CXX_FLAGS "-EB -mabi=64")
set(CMAKE_CXX_FLAGS "-EB -mabi=64 -L/.../mips-img-linux-gnu/2019.02-04/sysroot/mips-r6-hard/usr/lib64")

set(CMAKE_FIND_ROOT_PATH /.../mips-img-linux-gnu/2019.02-04)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

Protocol

cmake -S. -Bbuild -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=/.../toolchain_mips64.cmake

note: If using my project cmake-cpp you can use TARGET=mips64 ./tools/cross_compile.sh build

Observed

-- The CXX compiler identification is GNU 7.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /.../mips-img-linux-gnu/2019.02-04/bin/mips-img-linux-gnu-g++
-- Check for working CXX compiler: /.../mips-img-linux-gnu/2019.02-04/bin/mips-img-linux-gnu-g++ - broken
CMake Error at /usr/share/cmake-3.19/Modules/CMakeTestCXXCompiler.cmake:59 (message):
  The C++ compiler

    "/.../mips-img-linux-gnu/2019.02-04/bin/mips-img-linux-gnu-g++"

  is not able to compile a simple test program.
[...]
    Linking CXX executable cmTC_0d3cc
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_0d3cc.dir/link.txt --verbose=1
    /.../mips-img-linux-gnu/2019.02-04/bin/mips-img-linux-gnu-g++ --sysroot=/.../mips-img-linux-gnu/2019.02-04/sysroot/mips-r6-hard -EB -mabi=64 -L/.../mips-img-linux-gnu/2019.02-04/sysroot/mips-r6-hard/usr/lib64  CMakeFiles/cmTC_0d3cc.dir/testCXXCompiler.cxx.o -o cmTC_0d3cc 
    /.../mips-img-linux-gnu/2019.02-04/bin/../lib/gcc/mips-img-linux-gnu/7.4.0/../../../../mips-img-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory
    /.../mips-img-linux-gnu/2019.02-04/bin/../lib/gcc/mips-img-linux-gnu/7.4.0/../../../../mips-img-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
    collect2: error: ld returned 1 exit status
    make[1]: *** [CMakeFiles/cmTC_0d3cc.dir/build.make:106: cmTC_0d3cc] Error 1

FYI

find . -iname "crt1.o"
./mips-img-linux-gnu/2019.02-04/sysroot/mipsel-r6-soft/usr/lib/crt1.o
./mips-img-linux-gnu/2019.02-04/sysroot/micromips-r6-hard/usr/lib/crt1.o
./mips-img-linux-gnu/2019.02-04/sysroot/mips-r6-hard/usr/lib64/crt1.o
./mips-img-linux-gnu/2019.02-04/sysroot/mips-r6-hard/usr/lib32/crt1.o
./mips-img-linux-gnu/2019.02-04/sysroot/mips-r6-hard/usr/lib/crt1.o
./mips-img-linux-gnu/2019.02-04/sysroot/micromips-r6-soft/usr/lib/crt1.o
./mips-img-linux-gnu/2019.02-04/sysroot/mips-r6-soft/usr/lib64/crt1.o
./mips-img-linux-gnu/2019.02-04/sysroot/mips-r6-soft/usr/lib32/crt1.o
./mips-img-linux-gnu/2019.02-04/sysroot/mips-r6-soft/usr/lib/crt1.o
./mips-img-linux-gnu/2019.02-04/sysroot/micromipsel-r6-hard/usr/lib/crt1.o
./mips-img-linux-gnu/2019.02-04/sysroot/mipsel-r6-hard/usr/lib64/crt1.o
./mips-img-linux-gnu/2019.02-04/sysroot/mipsel-r6-hard/usr/lib32/crt1.o
./mips-img-linux-gnu/2019.02-04/sysroot/mipsel-r6-hard/usr/lib/crt1.o
./mips-img-linux-gnu/2019.02-04/sysroot/micromipsel-r6-soft/usr/lib/crt1.o

note: That's why I tried to add a -L/.../mips-r6-hard/usr/lib64/ without success...

Expected

Configure pass i.e. CMake manage to build a "simple" CXX program...

question from:https://stackoverflow.com/questions/65889221/cmake-mips64-cross-toolchain-issue

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...