I got Rust code to compile for the arc-elf32 target using rustc_codegen_gcc and using Heath123's rust-casio-docker repository. Modifications to rust-casio-docker:
- Had to modify rustc_codegen_gcc (applying a patch in the Dockerfile) to remove
fminf, fmin, fmaxf, fmax
frombuiltins
in src/context.rs. - Modified set_superh_flags.patch to only specify
context.add_command_line_option("-mcpu=em4")
(get the-mcpu
flag from ARC-Options). - Changed
wrapped_linker
toarc-elf32-gcc
insh-link-wrap.sh
and changed\x2A
to\x2D
(since that's ARC'se_machine
value) - Changed
linker
in sh3eb-elf.json toarc-elf32-gcc
. - Changed
--target
in the Dockerfile toarc-elf32
.
You can test the compiled Rust code using QEMU. Follow kolerov's synopsys repository on how to build QEMU for ARC.
Note that ./test.sh
in rustc_codegen_gcc still fails.
- The first issue you'll experience is an
arc_legitimize_tls_address
issue. - So remove the thread-local storage (TLS) related tests in example/mini_core.rs.
- The second issue is that arc-elf32-ld can't find libc. I haven't figured out a solution to that yet.