Tasking Toolchain: How to properly use it?

Hello,

currently im trying to setup a cmake project which should be used to compile an application for the infineon aurix tc29xb microcontroller using the tasking toolchain.

The cmake project must be usable under windows and linux (docker container).

Since cmake 3.25 there is an official support for the tasking toolchain (thanks @go2sh !).

I started to setup the cmake project under linux (debian with installed build-essentials).
Therefore i created a toolchain file (tasking_toolchain.cmake) which is passed on the command line when invoking cmake to configure the project.

The toolchain file currently looks as followed:

message(STATUS "## DEBUG - Toolchain file entered!")

# Determine the tasking tricore toolchain binary paths.
# The user must provide the environment variable 'TASKING_TRICORE_TOOLCHAIN_PATH'
# which points to the installation directory of the tasking toolchain for the tricore.
# Example:  C:/Tasking/ctc
# In the example the path 'C:/Tasking' could also contain other architecture toolchains, e.g. 'c51', 'carm', ...
# The toolchain for the tricore microcontroller is located in the subdirectoy 'ctc'.
set(TOOLCHAIN_PATH          $ENV{TASKING_TRICORE_TOOLCHAIN_PATH})
set(TOOLCHAIN_BIN_PATH      ${TOOLCHAIN_PATH}/bin)
set(EXE_SUFFIX              ${CMAKE_EXECUTABLE_SUFFIX})


message(STATUS "## DEBUG - TOOLCHAIN_BIN_PATH=${TOOLCHAIN_BIN_PATH}")


set(CMAKE_SYSTEM_NAME       "Generic")
set(CMAKE_SYSTEM_PROCESSOR  "TriCore")

set(CMAKE_TASKING_TOOLSET   "TriCore")


find_program(CMAKE_C_COMPILER
    NAMES   cctc${EXE_SUFFIX}
    HINTS   ${TOOLCHAIN_BIN_PATH}
)
find_program(CMAKE_CXX_COMPILER
    NAMES   cctc${EXE_SUFFIX}
    HINTS   ${TOOLCHAIN_BIN_PATH}
)
find_program(CMAKE_LINKER
    NAMES   cctc${EXE_SUFFIX}
    HINTS   ${TOOLCHAIN_BIN_PATH}
)

Using this toolchain file on the linux container worked so far to compile a minimal example.

Invocation:

cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE="./cmake/tasking/tasking_toolchain.cmake"

At this point i already was not clear on what binary to use for the C and CXX compiler variables.
Coming from GCC i would use the “ctc” and “cptc” binaries but this did not work.
Compiler identification unknown and not able to compile a simple test program.

Therefore i used the “cctc” for the C and CXX compiler, as well as for the linker.

When this was working i thought i got it.

Anyway build time was extremely slow on the docker container due to dependency scanning of a linked library (own mcal with iLLD).

To check if the slow build is related to the docker container i wanted to run the cmake configuration and build under windows with the same toolchain file which worked under linux.

First invocation failed since it just used the MSVC compiler.
I remembered that i run into same issues before when using GCC (e.g. cygwin or hightec compiler) without specified generator to use.
So i added the generator which should be used, the invocation therefore looked as followed:

cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE="./cmake/tasking/tasking_toolchain.cmake" -G"Unix Makefiles"

This lead to the following error:
“CMake was unable to find a build program corresponding to “Unix Makefiles”. CMAKE_MAKE_PROGRAM is not set.”

So i added the following to the toolchain file:

find_program(CMAKE_MAKE_PROGRAM
    NAMES   cctc${EXE_SUFFIX}
    HINTS   ${TOOLCHAIN_BIN_PATH}
)

Also using the “cctc” here instead of the concrete make binary (e.g. amk or mktc) due to the previous issues when setting the compiler.

Now the output when invoking cmake as before is as followed:

-- The C compiler identification is Tasking 6.3
-- The CXX compiler identification is Tasking 6.3
-- Detecting C compiler ABI info

And here it hangs when detecting the C compiler ABI info.
After about 10 minutes it states that detecting the C compiler ABI info failed and afterwards it checks for a working C compiler (using the cctc), which also hangs for multiple minutes and fails as well.
The C compiler is not able to compile a simple test program.

Detailed output:

-- Check for working C compiler: C:/TASKING/ctc/bin/cctc.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/CMakeTestCCompiler.cmake:70 (message):
  The C compiler
    "C:/TASKING/ctc/bin/cctc.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty

    Run Build Command(s):C:/TASKING/ctc/bin/cctc.exe -f Makefile cmTC_651cb/fast && cctc E200: commandline: cannot open option file "#"
    cctc E201: unknown option: "-B$(CMAKE_BINARY_DIR)"
    cctc E201: unknown option: "--regenerate-during-build"
    cctc E201: unknown option: "-B$(CMAKE_BINARY_DIR)"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc E201: unknown option: "--progress-dir=C:/dev/eec-board-drc_01-mcu/build/drc/ReleaseWin/CMakeFiles/CMakeScratch/TryCompile-5osoty/CMakeFiles"
    cctc E201: unknown option: "--progress-num=1,2"
    cctc F105: more than 42 errors - aborting

This happens on both (windows and linux).
When running without the specified generator on linux it works, so i guess its just using the default make which comes with the build-essentials.

I could use another make (cygwin, mingw) on windows as well, but shouldn’t it work using the binaries of the toolchain?

Does anyone (maybe @go2sh , @brad.king) can help me to correctly setup the usage of the tasking toolchain?

I’m totally stuck at this point and would be glad about any help.

Thanks in advance!

Regards,
Manuel

Something has a rogue comment in it somewhere. I would suggest running a fresh configure with --trace-expand to see where this might be coming from.

Support for the Tasking compiler has been asked around here before. I don’t remember if anyone’s posted a working toolchain file or not.

I don’t think that cctc is a “make”-alike program. Where does your assumption come from?

When using Windows, do yourself a favor and do not stick to make, use ninja instead.

Oh. Yes, that would be the problem then. CMAKE_MAKE_PROGRAM is what runs the Makefiles that get generated. You want to set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER instead.

Hello,

thanks for the replies so far.

I can check this, but in my opinion the sources which are built here should be a part of cmake, aren’t they? So i don’t think, that there are any rogue comments or something like that in it.

I could not find any toolchain file example so far. @go2sh offered to post an example in another thread, but unfortunately he did not upload it yet.

The “cctc” is a control program of the toolchain which invokes the underlying binaries of the toolchain, e.g. the c compiler (ctc), the c++ compiler (cptc) or the linker (ltc).
The CMAKE_C_COMPILER and CMAKE_CXX_COMPILER variables are also set to the “cctc”, since setting them to the compilers (ctc/cptc) directly results to a not correctly detected toolchain.
The toolchain also brings two make tools with it, the mktc and the amk. The later is a parallel make utilty.
I also tested to set CMAKE_MAKE_PROGRAM to the make utilities directly, which also did not work.

Yes you are right, i was able to get it working by using the ninja build tool.
Anyway i’m still more than unclear on how to really properly use the cmake tasking toolchain integration correctly.
Means, is setting the cctc for the compilers and linker the right way?

I think i’m not the only one struggling with this. An example toolchain file would clarify the usage.
At best place it into the cmake documentation of the tasking toolset variable.

Thank you very much for your help already!

Regards,
Manuel

Hi Manuel,

the bare minimum toolchain would look like this (exactly like for others):

set(CMAKE_SYSTEM_NAME Generic-ELF)
set(CMAKE_TASKING_TOOLSET SmartCode)
set(CMAKE_CXX_STANDARD_LIBRARIES "-lc -lcpx -lstlx --munch")

# Find Tasking for Tricore.
find_program(TRICORE_COMPILER_C cctc PATHS ENV TASKING_TRICORE_TOOLCHAIN_PATH PATH_SUFFIXES bin)

# Specify the cross compiler
set(CMAKE_C_COMPILER ${TRICORE_COMPILER_C})
set(CMAKE_CXX_COMPILER ${TRICORE_COMPILER_C})
set(CMAKE_ASM_COMPILER ${TRICORE_COMPILER_C})

The CMAKE_CXX_STANDARD_LIBRARIES is not 100% necessary for CXX and it also depends on the execption support and float type. You can add it also via target_link_libraries.

See the following attached toolchain file for additional stuff:
TaskingTricoreTC4.cmake (2.1 KB)
Additionally you can add to the file something like:

add_compile_options(
    -Ctc49x --language=+volatile --no-exceptions --anachronisms  -N0 -Z0 -Y0
)
add_link_options(
    LINKER:--optimize=2
    -d${PROJECT_SOURCE_DIR}/Lcf_Tasking_Tricore_Tc.lsl
)

If you want to have default options for your project.

BR,
go2sh

1 Like

Hi,

many thanks for your reply and the attached toolchain file.

So the assumptions on using the “cctc” as compiler was right.
This is how it also works for me (using ninja build).

You did not specify any CMAKE_MAKE_PROGRAM in your toolchain file.

Could you tell us if you use a third party make utility (e.g. make from gnu or ninja build) or if you are able to use one of the make utilities which comes with the tasking toolchain?

Regards,
Manuel

Hi Manuel,

I don’t specify the make tool variable. I have a presets file which includes the directory, the toolchain file and ninja multi config as generator. Ninja itself is part of the system path variable.

Presets + Toolchain file + ninja works like a charm, also with different compilers.

Regards,
go2sh

1 Like

Hi everyone,

many thanks for all your answers! :slight_smile:

To summarize for further readers:

How to use the tasking toolchain?

  1. Create a toolchain file and set the control program (cctc) as the compiler for your asm, c and cpp files.
  2. Enable cross compilation by setting the CMAKE_SYSTEM_NAME (e.g. to Generic), also optionally set the CMAKE_SYSTEM_PROCESSOR (e.g. to TriCore).
  3. Set the CMAKE_TASKING_TOOLSET variable to the used toolset (see official documentation).
  4. Use a third party make utility, e.g. GNU make or ninja build.
  5. Checkout the example toolchain file from go2sh (and the associated post) for further information.

Regards,
Manuel

hi sir,
I am also confused about using cmake to build infineon aurix tc2xx. But I am new to cmake and tasking, so I don’t know much about the details of the construction project. Can you provide a demo? Many thanks.

Hi Manuel,

first I want to thank you for the great effort to summarize everything, it helped a lot.

If I understood correctly you moved away from using the provided builder, I am too having problems to call the provided tasking builder out of my cmakelists file.

I am now at a point where I want to use the Ninja or Make builder. The compilation works fine, but the generated output object files come in the format “.obj” instead of my preferred “.o”. (When I use the Tasking IDE, the output is .o)

(I am also having issues linking the object files, but I think it is because I havent included the linker script file properly).

So my question is, are your output object files in the .obj or .o format? And do you know how to specify the extension of the object files?
Thanks in advance,
Target

Hi Target,

you’re welcome, I’m glad if it helped you!

In my case the Tasking IDE (Eclipse) just called the control program (cctc) for everything.
Therefore i also used this when setting up the toolchain file (see discussion on this topic).
As generator i use ninja, this was the only way i got it to work seamlessly (and it still does).

Regarding your question about the extension of the output files:
I also have object files ending with the “.obj” extension (i never cared about this).
So the issues you are facing are probably related to the missing linker script file, like you mentioned.

If you would like to change the output file extension, you can do so by using the CMAKE_C/CXX_OUTPUT_EXTENSION

Per default this seems to be “.obj” in this case for “C” and “CXX” option.
Check this stackoverflow entry for further details about setting the corresponding variables.

In my case the linker script is added as followed:

target_link_options(
    MyTargetName
    PUBLIC
    --lsl-file=${CMAKE_CURRENT_LIST_DIR}/RestOfPathTo/MyLinkerScriptFile.lsl
)

I hope this helps you!

Best regards,
Manuel

Hi Manuel, I just wanted to say thank you!
BR
Target

1 Like