TI cl2000 cmake CXX编译器标识未知
TI cl2000 cmake CXX compiler identification is unknown
我正在尝试使用来自 TI 的 cl2000.exe compiler/linker 进行交叉编译,但我遇到了 CMake compiling/linking 其简单测试程序的问题。
我使用的工具链文件是(从this gist复制):
set(TI_TOOLCHAIN_DIR "C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS")
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
# toolchain paths
find_program(TI_GCC NAMES cl2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
find_program(TI_CXX NAMES cl2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
find_program(TI_AS NAMES cl2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
find_program(TI_AR NAMES ar2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
find_program(TI_OBJCOPY NAMES ofd2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
find_program(TI_OBJDUMP NAMES hex2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
find_program(TI_SIZE NAMES size2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
find_program(TI_LD NAMES cl2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
# set executables settings
set(CMAKE_C_COMPILER ${TI_GCC})
set(CMAKE_CXX_COMPILER ${TI_CXX})
set(AS ${TI_AS})
set(AR ${TI_AR})
set(OBJCOPY ${TI_OBJCOPY})
set(OBJDUMP ${TI_OBJDUMP})
set(SIZE ${TI_SIZE})
set(LD ${TI_LD})
它似乎正确地将 C 编译器检测为 TI,而不是 CXX 编译器:
$ cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain-cl2000.cmake -G "Unix Makefiles" ..
-- The C compiler identification is TI
-- The CXX compiler identification is unknown
-- Check for working C compiler: C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe
-- Check for working C compiler: C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe
-- Check for working CXX compiler: C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeTestCXXCompiler.cmake:53 (message):
The C++ compiler
"C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/src/company/proj/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/PROGRA~2/GnuWin32/bin/make.exe cmTC_13e15/fast && C:/PROGRA~2/GnuWin32/bin/make.exe -f CMakeFiles/cmTC_13e15.dir/build.make CMakeFiles/cmTC_13e15.dir/build
make.exe[1]: Entering directory `C:/src/company/proj/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_13e15.dir/testCXXCompiler.cxx.obj
C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe -o CMakeFiles/cmTC_13e15.dir/testCXXCompiler.cxx.obj -c "C:/src/company/proj/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx"
[testCXXCompiler.cxx]
>> WARNING: object file specified, but linking not enabled
Linking CXX executable cmTC_13e15
C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe "CMakeFiles/cmTC_13e15.dir/testCXXCompiler.cxx.obj" -o cmTC_13e15
[cmTC_13e15.]
>> WARNING: object file specified, but linking not enabled
Fatal error: cannot open source file "cmTC_13e15"
1 catastrophic error detected in the compilation of "cmTC_13e15".
Compilation terminated.
>> Compilation failure
make.exe[1]: *** [cmTC_13e15] Error 1
make.exe[1]: Leaving directory `C:/src/company/proj/build/CMakeFiles/CMakeTmp'
make.exe: *** [cmTC_13e15/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
我试过:
set(CMAKE_EXE_LINKER_FLAGS "-z")
- 导致从编译器命令行调用链接器。
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -eo=cxx.obj")
- 这解决了
cl2000.exe
从 .cxx.obj
简单测试程序中删除 .cxx
的问题。
启用 -z
标志只会产生以下错误:
<Linking>
"C:\Users\user\AppData\Local\Temp\{F59696C9-9FC5-441B-8BA5-AC3022232249}", line 5: error:
cannot find file "CMakeFiles/cmTC_d4b00.dir/testCXXCompiler.cxx.obj"
fatal error: no input files
然后添加-eo=cxx.obj
选项也产生同样的错误。
有没有人使用 CMake 和 cl2000
成功交叉编译 C/C++?
问题是 cl2000
编译器生成 .obj
文件,其中编译器信息字符串为 UTF-16BE,CMake 假定它们为 UTF-8。 CMake 3.16.0 中计划包含一个修复程序,CMake 现在将为 cl2000
编译器正确检测 C 和 CXX 编译器标识。
有关详细信息,请参阅 issue and the merge request。
我正在尝试使用来自 TI 的 cl2000.exe compiler/linker 进行交叉编译,但我遇到了 CMake compiling/linking 其简单测试程序的问题。
我使用的工具链文件是(从this gist复制):
set(TI_TOOLCHAIN_DIR "C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS")
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
# toolchain paths
find_program(TI_GCC NAMES cl2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
find_program(TI_CXX NAMES cl2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
find_program(TI_AS NAMES cl2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
find_program(TI_AR NAMES ar2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
find_program(TI_OBJCOPY NAMES ofd2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
find_program(TI_OBJDUMP NAMES hex2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
find_program(TI_SIZE NAMES size2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
find_program(TI_LD NAMES cl2000 PATHS ${TI_TOOLCHAIN_DIR}/bin NO_DEFAULT_PATH)
# set executables settings
set(CMAKE_C_COMPILER ${TI_GCC})
set(CMAKE_CXX_COMPILER ${TI_CXX})
set(AS ${TI_AS})
set(AR ${TI_AR})
set(OBJCOPY ${TI_OBJCOPY})
set(OBJDUMP ${TI_OBJDUMP})
set(SIZE ${TI_SIZE})
set(LD ${TI_LD})
它似乎正确地将 C 编译器检测为 TI,而不是 CXX 编译器:
$ cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain-cl2000.cmake -G "Unix Makefiles" ..
-- The C compiler identification is TI
-- The CXX compiler identification is unknown
-- Check for working C compiler: C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe
-- Check for working C compiler: C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe
-- Check for working CXX compiler: C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeTestCXXCompiler.cmake:53 (message):
The C++ compiler
"C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/src/company/proj/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/PROGRA~2/GnuWin32/bin/make.exe cmTC_13e15/fast && C:/PROGRA~2/GnuWin32/bin/make.exe -f CMakeFiles/cmTC_13e15.dir/build.make CMakeFiles/cmTC_13e15.dir/build
make.exe[1]: Entering directory `C:/src/company/proj/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_13e15.dir/testCXXCompiler.cxx.obj
C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe -o CMakeFiles/cmTC_13e15.dir/testCXXCompiler.cxx.obj -c "C:/src/company/proj/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx"
[testCXXCompiler.cxx]
>> WARNING: object file specified, but linking not enabled
Linking CXX executable cmTC_13e15
C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe "CMakeFiles/cmTC_13e15.dir/testCXXCompiler.cxx.obj" -o cmTC_13e15
[cmTC_13e15.]
>> WARNING: object file specified, but linking not enabled
Fatal error: cannot open source file "cmTC_13e15"
1 catastrophic error detected in the compilation of "cmTC_13e15".
Compilation terminated.
>> Compilation failure
make.exe[1]: *** [cmTC_13e15] Error 1
make.exe[1]: Leaving directory `C:/src/company/proj/build/CMakeFiles/CMakeTmp'
make.exe: *** [cmTC_13e15/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
我试过:
set(CMAKE_EXE_LINKER_FLAGS "-z")
- 导致从编译器命令行调用链接器。
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -eo=cxx.obj")
- 这解决了
cl2000.exe
从.cxx.obj
简单测试程序中删除.cxx
的问题。
- 这解决了
启用 -z
标志只会产生以下错误:
<Linking>
"C:\Users\user\AppData\Local\Temp\{F59696C9-9FC5-441B-8BA5-AC3022232249}", line 5: error:
cannot find file "CMakeFiles/cmTC_d4b00.dir/testCXXCompiler.cxx.obj"
fatal error: no input files
然后添加-eo=cxx.obj
选项也产生同样的错误。
有没有人使用 CMake 和 cl2000
成功交叉编译 C/C++?
问题是 cl2000
编译器生成 .obj
文件,其中编译器信息字符串为 UTF-16BE,CMake 假定它们为 UTF-8。 CMake 3.16.0 中计划包含一个修复程序,CMake 现在将为 cl2000
编译器正确检测 C 和 CXX 编译器标识。
有关详细信息,请参阅 issue and the merge request。