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.

TI-CGT: TI CGT ARMLLVM linker issue

Part Number: TI-CGT


Hello,

I'm trying to compiling an app for ARM Cortex R5F core with ti-cgt-armllvm_1.3.0.LTS but got the following error:

$ "/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/bin/tiarmclang" -std=c11 -mcpu=cortex-r5 -mfloat-abi=hard -mfpu=vfpv3-d16 -m32 -O0 -g3 -pipe -fno-short-enums -fno-builtin -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -L _build/TI_ARMLLVM/HSM/lib/ -L "/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib" -o _build/TI_ARMLLVM/TI_ARMLLVM -L _build/TI_ARMLLVM/HSM/bin -L _build/TI_ARMLLVM/HOST/bin -llibHSM.lib -llibHOST_tests.lib -llibHOST.lib -v
TI Arm Clang Compiler 1.3.0.LTS
Target: arm-ti-none-eabi
Thread model: posix
InstalledDir: /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/bin
"/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/bin/tiarmlnk" --search_path _build/TI_ARMLLVM/HSM/lib/ --search_path /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib --search_path _build/TI_ARMLLVM/HSM/bin --search_path _build/TI_ARMLLVM/HOST/bin -I/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib -o _build/TI_ARMLLVM/TI_ARMLLVM -llibHSM.lib -llibHOST_tests.lib -llibHOST.lib --start-group -llibc++.a -llibc++abi.a -llibc.a -llibsys.a -llibsysbm.a -llibclang_rt.builtins.a -llibclang_rt.profile.a --end-group --cg_opt_level=0
warning: cannot resolve archive
/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libc++
.a to a compatible library, as no input files have been encountered
warning: cannot resolve archive
/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libc++
abi.a to a compatible library, as no input files have been encountered
warning: cannot resolve archive
/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libc.a
to a compatible library, as no input files have been encountered
warning: cannot resolve archive
/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libsys
.a to a compatible library, as no input files have been encountered
warning: cannot resolve archive
/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libsys
bm.a to a compatible library, as no input files have been encountered
warning: cannot resolve archive
/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libcla
ng_rt.builtins.a to a compatible library, as no input files have been
encountered
warning: cannot resolve archive
/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libcla
ng_rt.profile.a to a compatible library, as no input files have been
encountered
fatal error: no input files
tiarmclang: error: tiarmlnk command failed with exit code 1 (use -v to see invocation)

The libraries (libHSM.lib, libHOST_tests.lib, libHOST.lib) for linking are packed with tiarmar from object files built with tiarmclang in the same time.

How should I resolve this issue?

Thanks,

Matthew

  • The linker brings in a file from an object library like one of these ...

    libHSM.lib, libHOST_tests.lib, libHOST.lib

    ,,, only if that file defines an existing unresolved symbol reference.  Your invocation of the linker supplies no object files, so it is impossible for there to be any unresolved symbol reference, and thus the linker brings in no files from any library.

    Put another way ... In a typical build, the core functionality of the program is implemented in source files that are compiled into object files.  These object files call functions, or use data, that is defined in one or more libraries.  That is what causes the linker to bring in a file from a library.  However, it never occurs in your build.

    For more background, please see the sub-chapter Resolving Symbols with Object Libraries from the tiarmclang online manual.

    Thanks and regards,

    -George

  • Hi George,

    Just curiously, same source codes, it can be built and linked properly with Ubuntu clang version 12.0.0-3ubuntu1~20.04.5. Here below is the output:

    $ clang -std=c99 -O0 -g3 -pipe -fno-short-enums -m32 -fno-builtin -L _build/PCx32_CLANG/HSM/lib/ -L "/usr/lib/llvm-12/lib" -o _build/PCx32_CLANG/PCx32_CLANG -L _build/PCx32_CLANG/HSM/bin -L _build/PCx32_CLANG/HOST/bin -l:libHSM.lib -l:libHOST_tests.lib -l:libHOST.lib -l:libHSM.lib -l:libHOST_tests.lib -l:libHOST.lib -v
    Ubuntu clang version 12.0.0-3ubuntu1~20.04.5
    Target: i386-pc-linux-gnu
    Thread model: posix
    InstalledDir: /usr/bin
    Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
    Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
    Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
    Candidate multilib: .;@m64
    Candidate multilib: 32;@m32
    Candidate multilib: x32;@mx32
    Selected multilib: 32;@m32
    "/usr/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o _build/PCx32_CLANG/PCx32_CLANG /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../lib32/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../lib32/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/9/32/crtbegin.o -L_build/PCx32_CLANG/HSM/lib/ -L/usr/lib/llvm-12/lib -L_build/PCx32_CLANG/HSM/bin -L_build/PCx32_CLANG/HOST/bin -L/usr/bin/../lib/gcc/x86_64-linux-gnu/9/32 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../i386-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../lib32 -L/lib/i386-linux-gnu -L/lib/../lib32 -L/usr/lib/i386-linux-gnu -L/usr/lib/../lib32 -L/usr/lib/x86_64-linux-gnu/../../lib32 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/9 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../.. -L/usr/lib/llvm-12/bin/../lib -L/lib -L/usr/lib -l:libHSM.lib -l:libHOST_tests.lib -l:libHOST.lib -l:libHSM.lib -l:libHOST_tests.lib -l:libHOST.lib -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/bin/../lib/gcc/x86_64-linux-gnu/9/32/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../lib32/crtn.o

    I'll check the document you pointed out to see if I can find something out.

    Thanks,

    Matthew

  • The difference is that, behind the scenes, clang supplies these object files ...

    /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../lib32/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../lib32/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/9/32/crtbegin.o

    In your case, this must start the chain of symbol references that results in files being brought out of libraries.  

    tiarmclang does not do that.

    Thanks and regards,

    -George

  • Hi George,

    So is there a way to start the chain of symbol references, such as adding an additional file to the link command? In TI SDK such as mcu_plus_sdk_awr294x_08_02_00_25, I see a file called linker.cmd, not sure if this file can be used.

    Thanks,

    Matthew

  • Typically, source files in the project are compiled to object files, and those object files start the chain of symbol references.  

    I see a file called linker.cmd

    That's an important file.  Though it is not immediately related to this problem.  To learn more about it, please see the article Linker Command File Primer.  

    Even more generally ... Before going much further, I recommend you build and run one of the examples in the SDK.  That's likely to give you useful background knowledge about how TI projects are typically organized.

    Thanks and regards,

    -George

  • Hi George,

    I tried a SDK example to link without linker.cmd, it dumped out the following info:

    $ /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/bin/tiarmclang -Wl,--diag_suppress=10063 -Wl,--ram_model -Wl,--reread_libs -Wl,-i/home/mmao/Works/ti/mmwave_mcuplus_sdk_04_02_00_03/mcu_plus_sdk_awr294x_08_02_00_25/source/kernel/freertos/lib -Wl,-i/home/mmao/Works/ti/mmwave_mcuplus_sdk_04_02_00_03/mcu_plus_sdk_awr294x_08_02_00_25/source/drivers/lib -Wl,-i/home/mmao/Works/ti/mmwave_mcuplus_sdk_04_02_00_03/mcu_plus_sdk_awr294x_08_02_00_25/source/board/lib -Wl,-i/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib -Wl,-m=hello_world.release.map -o hello_world.release.out obj/release/hello_world.obj obj/release/main.obj obj/release/ti_drivers_config.obj obj/release/ti_drivers_open_close.obj obj/release/ti_board_config.obj obj/release/ti_board_open_close.obj obj/release/ti_dpl_config.obj obj/release/ti_pinmux_
    config.obj obj/release/ti_power_clock_config.obj -lfreertos.awr294x.r5f.ti-arm-clang.release.lib -ldrivers.awr294x.r5f.ti-arm-clang.release.lib -lboard.awr294x.r5f.ti-arm-clang.release.lib -llibc.a -v
    TI Arm Clang Compiler 1.3.0.LTS
    Target: arm-ti-none-eabi
    Thread model: posix
    InstalledDir: /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/bin
    "/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/bin/tiarmlnk" -I/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib -o hello_world.release.out --diag_suppress=10063 --ram_model --reread_libs -i/home/mmao/Works/ti/mmwave_mcuplus_sdk_04_02_00_03/mcu_plus_sdk_awr294x_08_02_00_25/source/kernel/freertos/lib -i/home/mmao/Works/ti/mmwave_mcuplus_sdk_04_02_00_03/mcu_plus_sdk_awr294x_08_02_00_25/source/drivers/lib -i/home/mmao/Works/ti/mmwave_mcuplus_sdk_04_02_00_03/mcu_plus_sdk_awr294x_08_02_00_25/source/board/lib -i/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib -m=hello_world.release.map obj/release/hello_world.obj obj/release/main.obj obj/release/ti_drivers_config.obj obj/release/ti_drivers_open_close.obj obj/release/ti_board_config.obj obj/release/ti_board_open_close.obj obj/release/ti_dpl_config.obj obj/release/ti_pinmux_config.obj obj/release/ti_power_clock_config.obj -lfreertos.awr294x.r5f.ti-arm-clang.release.lib -ldrivers.awr294x.r5f.ti-arm-clang.release.lib -lboard.awr294x.r5f.ti-arm-clang.release.lib -llibc.a --start-group -llibc++.a -llibc++abi.a -llibc.a -llibsys.a -llibsysbm.a -llibclang_rt.builtins.a -llibclang_rt.profile.a --end-group

    undefined first referenced
    symbol in file
    --------- ----------------
    __ABORT_STACK_END /home/mmao/Works/ti/mmwave_mcuplus_sdk_04_02_00_03/mcu_plus_sdk_awr294x_08_02_00_25/source/kernel/freertos/lib/freertos.awr294x.r5f.ti-arm-clang.release.lib<boot_armv7r_asm.obj>
    __BSS_END /home/mmao/Works/ti/mmwave_mcuplus_sdk_04_02_00_03/mcu_plus_sdk_awr294x_08_02_00_25/source/kernel/freertos/lib/freertos.awr294x.r5f.ti-arm-clang.release.lib<boot_armv7r.obj>
    __BSS_START /home/mmao/Works/ti/mmwave_mcuplus_sdk_04_02_00_03/mcu_plus_sdk_awr294x_08_02_00_25/source/kernel/freertos/lib/freertos.awr294x.r5f.ti-arm-clang.release.lib<boot_armv7r.obj>
    __FIQ_STACK_END /home/mmao/Works/ti/mmwave_mcuplus_sdk_04_02_00_03/mcu_plus_sdk_awr294x_08_02_00_25/source/kernel/freertos/lib/freertos.awr294x.r5f.ti-arm-clang.release.lib<boot_armv7r_asm.obj>
    __IRQ_STACK_END /home/mmao/Works/ti/mmwave_mcuplus_sdk_04_02_00_03/mcu_plus_sdk_awr294x_08_02_00_25/source/kernel/freertos/lib/freertos.awr294x.r5f.ti-arm-clang.release.lib<boot_armv7r_asm.obj>
    __SVC_STACK_END /home/mmao/Works/ti/mmwave_mcuplus_sdk_04_02_00_03/mcu_plus_sdk_awr294x_08_02_00_25/source/kernel/freertos/lib/freertos.awr294x.r5f.ti-arm-clang.release.lib<boot_armv7r_asm.obj>
    __UNDEFINED_STACK_END /home/mmao/Works/ti/mmwave_mcuplus_sdk_04_02_00_03/mcu_plus_sdk_awr294x_08_02_00_25/source/kernel/freertos/lib/freertos.awr294x.r5f.ti-arm-clang.release.lib<boot_armv7r_asm.obj>

    error: unresolved symbols remain
    error: errors encountered during linking; "hello_world.release.out" not built
    tiarmclang: error: tiarmlnk command failed with exit code 1 (use -v to see invocation)

    In this case, it tells me what are missing for linking due to no linker.cmd. Which file contains the starting point for linking in this case?

    In my original case, it seems it can not start linking because of no starting point of the chain references based on one of your previous responses. Should the main() function be the start point for linking? If yes, the libHOST_tests.lib does contain a main() function.

    I'll check the document you pointed out for linking command.

    Thanks,

    Matthew

  • Which file contains the starting point for linking in this case?

    The linker option ...

    -Wl,--ram_model

    ... tells the linker to observe several conventions required for linking C/C++ code.  Among these conventions is that the entry point of the program is the symbol _c_int00.  This symbol is defined in this RTS library supplied with the compiler ...

    -llibc.a

    That function calls the function main, which is probably defined in ...

    obj/release/main.obj

    ... and on it goes.  

    Please understand that these errors ...

    undefined first referenced
    symbol in file
    --------- ----------------
    __ABORT_STACK_END

    ... are quite different from the ones that appear in your first post.  This says code in the system refers to the symbol __ABORT_STACK_END, but no definition is found.  In this case, the definition of that symbol must be supplied in the missing linker.cmd.

    All of this is how things are typically organized in a TI project.

    Thanks and regards,

    -George

  • Hi George,

    Adding linker option -Wl,--ram_model and compiler library -llibc.a to my first linking command seems not triggering the linking operation and gets same output as below:

    $ /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/bin/tiarmclang -std=c11 -mcpu=cortex-r5 -mfloat-abi=hard -mfpu=vfpv3-d16 -m32 -O0 -g3 -pipe -fno-short-enums -fno-builtin -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -Wl,--diag_suppress=10063 -Wl,--ram_model -Wl,--reread_libs -L _build/TI_ARMLLVM/HSM/lib/ -L /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib -o _build/TI_ARMLLVM/TI_ARMLLVM -L _build/TI_ARMLLVM/HSM/bin -L _build/TI_ARMLLVM/HOST/bin -llibHSM.lib -llibHOST_tests.lib -llibHOST.lib -llibc.a -v
    TI Arm Clang Compiler 1.3.0.LTS
    Target: arm-ti-none-eabi
    Thread model: posix
    InstalledDir: /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/bin
    "/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/bin/tiarmlnk" --search_path _build/TI_ARMLLVM/HSM/lib/ --search_path /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib --search_path _build/TI_ARMLLVM/HSM/bin --search_path _build/TI_ARMLLVM/HOST/bin -I/home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib -o _build/TI_ARMLLVM/TI_ARMLLVM --diag_suppress=10063 --ram_model --reread_libs -llibHSM.lib -llibHOST_tests.lib -llibHOST.lib -llibc.a --start-group -llibc++.a -llibc++abi.a -llibc.a -llibsys.a -llibsysbm.a -llibclang_rt.builtins.a -llibclang_rt.profile.a --end-group --cg_opt_level=0
    warning: cannot resolve archive
    /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libc.a
    to a compatible library, as no input files have been encountered
    warning: cannot resolve archive
    /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libc++
    .a to a compatible library, as no input files have been encountered
    warning: cannot resolve archive
    /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libc++
    abi.a to a compatible library, as no input files have been encountered
    warning: cannot resolve archive
    /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libsys
    .a to a compatible library, as no input files have been encountered
    warning: cannot resolve archive
    /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libsys
    bm.a to a compatible library, as no input files have been encountered
    warning: cannot resolve archive
    /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libcla
    ng_rt.builtins.a to a compatible library, as no input files have been
    encountered
    warning: cannot resolve archive
    /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libcla
    ng_rt.profile.a to a compatible library, as no input files have been
    encountered
    fatal error: no input files
    tiarmclang: error: tiarmlnk command failed with exit code 1 (use -v to see invocation)

    But it works in AWR294x SDK example build. Here below is the main entry in libHOST_tests.lib:

    $ /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/bin/tiarmnm --debug-syms _build/TI_ARMLLVM/HOST/bin/libHOST_tests.lib | grep main
    test_support_main.o:
    00000000 t .text.main
    00000000 T main
    00000000 a test_support_main.c

    Do I still miss something?

    Thanks,

    Matthew

  • There is another reason at least one object file is required in the link.

    The library libc.a (and others like it) is not a collection of object files, but a collection of libraries.  It is called an index library.  To learn more about them, please see this page from the tiarmclang online manual.  Note how the tools choose between individual libraries in a single index library by using the build attributes of an object file file supplied in the link.  If no object file is supplied, then this choice cannot be made, which results in the diagnostic ...

    warning: cannot resolve archive
    /home/mmao/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib/libc.a
    to a compatible library, as no input files have been encountered

    Thanks and regards,

    -George