(MSP430 is a family of 16-bit microcontrollers)

Disclaimer: This target is not ready for prime time. This is a call for participation to get it in better shape.

If you have the right hardware, please test it and report your findings in this issue. That issue is where we are discussing support for this target and the next steps to take.

Minimal, non-working (*) example

(*) won’t work (will probably crash) if actually flashed on a device

There’s no “in tree” target for this architecture so you’ll have to use a custom target specified by a JSON file.

$ cat msp430.json { "arch": "msp430", "data-layout": "e-m:e-p:16:16-i32:16:32-a:16-n8:16", "executables": true, "linker": "msp430-elf-gcc", "llvm-target": "msp430", "max-atomic-width": 0, "no-integrated-as": true, "os": "none", "panic-strategy": "abort", "relocation-model": "static", "target-endian": "little", "target-pointer-width": "16" } $ cat foo.rs #![feature(lang_items)] #![feature(no_core)] #![no_core] #![no_main] #[no_mangle] pub fn main() -> ! { loop {} } #[lang = "copy"] trait Copy {} #[lang = "sized"] trait Sized {} $ rustc --target msp430 foo.rs --emit=obj $ msp430-elf-objdump -Cd foo.o foo.o: file format elf32-msp430 Disassembly of section .text.main: 00000000 <main>: 0: 21 83 decd r1 ; 2: 00 3c jmp $+2 ;abs 0x4 00000004 <.LBB0_1>: 4: 00 3c jmp $+2 ;abs 0x6 00000006 <.LBB0_2>: 6: 00 3c jmp $+2 ;abs 0x8

Compiling core

In theory, you can build a no_std program with these commands:

$ cargo new --bin app && cd $_ # NOTE you have to manually expand the `$(rustc --print sysroot)` command $ edit Cargo.toml && tail -n2 $_ [dependencies.core] path = "$(rustc --print sysroot)/lib/rustlib/src/rust/src/libcore" $ cat src/main.rs #![no_main] #![no_std] #[no_mangle] pub fn main() -> ! { loop {} } $ rustup component add rust-src $ ls msp430.json msp430.json $ cargo build --target msp430