From 9ba0a54554c15fe28ea0612c6e166ad114c87cda Mon Sep 17 00:00:00 2001 From: Alan Phipps Date: Wed, 6 Dec 2023 12:53:02 -0600 Subject: TIClang: Add support for TI Clang-based compilers, including tiarmclang Add TIClang compiler ID and support in compiler modules. Update documentation. Add rudimentary RunCMake test for TIClang to test basic functionality. Fixes: #24619 --- Help/manual/cmake-compile-features.7.rst | 1 + Help/release/3.29.rst | 3 ++ Help/variable/CMAKE_LANG_COMPILER_ID.rst | 2 + Modules/CMakeCompilerIdDetection.cmake | 1 + Modules/CMakeDetermineASMCompiler.cmake | 4 ++ Modules/CMakeDetermineCCompiler.cmake | 5 ++ Modules/CMakeDetermineCXXCompiler.cmake | 5 ++ Modules/CMakeDetermineCompilerId.cmake | 3 +- Modules/CMakePlatformId.h.in | 8 ++++ Modules/Compiler/TIClang-ASM.cmake | 9 ++++ Modules/Compiler/TIClang-C-FeatureTests.cmake | 1 + Modules/Compiler/TIClang-C.cmake | 23 +++++++++ Modules/Compiler/TIClang-CXX-FeatureTests.cmake | 1 + Modules/Compiler/TIClang-CXX.cmake | 25 ++++++++++ Modules/Compiler/TIClang-DetermineCompiler.cmake | 10 ++++ Modules/Compiler/TIClang.cmake | 30 ++++++++++++ Tests/RunCMake/CMakeLists.txt | 6 +++ Tests/RunCMake/TIClang/CMakeLists.txt | 3 ++ Tests/RunCMake/TIClang/RunCMakeTest.cmake | 61 ++++++++++++++++++++++++ Tests/RunCMake/TIClang/libmod.c | 4 ++ Tests/RunCMake/TIClang/module.c | 14 ++++++ Tests/RunCMake/TIClang/module.cxx | 7 +++ Tests/RunCMake/TIClang/module.h | 12 +++++ Tests/RunCMake/TIClang/module.s | 9 ++++ Tests/RunCMake/TIClang/ticlang-asm.cmake | 5 ++ Tests/RunCMake/TIClang/ticlang-c.cmake | 5 ++ Tests/RunCMake/TIClang/ticlang-cxx.cmake | 5 ++ Tests/RunCMake/TIClang/ticlang-lib.cmake | 10 ++++ 28 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 Modules/Compiler/TIClang-ASM.cmake create mode 100644 Modules/Compiler/TIClang-C-FeatureTests.cmake create mode 100644 Modules/Compiler/TIClang-C.cmake create mode 100644 Modules/Compiler/TIClang-CXX-FeatureTests.cmake create mode 100644 Modules/Compiler/TIClang-CXX.cmake create mode 100644 Modules/Compiler/TIClang-DetermineCompiler.cmake create mode 100644 Modules/Compiler/TIClang.cmake create mode 100644 Tests/RunCMake/TIClang/CMakeLists.txt create mode 100644 Tests/RunCMake/TIClang/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/TIClang/libmod.c create mode 100644 Tests/RunCMake/TIClang/module.c create mode 100644 Tests/RunCMake/TIClang/module.cxx create mode 100644 Tests/RunCMake/TIClang/module.h create mode 100644 Tests/RunCMake/TIClang/module.s create mode 100644 Tests/RunCMake/TIClang/ticlang-asm.cmake create mode 100644 Tests/RunCMake/TIClang/ticlang-c.cmake create mode 100644 Tests/RunCMake/TIClang/ticlang-cxx.cmake create mode 100644 Tests/RunCMake/TIClang/ticlang-lib.cmake diff --git a/Help/manual/cmake-compile-features.7.rst b/Help/manual/cmake-compile-features.7.rst index 1e87ec6..fb93222 100644 --- a/Help/manual/cmake-compile-features.7.rst +++ b/Help/manual/cmake-compile-features.7.rst @@ -266,6 +266,7 @@ versions specified for each: * ``PGI``: PGI version 12.10+. * ``NVHPC``: NVIDIA HPC compilers version 11.0+. * ``TI``: Texas Instruments compiler. +* ``TIClang``: Texas Instruments Clang-based compilers. * ``XL``: IBM XL version 10.1+. CMake is currently aware of the :prop_tgt:`C standards ` and diff --git a/Help/release/3.29.rst b/Help/release/3.29.rst index a655f62..96f161f 100644 --- a/Help/release/3.29.rst +++ b/Help/release/3.29.rst @@ -39,6 +39,9 @@ Compilers * The LLVM/Clang GNU-like frontend on Windows (``clang++``) may now be used to compile ``CUDA`` language sources. +* TI Clang-based compilers are now supported with + :variable:`compiler id _COMPILER_ID>` ``TIClang``. + Commands -------- diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index 6893eea..b1e2687 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -43,6 +43,7 @@ Value Name ``SunPro`` Oracle Solaris Studio ``Tasking`` `Tasking Compiler Toolsets`_ ``TI`` Texas Instruments +``TIClang`` `Texas Instruments Clang-based Compilers`_ ``TinyCC`` `Tiny C Compiler`_ ``XL``, ``VisualAge``, ``zOS`` IBM XL ``XLClang`` IBM Clang-based XL @@ -68,3 +69,4 @@ languages. .. _Small Device C Compiler: https://sdcc.sourceforge.net .. _Tiny C Compiler: https://bellard.org/tcc .. _Tasking Compiler Toolsets: https://www.tasking.com +.. _Texas Instruments Clang-based Compilers: https://www.ti.com/tool/download/ARM-CGT-CLANG diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index e4fa43f..2817d37 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -80,6 +80,7 @@ function(compiler_id_detection outvar lang) ARMCC AppleClang ARMClang + TIClang ) list(APPEND ordered_compilers Clang diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 6d7d17e..2042e64 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -102,6 +102,10 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_TI "-h") set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_TI "Texas Instruments") + list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS TIClang ) + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_TIClang "--version") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_TIClang "(TI (.*) Clang Compiler)") + list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS IAR) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_IAR ) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_IAR "IAR Assembler") diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 8beebc5..73b6cee 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -166,6 +166,11 @@ if (NOT _CMAKE_TOOLCHAIN_PREFIX) set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) set(_CMAKE_TOOLCHAIN_SUFFIX ${CMAKE_MATCH_4}) set(_CMAKE_COMPILER_SUFFIX ${CMAKE_MATCH_6}) + elseif(CMAKE_C_COMPILER_ID MATCHES "TIClang") + if (COMPILER_BASENAME MATCHES "^(.+)?clang(\\.exe)?$") + set(_CMAKE_TOOLCHAIN_PREFIX "${CMAKE_MATCH_1}") + set(_CMAKE_TOOLCHAIN_SUFFIX "${CMAKE_MATCH_2}") + endif() elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") if(CMAKE_C_COMPILER_TARGET) set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_C_COMPILER_TARGET}-) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 40934ec..891ba6e 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -171,6 +171,11 @@ if (NOT _CMAKE_TOOLCHAIN_PREFIX) set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) set(_CMAKE_TOOLCHAIN_SUFFIX ${CMAKE_MATCH_3}) set(_CMAKE_COMPILER_SUFFIX ${CMAKE_MATCH_5}) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "TIClang") + if (COMPILER_BASENAME MATCHES "^(.+)?clang(\\.exe)?$") + set(_CMAKE_TOOLCHAIN_PREFIX "${CMAKE_MATCH_1}") + set(_CMAKE_TOOLCHAIN_SUFFIX "${CMAKE_MATCH_2}") + endif() elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(CMAKE_CXX_COMPILER_TARGET) set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_CXX_COMPILER_TARGET}-) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 25aacca..1cf1e79 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -280,7 +280,8 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) endif() elseif("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xGNU" OR "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xAppleClang" - OR "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xFujitsuClang") + OR "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xFujitsuClang" + OR "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xTIClang") set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU") elseif("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xMSVC") set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "MSVC") diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index 32b7166..fd0367e 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -219,6 +219,14 @@ # define ARCHITECTURE_ID "" # endif +#elif defined(__clang__) && defined(__ti__) +# if defined(__ARM_ARCH) +# define ARCHITECTURE_ID "Arm" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + #elif defined(__TI_COMPILER_VERSION__) # if defined(__TI_ARM__) # define ARCHITECTURE_ID "ARM" diff --git a/Modules/Compiler/TIClang-ASM.cmake b/Modules/Compiler/TIClang-ASM.cmake new file mode 100644 index 0000000..6bb07e3 --- /dev/null +++ b/Modules/Compiler/TIClang-ASM.cmake @@ -0,0 +1,9 @@ +include(Compiler/TIClang) + +set(CMAKE_ASM_OUTPUT_EXTENSION ".o") +set(CMAKE_ASM_OUTPUT_EXTENSION_REPLACE 1) + +set(CMAKE_ASM_COMPILE_OBJECT " -c -o ") +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS S;s;asm;msa) + +__compiler_ticlang(ASM) diff --git a/Modules/Compiler/TIClang-C-FeatureTests.cmake b/Modules/Compiler/TIClang-C-FeatureTests.cmake new file mode 100644 index 0000000..ef79229 --- /dev/null +++ b/Modules/Compiler/TIClang-C-FeatureTests.cmake @@ -0,0 +1 @@ +include(Compiler/Clang-C-FeatureTests) diff --git a/Modules/Compiler/TIClang-C.cmake b/Modules/Compiler/TIClang-C.cmake new file mode 100644 index 0000000..2721fef --- /dev/null +++ b/Modules/Compiler/TIClang-C.cmake @@ -0,0 +1,23 @@ +include(Compiler/Clang-C) +include(Compiler/TIClang) +__compiler_ticlang(C) + +if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_C) + # dependencies are computed by the compiler itself + set(CMAKE_C_DEPFILE_FORMAT gcc) + set(CMAKE_C_DEPENDS_USE_COMPILER TRUE) +endif() + +set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") +set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") +set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) + +set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") +set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") +set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) + +set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") +set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") +set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) diff --git a/Modules/Compiler/TIClang-CXX-FeatureTests.cmake b/Modules/Compiler/TIClang-CXX-FeatureTests.cmake new file mode 100644 index 0000000..e038e80 --- /dev/null +++ b/Modules/Compiler/TIClang-CXX-FeatureTests.cmake @@ -0,0 +1 @@ +include(Compiler/Clang-CXX-FeatureTests) diff --git a/Modules/Compiler/TIClang-CXX.cmake b/Modules/Compiler/TIClang-CXX.cmake new file mode 100644 index 0000000..860bb42 --- /dev/null +++ b/Modules/Compiler/TIClang-CXX.cmake @@ -0,0 +1,25 @@ +include(Compiler/Clang-CXX) +include(Compiler/TIClang) +__compiler_ticlang(CXX) + +if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_CXX) + # dependencies are computed by the compiler itself + set(CMAKE_CXX_DEPFILE_FORMAT gcc) + set(CMAKE_CXX_DEPENDS_USE_COMPILER TRUE) +endif() + +set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") +set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") +set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) + +set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") +set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") + +set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") +set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") +set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) + +set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17") +set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") diff --git a/Modules/Compiler/TIClang-DetermineCompiler.cmake b/Modules/Compiler/TIClang-DetermineCompiler.cmake new file mode 100644 index 0000000..2447fdf --- /dev/null +++ b/Modules/Compiler/TIClang-DetermineCompiler.cmake @@ -0,0 +1,10 @@ +# TI Clang-based Toolchains +set(_compiler_id_pp_test "defined(__clang__) && defined(__ti__)") + +set(_compiler_id_version_compute " + # define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__ti_major__) + # define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__ti_minor__) + # define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__ti_patchlevel__)") + +string(APPEND _compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__ti_version__)") diff --git a/Modules/Compiler/TIClang.cmake b/Modules/Compiler/TIClang.cmake new file mode 100644 index 0000000..4965e62 --- /dev/null +++ b/Modules/Compiler/TIClang.cmake @@ -0,0 +1,30 @@ +if(__COMPILER_TICLANG) + return() +endif() +set(__COMPILER_TICLANG TRUE) + +include(Compiler/CMakeCommonCompilerMacros) + +# get linker supported cpu list +macro(__compiler_ticlang lang) + set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-Xlinker ") + + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE " -E > ") + + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE " -S -o ") + + set(CMAKE_${lang}_COMPILE_OBJECT " -c -o ") + + set(CMAKE_${lang}_LINK_EXECUTABLE " -Xlinker --output_file= -Xlinker --map_file=.map -Xlinker --rom_model ") + + set(CMAKE_${lang}_ARCHIVE_CREATE " cr ") + set(CMAKE_${lang}_ARCHIVE_APPEND " r ") + set(CMAKE_${lang}_ARCHIVE_FINISH "") + + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP) +endmacro() + +set(CMAKE_EXECUTABLE_SUFFIX ".out") +set(CMAKE_LIBRARY_PATH_FLAG "-Wl,--search_path=") +set(CMAKE_LINK_LIBRARY_FLAG "-Wl,--library=") diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 3e22247..d9090d6 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -1177,3 +1177,9 @@ if(CMake_TEST_IAR_TOOLCHAINS) add_RunCMake_test(IAR -DCMake_TEST_IAR_TOOLCHAINS=${CMake_TEST_IAR_TOOLCHAINS}) set_property(TEST RunCMake.IAR APPEND PROPERTY LABELS "IAR") endif() +if(CMake_TEST_TICLANG_TOOLCHAINS) + # This is necessary to preserve the LIST variable contents given by user. + string(REPLACE ";" "$" TOOLCHAINS "${CMake_TEST_TICLANG_TOOLCHAINS}") + add_RunCMake_test(TIClang "-DCMake_TEST_TICLANG_TOOLCHAINS=${TOOLCHAINS}") + set_property(TEST RunCMake.TIClang APPEND PROPERTY LABELS "TIClang") +endif() diff --git a/Tests/RunCMake/TIClang/CMakeLists.txt b/Tests/RunCMake/TIClang/CMakeLists.txt new file mode 100644 index 0000000..94e43ba --- /dev/null +++ b/Tests/RunCMake/TIClang/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.29) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/TIClang/RunCMakeTest.cmake b/Tests/RunCMake/TIClang/RunCMakeTest.cmake new file mode 100644 index 0000000..898de74 --- /dev/null +++ b/Tests/RunCMake/TIClang/RunCMakeTest.cmake @@ -0,0 +1,61 @@ +include(RunCMake) + +# Test expects to be given a LIST of toolchain directories where a TIClang +# compiler binary is expected to be found relative to the "bin" directory: +# "-DCMake_TEST_TICLANG_TOOLCHAINS=;;" +if(RunCMake_GENERATOR MATCHES "Makefile|Ninja") + set(_ticlang_toolchains "${CMake_TEST_TICLANG_TOOLCHAINS}" ) +endif() + +function(run_toolchain case) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) + run_cmake_with_options(${case} ${ARGN}) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${case}-build ${CMAKE_COMMAND} --build .) +endfunction() + +foreach(_ticlang_toolchain_path IN LISTS _ticlang_toolchains) + file(GLOB _ticlang_toolchain "${_ticlang_toolchain_path}/bin/*clang" ) + if(_ticlang_toolchain STREQUAL "") + message(WARNING + "Could not find a TIClang toolchain at: ${_ticlang_toolchain_path}.") + continue() + endif() + + message(STATUS "Found TIClang toolchain: ${_ticlang_toolchain}") + + if(_ticlang_toolchain MATCHES "tiarmclang") + set(LINK_OPTS "--use_memcpy=fast,--use_memset=fast,-llnk.cmd") + set(CMAKE_FLAGS "-mcpu=cortex-r5 -Oz") + else() + set(CMAKE_FLAGS "") + set(LINK_OPTS "") + endif() + + run_toolchain(ticlang-c + -DCMAKE_SYSTEM_NAME=Generic + -DCMAKE_C_COMPILER=${_ticlang_toolchain} + -DCMAKE_C_FLAGS=${CMAKE_FLAGS} + -DCMAKE_C_LINKER_FLAGS=${LINK_OPTS} + ) + + run_toolchain(ticlang-cxx + -DCMAKE_SYSTEM_NAME=Generic + -DCMAKE_CXX_COMPILER=${_ticlang_toolchain} + -DCMAKE_CXX_FLAGS=${CMAKE_FLAGS} + -DCMAKE_CXX_LINKER_FLAGS=${LINK_OPTS} + ) + + run_toolchain(ticlang-asm + -DCMAKE_SYSTEM_NAME=Generic + -DCMAKE_ASM_COMPILER=${_ticlang_toolchain} + -DCMAKE_ASM_FLAGS=${CMAKE_FLAGS} + ) + + run_toolchain(ticlang-lib + -DCMAKE_SYSTEM_NAME=Generic + -DCMAKE_C_COMPILER=${_ticlang_toolchain} + -DCMAKE_C_FLAGS=${CMAKE_FLAGS} + -DCMAKE_C_LINKER_FLAGS=${LINK_OPTS} + ) +endforeach() diff --git a/Tests/RunCMake/TIClang/libmod.c b/Tests/RunCMake/TIClang/libmod.c new file mode 100644 index 0000000..50666c9 --- /dev/null +++ b/Tests/RunCMake/TIClang/libmod.c @@ -0,0 +1,4 @@ +int ticlang_libfun() +{ + return 42; +} diff --git a/Tests/RunCMake/TIClang/module.c b/Tests/RunCMake/TIClang/module.c new file mode 100644 index 0000000..46d7571 --- /dev/null +++ b/Tests/RunCMake/TIClang/module.c @@ -0,0 +1,14 @@ +#include "module.h" +#if defined(__USE_LIBFUN) +extern int ticlang_libfun(); +#endif +int i; +int main() +{ +#if defined(__USE_LIBFUN) + i = ticlang_libfun(); +#else + i = INTERNAL; +#endif + return i; +} diff --git a/Tests/RunCMake/TIClang/module.cxx b/Tests/RunCMake/TIClang/module.cxx new file mode 100644 index 0000000..b4d46b1 --- /dev/null +++ b/Tests/RunCMake/TIClang/module.cxx @@ -0,0 +1,7 @@ +#include "module.h" +int i; +int main() +{ + i = INTERNAL; + return i; +} diff --git a/Tests/RunCMake/TIClang/module.h b/Tests/RunCMake/TIClang/module.h new file mode 100644 index 0000000..a8a85a6 --- /dev/null +++ b/Tests/RunCMake/TIClang/module.h @@ -0,0 +1,12 @@ +#ifndef __MODULE_H__ +#define __MODULE_H__ + +#if defined(__cplusplus) +# define INTERNAL 64 +#elif !defined(__cplusplus) +# define INTERNAL 32 +#else +# error "Unable to determine INTERNAL symbol." +#endif + +#endif /* __MODULE_H__ */ diff --git a/Tests/RunCMake/TIClang/module.s b/Tests/RunCMake/TIClang/module.s new file mode 100644 index 0000000..df16350 --- /dev/null +++ b/Tests/RunCMake/TIClang/module.s @@ -0,0 +1,9 @@ + .text + .syntax unified + .section .text.main,"ax",%progbits + .hidden main + .globl main + .p2align 4 +main: + nop + bx lr diff --git a/Tests/RunCMake/TIClang/ticlang-asm.cmake b/Tests/RunCMake/TIClang/ticlang-asm.cmake new file mode 100644 index 0000000..f6c27fc --- /dev/null +++ b/Tests/RunCMake/TIClang/ticlang-asm.cmake @@ -0,0 +1,5 @@ +enable_language(ASM) + +add_executable(exec-asm) +target_sources(exec-asm PRIVATE module.s) +target_link_options(exec-asm PRIVATE ${LINKER_OPTS}) diff --git a/Tests/RunCMake/TIClang/ticlang-c.cmake b/Tests/RunCMake/TIClang/ticlang-c.cmake new file mode 100644 index 0000000..a36f096 --- /dev/null +++ b/Tests/RunCMake/TIClang/ticlang-c.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +add_executable(exec-c) +target_sources(exec-c PRIVATE module.c) +target_link_options(exec-c PRIVATE ${LINKER_OPTS}) diff --git a/Tests/RunCMake/TIClang/ticlang-cxx.cmake b/Tests/RunCMake/TIClang/ticlang-cxx.cmake new file mode 100644 index 0000000..6b005b5 --- /dev/null +++ b/Tests/RunCMake/TIClang/ticlang-cxx.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) + +add_executable(exec-cxx) +target_sources(exec-cxx PRIVATE module.cxx) +target_link_options(exec-cxx PRIVATE ${LINKER_OPTS}) diff --git a/Tests/RunCMake/TIClang/ticlang-lib.cmake b/Tests/RunCMake/TIClang/ticlang-lib.cmake new file mode 100644 index 0000000..e47647c --- /dev/null +++ b/Tests/RunCMake/TIClang/ticlang-lib.cmake @@ -0,0 +1,10 @@ +enable_language(C) + +add_library(ticlang-test-lib) +target_sources(ticlang-test-lib PRIVATE libmod.c) + +add_executable(exec-lib-c) +target_sources(exec-lib-c PRIVATE module.c) +target_compile_definitions(exec-lib-c PRIVATE __USE_LIBFUN) +target_link_libraries(exec-lib-c LINK_PUBLIC ticlang-test-lib) +target_link_options(exec-lib-c PRIVATE ${LINKER_OPTS}) -- cgit v0.12 From 4c51136b8c345adffc4052eb5bd70978d8bc903e Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 9 Feb 2024 15:32:44 -0500 Subject: ci: Enable TIClang test on Debian Clang jobs in nightly pipeline --- .gitlab/.gitignore | 1 + .../ci/configure_debian12_makefiles_clang.cmake | 4 ++++ .gitlab/ci/configure_debian12_ninja_clang.cmake | 4 ++++ .gitlab/ci/env_debian12_makefiles_clang.sh | 4 ++++ .gitlab/ci/env_debian12_ninja_clang.sh | 4 ++++ .gitlab/ci/ticlang-env.sh | 2 ++ .gitlab/ci/ticlang.sh | 28 ++++++++++++++++++++++ 7 files changed, 47 insertions(+) create mode 100644 .gitlab/ci/ticlang-env.sh create mode 100755 .gitlab/ci/ticlang.sh diff --git a/.gitlab/.gitignore b/.gitlab/.gitignore index b28fe32..d8efc1e 100644 --- a/.gitlab/.gitignore +++ b/.gitlab/.gitignore @@ -16,6 +16,7 @@ /python* /qt* /sccache* +/ticlang /unstable-jom* /watcom /wix* diff --git a/.gitlab/ci/configure_debian12_makefiles_clang.cmake b/.gitlab/ci/configure_debian12_makefiles_clang.cmake index 20863a2..69f1e7c 100644 --- a/.gitlab/ci/configure_debian12_makefiles_clang.cmake +++ b/.gitlab/ci/configure_debian12_makefiles_clang.cmake @@ -1 +1,5 @@ +if (NOT "$ENV{CMAKE_CI_NIGHTLY}" STREQUAL "") + set(CMake_TEST_TICLANG_TOOLCHAINS "$ENV{CI_PROJECT_DIR}/.gitlab/ticlang" CACHE PATH "") +endif() + include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/configure_debian12_ninja_clang.cmake b/.gitlab/ci/configure_debian12_ninja_clang.cmake index 20863a2..69f1e7c 100644 --- a/.gitlab/ci/configure_debian12_ninja_clang.cmake +++ b/.gitlab/ci/configure_debian12_ninja_clang.cmake @@ -1 +1,5 @@ +if (NOT "$ENV{CMAKE_CI_NIGHTLY}" STREQUAL "") + set(CMake_TEST_TICLANG_TOOLCHAINS "$ENV{CI_PROJECT_DIR}/.gitlab/ticlang" CACHE PATH "") +endif() + include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/env_debian12_makefiles_clang.sh b/.gitlab/ci/env_debian12_makefiles_clang.sh index eda7c1f..e46aa29 100644 --- a/.gitlab/ci/env_debian12_makefiles_clang.sh +++ b/.gitlab/ci/env_debian12_makefiles_clang.sh @@ -1,2 +1,6 @@ +if test "$CMAKE_CI_NIGHTLY" = "true"; then + source .gitlab/ci/ticlang-env.sh +fi + export CC=/usr/bin/clang-15 export CXX=/usr/bin/clang++-15 diff --git a/.gitlab/ci/env_debian12_ninja_clang.sh b/.gitlab/ci/env_debian12_ninja_clang.sh index eda7c1f..e46aa29 100644 --- a/.gitlab/ci/env_debian12_ninja_clang.sh +++ b/.gitlab/ci/env_debian12_ninja_clang.sh @@ -1,2 +1,6 @@ +if test "$CMAKE_CI_NIGHTLY" = "true"; then + source .gitlab/ci/ticlang-env.sh +fi + export CC=/usr/bin/clang-15 export CXX=/usr/bin/clang++-15 diff --git a/.gitlab/ci/ticlang-env.sh b/.gitlab/ci/ticlang-env.sh new file mode 100644 index 0000000..448c0d7 --- /dev/null +++ b/.gitlab/ci/ticlang-env.sh @@ -0,0 +1,2 @@ +.gitlab/ci/ticlang.sh +.gitlab/ticlang/bin/tiarmclang --version diff --git a/.gitlab/ci/ticlang.sh b/.gitlab/ci/ticlang.sh new file mode 100755 index 0000000..66fa863 --- /dev/null +++ b/.gitlab/ci/ticlang.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +case "$(uname -s)-$(uname -m)" in + Linux-x86_64) + shatool="sha256sum" + sha256sum="c69ac58e403b82eac1c407cc67b35fab5d95c5d8db75b019095f9412aacff27d" + filename="ti_cgt_armllvm_3.2.1.LTS_linux-x64_installer.bin" + dirname="ti-cgt-armllvm_3.2.1.LTS" + ;; + *) + echo "Unrecognized platform $(uname -s)-$(uname -m)" + exit 1 + ;; +esac +readonly shatool +readonly sha256sum + +cd .gitlab + +echo "$sha256sum $filename" > ticlang.sha256sum +curl -OL "https://cmake.org/files/dependencies/internal/$filename" +$shatool --check ticlang.sha256sum +chmod +x "$filename" +"./$filename" --mode unattended --prefix . +mv "$dirname" ticlang +rm -f "$filename" ticlang.sha256sum -- cgit v0.12