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, fmaxfrombuiltinsin src/context.rs. - Modified set_superh_flags.patch to only specify
context.add_command_line_option("-mcpu=em4")(get the-mcpuflag from ARC-Options). - Changed
wrapped_linkertoarc-elf32-gccinsh-link-wrap.shand changed\x2Ato\x2D(since that's ARC'se_machinevalue) - Changed
linkerin sh3eb-elf.json toarc-elf32-gcc. - Changed
--targetin 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_addressissue. - 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.