[PATCH] D81676: [MSP430] Align the toolchain definition with the TI's msp430-gcc v8.3.1

Anatoly Trosinenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 11 11:33:00 PDT 2020


atrosinenko created this revision.
atrosinenko added reviewers: broadwaylamb, sepavloff.
Herald added subscribers: s.egerton, dexonsmith, simoncook, emaste.
Herald added a reviewer: espindola.
Herald added a project: clang.
atrosinenko edited the summary of this revision.

This patch updates the toolchain description for MSP430 target, aligning it with the TI-provided sysroot based on msp430-gcc v8.3.1.

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 -I $sysroot/msp430-elf/include -msim
  $ $sysroot/bin/msp430-elf-run ./test
  N = 1

- Compile for a real MCU: links successfully

  $ /path/to/bin/clang -target msp430 --sysroot=$sysroot test.c -o test -I $sysroot/msp430-elf/include -mmcu=msp430g2553

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` (still requires specifying `-I path`)
- **not** yet tested on a real hardware
- may require further adjustment of `--gcc-toolchain` option handling

name=test.c
  #include <stdio.h>
  
  int main()
  {
    printf("N = %d\n", 1);
    return 0;
  }

References:

- https://clang.llvm.org/docs/CrossCompilation.html
- https://www.ti.com/tool/MSP430-GCC-OPENSOURCE
- cfe-users: --sysroot and --gcc-toolchain: any docs etc.? <http://lists.llvm.org/pipermail/cfe-users/2017-June/001155.html>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81676

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/MSP430.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/lib/Driver/ToolChains/MSP430.h
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/430/crtn.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/430/exceptions/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/exceptions/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/exceptions/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/full-memory-range/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/full-memory-range/exceptions/crt0.o
  clang/test/Driver/msp430-toolchain.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81676.270188.patch
Type: text/x-patch
Size: 29324 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200611/8c3576eb/attachment-0001.bin>


More information about the cfe-commits mailing list