AdaCore / gnat-llvm

LLVM based GNAT compiler
179 stars 18 forks source link

Building a Ravenscar full runtime #28

Closed TintoEdoardo closed 2 years ago

TintoEdoardo commented 2 years ago

Good afternoon, are there any reference points for building a Ravenscar full runtime with GNAT LLVM? In particular, I am interested in building one for an ARM-EABI (zynq7000) target. Kind regards, Edoardo Tinto

ArnaudCharlet commented 2 years ago

Hello, Not that I know of. I would start with the same building recipe as for GNAT GCC, adding the gprbuild switch --target=llvm to replace gnat gcc with gnat llvm, and possibly combined with the compiler switch (-cargs in gprbuild parlance) --target=arm-elf. Do not hesitate to share your findings here!

TintoEdoardo commented 2 years ago

Hello, I found that Clang (v13) generates an error when I try to compile start-ram.S, which is taken from the Ravenscar full sources for ARM-ELF (2018). Here it is the command I used and the corresponding output:

clang --target=arm-none-eabi -mcpu=cortex-a9 -mlittle-endian -mfloat-abi=hard -mfpu=vfpv3 -marm -march=armv7 -mno-unaligned-access -c start-ram.S

start-ram.S:192:2: error: invalid instruction, did you mean: adr? adrl r0, __mmu_l0 ^

From these two open issues on the LLVM repository, it seems that the instruction adrl is not supported by Clang.

ArnaudCharlet commented 2 years ago

Thank you for sharing your experience. Hopefully this will be fixed in LLVM upstream. If you find a workaround (rewrite) in start-ram.S, let us know!

TintoEdoardo commented 2 years ago

Hello, I would like to ask for suggestions regarding a possible workaround.

This is the original source code (lines 191-192, from start-ram.S): /* Initialize MMU. */ adrl r0, __mmu_l0

I tried to use the pseudo-instruction ldr instead of adrl: /* Initialize MMU. */ // adrl r0, __mmu_l0 ldr r0,=__mmu_l0

I applied the change to the Ravenscar full runtime for ARM-ELF (2018), and compiled it with standard gnat-gcc. Finally, I tried to run a simple application over a target board (Zynq7000) in order to compare the output generated during this execution and that of an application running on the same target but using the original runtime (without modifications). Quite superficial as a comparison, however both applications execute and produce the expected result.

Could it be a feasible workaround?

Thanks for your support and time.

Fabien-Chouteau commented 2 years ago

Hello @TintoEdoardo,

For this you should open a pull-request in this repo: https://github.com/AdaCore/bb-runtimes The file to change is here: https://github.com/AdaCore/bb-runtimes/blob/community-2021/arm/zynq/start-ram.S

Thank you,