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.

Error linking non-trivial project with OpenMP enabled



Hi,

We are currently trying to port a non-trivial project which consists of several self-written libraries to OpenMP.
We took the existing SYS/BIOS project, added IPC+OMP rtsc libraries and switched to the beta-mcsdk + cgt 7.4b2.

However linking fails with the following error:


error #10378: non-TLS reference "errno" in
   "somelib_TMS320C6600_D.lib<someobject.obj>" mismatches TLS definition in "C:\TI\C6000 Code Generation Tools
   7.4.0B2\lib\rts6600_elf_mt.lib<errno.obj>"
warning #10247-D: creating output section ".TI.tls" without a SECTIONS

>> Compilation failure
   specification
warning #10247-D: creating output section ".TI.tls_init" without a SECTIONS
   specification
"./configPkg/linker.cmd", line 134: warning #10237-D: split placement (>>)
   ignored for ".init_array":  split placement for this section is not
   permitted
error #10010: errors encountered during linking; "somefile.out" not built
gmake: *** [EV3D.out] Error 1
gmake: Target `all' not remade because of errors.

Any idea whats the cause of this problem? Also, what does the "split placement" warning mean?
The library linked in is a non-RTSC project which has been compiled with cgt 7.4b2 before.

Thank you in advance, Clemens

PS: Actually a second question. I tried to use my own RTSC platform definition, created with the RTSC platform wizzard - however this fails, because that failed, because the OpenMP runtime refers to memory ranges like MSMCSRAM_NOCACHE, the rtsc platform wizzard simply doesn't offer.
Will I have to edit the platform definition manually?

PS2: I just noticed the linker.cmd file differes a lot compared the OpenMP example project supplied by TI, however I can't explain why different linker.cmd files are generated. I don't specify any special placement rules, and used the omp_config.conf file supplied with the example.

  • I gave the suggestion mentioned in http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/p/196384/711269.aspx a try (replaced libc.a with rts6600.elf), now I get a different error message:


    error #10378: non-TLS reference "errno" in
       "C:\work_pfelib/lib/pfe_base_TMS320C6600_D.lib<PfeTftpProtocol.obj>"
       mismatches TLS definition in
       "C:\ti\cgt-7.4b2\lib\rts6600_elf.lib<errno.obj>"

  • The first thing you need to do is switch back to using libc.a; the library you actually want is rts6600_elf_mt.lib, which is the library that was found using libc.a

    The "split placement" warning is because your linker command file uses the ">>" operator, which means "split placement", on the ".init_array" section.  The ".init_array" section must be contiguous in memory, so it is forbidden to use the ">>" operator to place it.  The only way to silence this warning is to adjust your linker command file.  As the warning indicates, the operator is being ignored, so this is not your primary problem.

    For OpenMP programs, all modules which refer to "errno" must be compiled with multithreading support enabled.  That is, with the "--openmp" option."  You must recompile file someobject.obj in library somelib_TMS320C6600_D.lib with this option.  This is necessary because errno is a thread-local object, and must be accessed differently in a multithreaded program.

  • Hi Archaeologist,

    As always, thanks a lot for your reply.

    The object-file contained within the library which causes the error-message was compiled with the following options:


    'Building file: C:/work_pfelib/pfeCore/base/src/PfeTftpProtocol.c'
    'Invoking: C6000 Compiler'
    "C:/ti/cgt-7.4b2/bin/cl6x" -mv6600 --abi=eabi -g --include_path="C:/ti/cgt-7.4b2/include" --include_path="../../include" --include_path="../../../heapman/include" --include_path="../../../ros/include" --display_error_number --diag_warning=225 --openmp --preproc_with_compile --preproc_dependency="PfeTftpProtocol.pp"  "C:/work_pfelib/pfeCore/base/src/PfeTftpProtocol.c"
    "C:/work_pfelib/pfeCore/base/src/PfeTftpProtocol.c", line 562: warning #190-D: enumerated type mixed with another type
    "C:/work_pfelib/pfeCore/base/src/PfeTftpProtocol.c", line 569: warning #190-D: enumerated type mixed with another type
    "C:/work_pfelib/pfeCore/base/src/PfeTftpProtocol.c", line 1426: warning #190-D: enumerated type mixed with another type
    'Finished building: C:/work_pfelib/pfeCore/base/src/PfeTftpProtocol.c'

    yet I still get the following message, when linking the main-project (which is also compiled with --openmp):


    error #10378: non-TLS reference "errno" in
       "C:\work_pfelib/lib/pfe_base_TMS320C6600_D.lib<PfeTftpProtocol.obj>"
       mismatches TLS definition in
       "C:\ti\cgt-7.4b2\lib\rts6600_elf_mt.lib<errno.obj>"

    Hmm, in this case I have no clue what could be wrong :/

    Thanks, Clemens

  • Are you sure the freshly-built PfeTftpProtocol.obj was placed in library pfe_base_TMS320C6600_D.lib?

  • Archaeologist said:
    Are you sure the freshly-built PfeTftpProtocol.obj was placed in library pfe_base_TMS320C6600_D.lib?

    Unfourtunatly yes, I deleted all existing pre-built libraries and object files, made sure 7.4b2 / --openmp was specified everywhere, deleted the Release/Debug folders so to make sure config/linker files are recompiled. I also watched the compiler output, to see if the compiler was really 7.4b2 and --openmp. Because the error persisted with "libc.a" in the linker search path, I manually chose rts6600_elf_mt.lib, but I still get the mismatch error :(

    Any ideas how to narrow the problem down?

    Thank you in advance, Clemens

  • Hi Clemens,

    The TLS mismatch error is a known ease-of-use problem in the 7.4.0B2 release. The issue comes up when a user references 'errno' from their application source code and then links against a thread-safe version of the RTS library (rts6600_elf_mt.lib in your case, I believe).

    The problem is that when the application code includes <errno.h> it does not get the TLS declaration of 'errno' (which is controlled via the use of the __TI_USE_TLS symbol in the RTS source). Therefore, references to 'errno' from the application code will not use TLS addressing conventions. Inside of rts6600_elf_mt.lib, 'errno' is defined in TLS and is expected to be referenced via TLS addressing.

    A wrokaround to your specific problem is to use a '-D__TI_USE_TLS' option when compiling your application code that needs to reference 'errno'.

    The underlying issue has been addressed in fixes to SDSCM00044229 and SDSCM00045068 in the soon to be available 7.4.1. The solution was to change the definition of 'errno' in errno.h into a macro which defines errno as follows:

    #ifdef __cplusplus

    #define errno (* ::std::__c6xabi_errno_addr())

    #else

    #define errno (* __c6xabi_errno_addr())

    #endif

    where __c6xabi_errno_addr() returns the address of the RTS-internal implementation of the 'errno' object. This makes the references to 'errno' from the application code independent of how 'errno' is actually implemented in the RTS.

    This is probably more than you wanted to know, but I hope it proves helpful.

    Let me know if you have further questions.

    Thanks and Regards,

    Todd Snider

    C6000 Code Generation Tools Team

    Texas Instruments Incorporated

  • Hi Todd,

    Thanks a lot for the detailed analysis of the problem - I am always interested in learning how things are implemented.
    As suggested, compiling with -D__TI_USE_TLS solved the problem :) - thanks a lot.

    The only linker problems left are placement errors, caused by a non-appropriate linker command file.
    The linker.cmd file is auto-generated during build , and I am using the same rtsc cfg-file (and rtsc platform definition) as supplied with the omp_matvec example, however e.g. my linker.cmd file hasn't a memory range "MSMCSRAM_NOCACHE", and sections are placed very different compared to the omp_mathvec example.

    Are there additional sources / configuration files which are read during linker.cmd generation, except from the rtsc config file?

    Sorry for beeing so support-intensive in this case, and thaks a lot for your professional help.

    Thanks, Clemens

  • Sorry, this was really my fault - I had selected the wrong platform.

    Instead of ti.exmaples.omp.evm6678 I had ti.examples.evm6678 - which of course doesn't sepcify the memory ranges required by OMP.

    Thanks, Clemens

  • Clemens,

    Just following up ... did you get the information you were looking for from the ti.examples.omp.evm6678 forum?

    Regards,

    Todd

  • Hi Todd,

    Thanks to your help, my example project now builds and works as exppected.

    Thanks, Clemens

  • Hi everyone,

    I am now trying to compile with the 7.4.1 CGT (non-beta) with the MCSDK 2.1 (beta). Unfortunately, I received the following error:

    **** Build of configuration Debug for project RKLTSerialCluster ****

    C:\ti\ccsv5\utils\bin\gmake -k all

    'Building file: ../omp_config.cfg'

    'Invoking: XDCtools'

    "C:/ti/xdctools_3_23_02_47/xs" --xdcpath="C:/ti/bios_6_33_04_39/packages;C:/ti/mcsdk_2_01_00_02/eclipse;C:/ti/pdk_C6678_1_1_0_2/eclipse;C:/ti/pdk_C6678_1_1_0_2/packages;C:/ti/ndk_2_21_01_38/packages;C:/ti/nsp_1_10_00_03/packages;C:/ti/ipc_1_24_02_27/packages;C:/ti/omp_1_01_02_03_beta/packages;" xdc.tools.configuro -o configPkg -t ti.targets.elf.C66 -p ti.omp.examples.platforms.evm6678 -r debug -c "C:/ti/C6000 Code Generation Tools 7.4.1" "../omp_config.cfg"

    making package.mak (because of package.bld) ...

    generating interfaces for package configPkg (because package/package.xdc.inc is older than package.xdc) ...

    configuring omp_config.xe66 from package/cfg/omp_config_pe66.cfg ...

    cle66 package/cfg/omp_config_pe66.c ...

    'Finished building: ../omp_config.cfg'

    ' '

    'Building file: ../RKLTSerialCluster.c'

    'Invoking: C6000 Compiler'

    "C:/ti/C6000 Code Generation Tools 7.4.1/bin/cl6x" -mv6600 --abi=eabi -g --include_path="C:/ti/C6000 Code Generation Tools 7.4.1/include" --display_error_number --diag_warning=225 --mem_model:const=far --mem_model:data=far --openmp --preproc_with_compile --preproc_dependency="RKLTSerialCluster.pp" --cmd_file="./configPkg/compiler.opt"  "../RKLTSerialCluster.c"

    "../RKLTSerialCluster.c", line 38: warning #179-D: variable "P" was declared but never referenced

    "../RKLTSerialCluster.c", line 39: warning #179-D: variable "L" was declared but never referenced

    "../RKLTSerialCluster.c", line 40: warning #179-D: variable "eigvector" was declared but never referenced

    "../RKLTSerialCluster.c", line 41: warning #179-D: variable "S" was declared but never referenced

    'Finished building: ../RKLTSerialCluster.c'

    ' '

    'Building target: RKLTSerialCluster.out'

    'Invoking: C6000 Linker'

    "C:/ti/C6000 Code Generation Tools 7.4.1/bin/cl6x" -mv6600 --abi=eabi -g --display_error_number --diag_warning=225 --mem_model:const=far --mem_model:data=far --openmp -z -m"RKLTSerialCluster.map" -i"C:/ti/C6000 Code Generation Tools 7.4.1/lib" -i"C:/ti/C6000 Code Generation Tools 7.4.1/include" --reread_libs --warn_sections --rom_model -o "RKLTSerialCluster.out" -l"./configPkg/linker.cmd"  "./RKLTSerialCluster.obj" -l"libc.a"

    <Linking>

    error #10378: TLS reference "errno" in

       "C:\ti\omp_1_01_02_03_beta\packages\ti\omp\lib\debug\ti.omp.ae66<env.oe66>"

       mismatches non-TLS definition in "C:\ti\C6000 Code Generation Tools

       7.4.1\lib\rts6600_elf_mt.lib<errno.obj>"

    warning #10247-D: creating output section ".TI.tls" without a SECTIONS

       specification

    warning #10247-D: creating output section ".TI.tls_init" without a SECTIONS

       specification

    error #10010: errors encountered during linking; "RKLTSerialCluster.out" not

       built

    >> Compilation failure

    gmake: *** [RKLTSerialCluster.out] Error 1

    gmake: Target `all' not remade because of errors.

    **** Build Finished ****

    Can anyone advice me on this ?

    Regards,

    Rizuan

  • Hi Rizuan,

    The thread you posted in should provide you with all the information nescessary to fix your issue.

    - Clemens

  • Hi Clemens,

    Thanks for your reply. Do you mean by adding the compiler option -D__TI_USE_TLS to the specific code? Is this necessary even my CGT that I'm using now is not the beta version as discussed?

    Can you please advice me on how to add the -D__TI_USE_TLS compiler option? I couldn't find it in the project property.

    If you are interested, can you compile your project using the latest and non-beta CGT available at:

    https://www-a.ti.com/downloads/sds_support/TICodegenerationTools/download.htm (you need to sign in)

    It said that we need to use the MCSDK 2.1 or later. There is no MCSDK 2.1 except for the beta release. Could you please try these?

    Thanks, Clemens,

    Rizuan

  • Hi everyone,

    Here is what I've tried.

    Hello World example for OpenMP. I've tried using the CGT V7.4.0.B2, and no error. When I changed to CGT V7.4.1 (non-Beta), I've received:

    error #10378: TLS reference "errno" in

       "C:\ti\omp_1_01_02_03_beta\packages\ti\omp\lib\debug\ti.omp.ae66<env.oe66>"

       mismatches non-TLS definition in "C:\ti\C6000 Code Generation Tools

       7.4.1\lib\rts6600_elf_mt.lib<errno.obj>"

    Please note that it is not

    error #10378: non-TLS reference "errno" in

    as in the previous posts by Clemens if I'm not mistaken.

    My guess is the latest CGT V7.4.1 is not compatible with the MCSDK 2.1.0.2 (beta).

    Regards,

    Rizuan

  • I am curious as to how 'errno' is being used in the source for ti.omp.ae66<env.oe66>. If the ti.omp.ae66 library must reference 'errno', it should always use #include <errno.h> to get the proper declaration of 'errno'. If the ti.omp.ae66 source file uses an explicit scalar declaration of 'errno', "extern int errno;", for example, this can lead to the above TLS symbol mismatch that is described above.

    I will try to pursue this line of questioning with the ti.omp.ae66 library authors to find out what is going on.

    Regards,

    Todd Snider

    C6000 Code Generation Tools Team

    Texas Instruments Incorporated

  • Here is an update on what I have found out ...

    The ti.omp.ae66<env.oe66> file in question was built with the -D__TI_USE_TLS option and the 7.4.0B2 compiler, which uses a version of the <errno.h> file that is not compatible with the 7.4.0 (or later) RTS.

    The RTS's <errno.h> file was updated between version 7.4.0B2 and 7.4.0 in order to make applications independent of the RTS's internal implementation or 'errno'. Specifically, in the 7.4.0 <errno.h>, 'errno' is defined as follows:

       #ifdef __cplusplus

        #define errno (*::std::__c6xabi_errno_addr())

       #else

        #define errno (*__c6xabi_errno_addr())

       #endif

    Using this 'errno' interface, all references to 'errno' in the application code should be replaced by a dereference of the return value of __c6xabi_errno_addr() which computes the address of the RTS's internal implementation of 'errno'. This allows the RTS to define 'errno' as TLS or not without impacting the application code.

    This 'errno' interface change did create an incompatibility between beta versions of the MCSDK which were built with the 7.4.0B2 tools and the 7.4.0 (or later) Code Generation tools. The safest remedy to this situation is to continue using the 7.4.0B2 tools with beta versions of the MCSDK and to use the latest 7.4.x tools with the production version of the MCSDK which will have been built with the 7.4.0 release.

    Regards,

    Todd Snider

  • Thanks Todd,

    Look forward for the production version of the MCSDK that has been built with the CGT v7.4.1.

    Kind regards,

    Rizuan