Figured out I can use --target thumbv6m-linux-eabi, which implies -mthumb.
Now the problem is that if I use

rustc --target thumbv6m-linux-eabi -O --emit obj main.rs -o main.o

instead of three-step process I mentioned before, I get a valid object file
for cortex-m0, but functions have big prologues and symbol table is much
bigger:

         U STACK_LIMIT
         U _GLOBAL_OFFSET_TABLE_
00000000 D _ZN20_rust_crate_map_main16ad67637f924a5c794v0.0E
00000008 r _ZN2hw11GPIO_PIN_NO20hb0b70c1482b61788Gaa4v0.0E
00000000 r _ZN2hw12GPIO_DIR_REG20hb0b70c1482b61788yaa4v0.0E
00000004 r _ZN2hw12GPIO_REG_VAL20hb0b70c1482b61788Caa4v0.0E
00000078 t _ZN4main10__rust_abiE
00000000 t _ZN4wait20h53ffb23463e08f19Maa4v0.0E
         U __aeabi_unwind_cpp_pr0
         U __morestack
0000004c T main

vs.

00000000 D _ZN23_rust_crate_map_main.c016ad67637f924a5c794v0.0E
00000000 T main

in the initial version. Also, I now need to provide __morestack (no idea
what's that about).


On Sun, Mar 23, 2014 at 5:17 PM, Alex Crichton <a...@crichton.co> wrote:

> You should be able to assemble standalone objects for any triple
> through rustc itself, you'll likely have to specify a different linker
> or assembler though:
>
>     rustc foo.rs --target arm-non-linux-gnueabi \
>         -C linker=arm-non-linux-gnueabi-ld \
>         -C ar=arm-non-linux-gnueabi-ar
>
> As you discovered, you can pass through arguments to LLVM via the "-C
> llvm-args=foo" command line option to rustc. If you get complaints
> that it's an unknown command line argument, it's LLVM telling you
> those complaints, not rustc.
>
> On Sun, Mar 23, 2014 at 8:54 AM, Vladimir Pouzanov <farcal...@gmail.com>
> wrote:
> > I'm trying to experiment with rust and some embedded code. Currently I
> have
> > to do a three-pass compilation:
> >
> > rustc --target arm-linux-eabi -O --emit bc main.rs -o main.bc
> > llc -mtriple arm-none-eabi -march=thumb -mcpu=cortex-m0 main.bc -o main.s
> > arm-none-linux-gnueabi-as main.s -o main.o
> >
> > First, I'm not sure how relevant is --target flag for rustc. I seems to
> > change target datalayout/triple in generated bc, but that should be
> > overriden by llc -mtriple anyway, right?
> >
> > Second, I can pass -Ctarget-cpu=cortex-m0, but I cannot pass down
> > -march=thumb, tried this way: -Cllvm-args='--march=thumb', failed with
> > "rustc: Unknown command line argument '--march=thumb'".
> >
> > Any hints on how can I drop explicit llc and as steps here?
> >
> > --
> > Sincerely,
> > Vladimir "Farcaller" Pouzanov
> > http://farcaller.net/
> >
> > _______________________________________________
> > Rust-dev mailing list
> > Rust-dev@mozilla.org
> > https://mail.mozilla.org/listinfo/rust-dev
> >
>



-- 
Sincerely,
Vladimir "Farcaller" Pouzanov
http://farcaller.net/
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to