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.

Compiler/MSP430F249: GCC compiler links CPUX code to non-CPUX project

Part Number: MSP430F249

Tool/software: TI C/C++ Compiler

The command line is: /usr/ti/gcc/bin/msp430-elf-gcc -Wl,-L/usr/ti/gcc/include,--gc-sections -mmcu=msp430f249 -g ...

This generates errors like:

/usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: error: main.o uses MSP430 instructions but /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib/crt0.o uses MSP430X

This is using the current version of gcc downloaded this week.

I will have to see if  I can assemble a direct invocation of ld. Assuming that I find a suitable set of library files.

  • The MSP430F249 is MSP430 CPU device, not CPUX. I think you should re-compiler crt0.o for MSP430 CPU.
  • Of course it isn't CPUX, that is entirely the point.

    GCC has to keep several different versions of the libraries around (CPU, CPUX, 16/20 bit pointers) and select between them at link time. It is more than just crt0.o and if I replace all of those with a non-CPUX versions, I will break the compiler for CPUX builds.

    The files that should be used appear to be in subdirectory 430. But gcc didn't give ld that path.

  • I found a way to coerce gcc into using the msp430 ISA when linking by adding a "-mcpu=msp430" to the command line. This option is described as deprecated with -mmcu= being preferred so this is not a fix.
  • Hi,

    I can't reproduce this. What MSP430-GCC package did you use to install the toolchain? What operating system are you using?

    The following invocation built successfully for me (using MSP430-GCC 7.3.2.154).

    ~/ti/msp430-gcc-732/bin/msp430-elf-gcc -Wl,-L/home/jozef/msp430/msp430-gcc-support-files/include/,--gc-sections -mmcu=msp430f249 -g empty.c -I/home/jozef/msp430/msp430-gcc-support-files/include/

  • The verbose version:

    /usr/ti/gcc/bin/msp430-elf-gcc -Wl,-L/usr/ti/gcc/include,--gc-sections -mmcu=msp430f249 -g -v  -o test.elf main.o lcd.o packet.o crc16.o configure.o flash.o padnet.o adc.o queue.o event.o
    Using built-in specs.
    COLLECT_GCC=/usr/ti/gcc/bin/msp430-elf-gcc
    COLLECT_LTO_WRAPPER=/usr/ti/gcc/bin/../libexec/gcc/msp430-elf/7.3.2/lto-wrapper
    Target: msp430-elf
    Configured with: ../../gcc/configure --target=msp430-elf --enable-languages=c,c++ --disable-nls --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --enable-target-optspace --enable-newlib-nano-formatted-io --with-pkgversion='Mitto Systems Limited - msp430-gcc 7.3.2.154'
    Thread model: single
    gcc version 7.3.2 (Mitto Systems Limited - msp430-gcc 7.3.2.154) 
    COMPILER_PATH=/usr/ti/gcc/bin/../libexec/gcc/msp430-elf/7.3.2/:/usr/ti/gcc/bin/../libexec/gcc/:/usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/
    LIBRARY_PATH=/usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/:/usr/ti/gcc/bin/../lib/gcc/:/usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib/
    COLLECT_GCC_OPTIONS='-mmcu=msp430f249' '-g' '-v' '-o' 'test.elf'
     /usr/ti/gcc/bin/../libexec/gcc/msp430-elf/7.3.2/collect2 -plugin /usr/ti/gcc/bin/../libexec/gcc/msp430-elf/7.3.2/liblto_plugin.so -plugin-opt=/usr/ti/gcc/bin/../libexec/gcc/msp430-elf/7.3.2/lto-wrapper -plugin-opt=-fresolution=/tmp/cchd5Lvo.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmul_16 -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lcrt -plugin-opt=-pass-through=-lnosys -plugin-opt=-pass-through=-lgcc -o test.elf /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib/crt0.o /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/crtbegin.o -L/usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2 -L/usr/ti/gcc/bin/../lib/gcc -L/usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib -L/usr/ti/gcc/include --gc-sections main.o lcd.o packet.o crc16.o configure.o flash.o padnet.o adc.o queue.o event.o -lgcc --start-group -lmul_16 -lc -lgcc -lcrt -lnosys --end-group --script=msp430f249.ld -lgcc /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/crtend.o /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib/crtn.o -lgcc
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: error: main.o uses MSP430 instructions but /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib/crt0.o uses MSP430X
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: failed to merge target specific data of file main.o
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: error: lcd.o uses MSP430 instructions but /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib/crt0.o uses MSP430X
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: failed to merge target specific data of file lcd.o
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: error: packet.o uses MSP430 instructions but /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib/crt0.o uses MSP430X
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: failed to merge target specific data of file packet.o
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: error: crc16.o uses MSP430 instructions but /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib/crt0.o uses MSP430X
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: failed to merge target specific data of file crc16.o
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: error: configure.o uses MSP430 instructions but /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib/crt0.o uses MSP430X
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: failed to merge target specific data of file configure.o
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: error: flash.o uses MSP430 instructions but /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib/crt0.o uses MSP430X
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: failed to merge target specific data of file flash.o
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: error: padnet.o uses MSP430 instructions but /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib/crt0.o uses MSP430X
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: failed to merge target specific data of file padnet.o
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: error: adc.o uses MSP430 instructions but /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib/crt0.o uses MSP430X
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: failed to merge target specific data of file adc.o
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: error: queue.o uses MSP430 instructions but /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib/crt0.o uses MSP430X
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: failed to merge target specific data of file queue.o
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: error: event.o uses MSP430 instructions but /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/lib/crt0.o uses MSP430X
    /usr/ti/gcc/bin/../lib/gcc/msp430-elf/7.3.2/../../../../msp430-elf/bin/ld: failed to merge target specific data of file event.o
    collect2: error: ld returned 1 exit status
    make: *** [makefile:23: test.elf] Error 1

  • Thanks, I reproduced it.

    msp430-elf-gcc reads the "devices.csv" file in /usr/ti/gcc/include to determine the correct CPU ISA for the device given to -mmcu. It looks on the paths passed to "-L" and "-I" for this file.

    However, when the "-L" option is passed directly to the linker by prefixing it with "-Wl", msp430-elf-gcc does not search the path for devices.csv, which means it cannot determine the CPU ISA and defaults to MSP430X.

    You do not need to prefix -L with "-Wl", as GCC understands this option and knows to pass the path to the linker. So as a workaround I would recommend adjusting your link line as follows:

    /usr/ti/gcc/bin/msp430-elf-gcc -Wl,--gc-sections -L/usr/ti/gcc/include -mmcu=msp430f249 -g -v  -o test.elf main.o lcd.o packet.o crc16.o configure.o flash.o padnet.o adc.o queue.o event.o

    Meanwhile we will log this bug where "-Wl,-L" is not interpreted properly and aim to get it fixed in an upcoming release.

    Regards

  • That behaviour differs from the 4.1 installation as that command line worked with no trouble .
  • We changed how the toolchain reads the device information during the 5x release series.

    So new devices can now be added by updating the devices.csv file, whilst previously the information was hardcoded into the toolchain. The old behaviour necessitated a new release of the toolchain whenever TI added new devices.

**Attention** This is a public forum