On 2/27/23 12:00, Karel Gardas wrote:
On 2/27/23 02:16, Joel Sherrill wrote:
Another GCC related project could be Rust RTEMS Support but I don't
know what that entails beyond turning it on and seeing what goes
wrong. I tried to build it last year and got far enough to decide to
wait before trying again.
Not sure how far you went. The process is generally:
(1) tune Rust compiler to cross-compile correctly for specific
hardware/os
platform. So basically you get no_std capable compiler
(2) review, patch and by using (1) cross-compile libc
(3) using sources from (1) and (2) build full stage (std enabled) rustc.
(4) tweak and tune tools (rustup/cargo etc.) whenever required to smooth
sharp edges for RTEMS.
Here, I'm nearly finished with (1) for arm-rtems (e.g. cortex-aX not
cortex-
mX).
Something is running:
silence:/tmp$ cat hello-rtems.rs
#![no_std]
#![no_main]
use core::panic::PanicInfo;
use core::ffi::c_char;
use core::ffi::c_int;
extern "C" {
fn puts(str: *const c_char) -> c_int;
}
#[no_mangle]
pub fn main() -> ! {
unsafe {
puts(b"Rust says hello to hosting RTEMS\n\0".as_ptr() as *const
i8);
}
loop {}
}
#[panic_handler]
fn panic(_: &PanicInfo) -> ! {
loop {}
}
silence:/tmp$ /tmp/rustc-rtems-arm/bin/rustc -g -Z verbose
--target=arm-rtems hello-rtems.rs -lrtemscpu -lrtemsbsp -lrtemsdefaultconfig
silence:/tmp$ file hello-rtems.exe
hello-rtems.exe: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV),
statically linked, with debug_info, not stripped
silence:/tmp$ ~rtems/sfw/qemu-7.2.0/bin/qemu-system-arm -serial null
-serial mon:stdio -nographic -M xilinx-zynq-a9 -m 512M -kernel
/tmp/hello-rtems.exe
Rust says hello to hosting RTEMS
QEMU 7.2.0 monitor - type 'help' for more information
(qemu) q
silence:/tmp$
Note: this is hacked rust-lang.org rust compiler, not gccrs project and
soon to be released GCC 13.
The biggest problem and probably soon to be source of headaches is
mixture of LLVM's compiler-rt and GCC's libgcc binaries. This means once
you employ for example arithmetic you need to add
-C link-arg=-Wl,--allow-multiple-definition otherwise you would get
multiple definitions symbols error.
Karel
_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel