I've followed the adding a new target rustc-dev guide using a pre-built LLVM. Note that ARC is an experimental LLVM target (like m68k). I'm attempting to compile for the arc-unknown-none-elf target triple. What I've done so far:
- Specify pre-built llvm-config path in config.toml.
- Created a target specification JSON file.
supported_targets macro in
rustc_target::spec and created a target rs file.
- If I run
llvm-config --targets-built with the pre-built
llvm-config I get
X86 ARC so LLVM should support it.
EXTRA_CHECK_CFGS as described by rustc-dev
DESTDIR=/path/to/destdir ./x install -i --stage 1 --host arc-unknown-none-elf.json --target arc-unknown-non-elf compiler/rustc
./x install above I get to the step:
Creating a sysroot for stage1 compiler (use
rustup toolchain link 'name' build/host/stage1)
Building stage0 library artifacts (x86_64-unknown-linux-gnu -> arc-unknown-none-elf(arc-unknown-none-elf.json))
It fails due to the error:
error: could not create LLVM TargetMachine for triple: arc-unknown-none-elf: No available targets are compatible with triple "arc-unknown-none-elf".
If you don't get an answer here, you may want to ask on the internals forum as well.
There's a bit of overlap, but most of the people on the user forums are end users of Rust, whereas most of the people on the internal forums are working on the language itself. There's also a Zulip server that a lot of the compiler people hang out on.
You can also try the rust-dev channel in discord.
Thanks for the help.
I added the
init_target! macro call and added arc to
OPTIONAL_COMPONENTS in rustc_llvm/build.rs.
However after running
./x install I saw that ARC doesn't implement
LLVMInitializeARCAsmParser like other ISA's (e.g.
LLVMInitializeRISCVAsmParser) After removing the AsmParser from the macro, I got the same error I initially described. Is something like
LLVMInitializeARCAsmParser necessary for Rust? Or is it only needed for inline assembly?
LLVM may be missing an integrated assembler for ARC. Rustc doesn't support invoking an external assembler.
Where in M68k's directory reference and ARC's directory reference do you see you can invoke an external assembler?
Hey @rusty0, I wanted to follow up and ask if you had any idea on how to use an external assembler for rustc and where in the LLVM directory reference's it's discussed.
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:
You can test the compiled Rust code using QEMU. Follow kolerov's synopsys repository on how to build QEMU for ARC.
./test.sh in rustc_codegen_gcc still fails.
- The first issue you'll experience is an
- 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.