This patch updates the toolchain description for MSP430 target, aligning it with the TI-provided sysroot based on msp430-gcc v9.2.0.
It leaves some features (such as sanitizer runtimes, LTO, etc.) unsupported, trying to translate the remaining parts of the link_command spec description from current GCC version as closely as possible.
It introduces support for GCC -msim option to Clang that simplifies building msp430 binaries to be run on a simulator (such as for unit testing purposes).
This patch contains updated unit tests to prevent silent changing of the behavior. Its current behavior can be manually tested as follows:
- Compile and run on the simulator: compiles successfully, runs as expected, terminates cleanly
$ /path/to/bin/clang -target msp430 --sysroot=$sysroot test.c -o test -msim $ $sysroot/bin/msp430-elf-run ./test N = 1
- Compile for a real MCU: links successfully, can be run with MSP430 Emulator after manually setting pc to address written at the reset vector (0xFFFE)
$ /path/to/bin/clang -target msp430 --sysroot=$sysroot -mmcu=msp430g2553 blink.c -o blink -I $sysroot/include
Please note that in the latter case msp430-elf-gcc requires -I... option as well.
Current state:
- can run simple programs on a simulator built into msp430-elf-gdb
- can link a program by passing just a --sysroot=/path/to/msp430-gcc/binary/distrib
- tested on third-party MSP430 Emulator, see above
- not tested on a real hardware
- may require further adjustment of --gcc-toolchain option handling
#include <stdio.h> int main() { printf("N = %d\n", 1); return 0; }
References:
I'd guard this by if (GCCInstallation.isValid()) to avoid adding include directories with relative paths if GCCInstallation.getInstallPath() is empty.