Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDA4VH-Q1: TI Arm Clang Compiler Tools C++ Exceptions Support Problem

Part Number: TDA4VH-Q1
Other Parts Discussed in Thread: TDA4VH

Hi TI Experts,

Customer is working on TDA4VH SDK9.0

The tool chain they applied is ti-cgt-armllvm_3.0.0.STS

Based on the below link, beginning with version 3.0.0.STS of the tiarmclang compiler tools, the -fexceptions compiler option can be specified when the compiler is invoked to enable support for C++ exceptions.

https://software-dl.ti.com/codegen/esd/cgt_public_sw/ARM_LLVM/3.0.0.STS/README.html

Customer is trying to validate the example shown in the above link.

Customer has followed the source code shown in the above link example, and uses the Makefile to link -fexceptions. The source code and makefile can be downloaded below.

678873F4BDEE00A7CE7811AED7D295A9.zip

Customer also provided an executable file below after compiling the above code. This could be directly run our EVM board.

E93AF3D3A49760B26981775C3C15A750.zip

After running the executable file, the output is shown below.

Based on the result, we could see that if the input age is equal or greater than 18, then the output is normal as expected.

However, when the input age is less than 18, then it will goto throw & catch, in this case when it reach to the code line of std::cout inside the catch, it will exit suddenly.

The output result of age less than 18 is not the same as example of the link above.

In summary, the compilation of C++ exceptions is okay on 3.0.0.STS, but when running the executable file, it will have problem described in the throw & catch branch.

May I know that if our ti-cgt-armllvm_3.0.0.STS still has some limitation to use C++ exceptions like -fexceptions?

Thanks a lot!

Kevin

  • Hi TI Experts,

    I am not sure if the below warning during the compilation stage of using 3.0.0.STS is related to the above problem or not. Before the 3.x toolchain, there is no these warning.

    Kind Regards,

    Kevin

  • Please upgrade to the latest compiler version 3.2.0.LTS.

    Change the stack and heap sizes to be as big as possible.  Just to make sure they cannot be the problem.

    In the invocation of the linker, I see the specification of these libraries from the compiler ...

    -l../ti-processor-sdk-rtos-j784s4-evm-09_00_01_01/ti-cgt-armllvm_3.0.0.STS/lib/armv7r-ti-none-eabihf/except/libc++.a
    -l../ti-processor-sdk-rtos-j784s4-evm-09_00_01_01/ti-cgt-armllvm_3.0.0.STS/lib/armv7r-ti-none-eabihf/except/libunwind.a
    -l../ti-processor-sdk-rtos-j784s4-evm-09_00_01_01/ti-cgt-armllvm_3.0.0.STS/lib/armv7r-ti-none-eabihf/except/libc++abi.a
    -l../ti-processor-sdk-rtos-j784s4-evm-09_00_01_01/ti-cgt-armllvm_3.0.0.STS/lib/armv7r-ti-none-eabihf/except/libc++experimental.a
    ../ti-processor-sdk-rtos-j784s4-evm-09_00_01_01/ti-cgt-armllvm_3.0.0.STS/lib/armv7r-ti-none-eabihf/except/libc++.a
    ../ti-processor-sdk-rtos-j784s4-evm-09_00_01_01/ti-cgt-armllvm_3.0.0.STS/lib/armv7r-ti-none-eabihf/except/libunwind.a
    ../ti-processor-sdk-rtos-j784s4-evm-09_00_01_01/ti-cgt-armllvm_3.0.0.STS/lib/armv7r-ti-none-eabihf/except/libc++abi.a
    ../ti-processor-sdk-rtos-j784s4-evm-09_00_01_01/ti-cgt-armllvm_3.0.0.STS/lib/armv7r-ti-none-eabihf/except/libc++experimental.a

    Remove all of that.  As described in the Compile and Link part of the tiarmclang online manual, it is best to let the compiler automatically choose those libraries.

    I cannot guarantee these changes resolve the problem.  But these changes need to be made anyway.

    Thanks and regards,

    -George

  • Hi George,

    Thanks for your suggestions!

    We have upgraded to 3.2.0.LTS, & removed the specification of those libraries you mentioned from the compiler, but the result is still the same.

    We are now trying to increase the stack & the heap size as you suggested.

    We have tried the below modifications from the j784s4_linker_freertos.cmd shown below.

    The original default setting is stack_size = 0x8000, heap_size = 0x10000

    Case 1: 2*times the default size, stack_size = 0x16000, heap_size = 0x20000

    Case 2: 4*times the default size, stack_size = 0x32000, heap_size = 0x40000

    For the both of the above 2 cases, the result remains the same.

    May I know if this is the proper way to increase the stack & heap size?

    Any suggestions would be very appreciated!

    Kevin

  • I don't have the hardware to run the executable you build.  But I did build the same example to run on a system I have that has a Cortex-R4 CPU on it.  It works fine for me.  Thus, I conclude there is no problem with the compiler toolchain.

    Try changing the code to not use std::cout or std::cin.  The related RTS functions are complicated and require lots of memory.  Your final application does not use them.  So, if removing them makes the example work, you know the problem, whatever it is, can be ignored.  

    Thanks and regards,

    -George

  • Hi George,

    Thanks for your suggestions!

    We have tried below testing, changing the std::cin & std::cout to printf.

    If the input age is greater than 18, the result is normal shown below.

    However, when the input age is less than 18, there is no information print out, even the "hello world" not printed out, which means that after reaching to "throw" program will exit directly without continuing further.

    We do not know how to debug it further, the only information we have is the warning shown below.

    The relocated address 0xa01623d0 in the above warning locates within the below DDR_MCU1_0 range.

    It seems the space should be enough, so we do not know how to debug it further.

    Any other ideas you could suggest us for a try?

    Thanks a lot!

    Kevin

  • Regarding ...

    We do not know how to debug it further, the only information we have is the warning shown below.

    I'm sorry I overlooked those warnings in an earlier post.  You should not see those.  In the linker command file, be sure there are specifications similar to ...

        .ARM.exidx > MEMORY_RANGE
        .ARM.extab > MEMORY_RANGE

    These output sections contain initialized tables related to C++ exceptions.  They are read-only.  They do not need to be allocated to fast memory.  They can probably go in the same memory range as the .cinit section.

    changing the std::cin & std::cout to printf.

    Unfortunately, printf also takes up lots of memory.  Make it even simpler.  Remove all the print statements.  Assign a constant value to the age variable.  Set a breakpoint inside the catch clause, and another one at the end of the program.  See what happens.  

    Thanks and regards,

    -George

  • Hi George,

    Thanks for your advice!

    We finally could make it work by adding the specifications you suggested shown below.

    In summary of this case, every time we use C++ exceptions, we have to ensure there are specifications for .ARM.exidx & .ARM.extab in the linker command file. As in our SDK, it may not have these settings by default because the default SDK may not consider the application of C++ exceptions.

    Thanks a lot!

    Kevin

  • I filed EXT_EP-11544 to request that the compiler manual be updated to document that add these sections to the list of those that may be created by the compiler.  You are welcome to follow it with that link.

    Thanks and regards,

    -George