RFC: Building RTEMS/RISC-V with LLVM/Clang

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Nov 14 07:27:36 UTC 2019


Hello Hesham,

On 13/11/2019 16:32, Hesham Almatary wrote:
> On Wed, 13 Nov 2019 at 14:48, Sebastian Huber
> <sebastian.huber at embedded-brains.de> wrote:
>>
>> Hello Hesham,
>>
>> On 23/10/2019 15:50, Hesham Almatary wrote:
>>> Hi,
>>>
>>> I submitted a RFC patch series to be able to build RTEMS/RISC-V with
>>> LLVM/Clang. I'd appreciate your feedback on that.
>>>
>>> A sample configure line to build RTEMS with LLVM/Clang is:
>>>
>>> ../rtems/configure --target=riscv-rtems6
>>> --enable-rtemsbsp=rv64imafdc_clang  CC_FOR_TARGET="clang"
>>> CXX_FOR_TARGET="clang++" AR_FOR_TARGET="llvm-ar"
>>
>> Could you provide me a 64-bit Linux binary installation of your clang
>> toolchain so that I can test it locally?
>>
> https://drive.google.com/file/d/1I0WHOMT2CCkxn_9mz7_WxEXXgCp6yNab/view?usp=sharing

thanks, you can delete the file if you want.

> 
> You can you also to build it yourself from source here
> https://github.com/CTSRD-CHERI/llvm-project
> 
>>>
>>> NEWLIB_SYSROOT env variable needs to point to where newlib is
>>> installed while configuring/building RTEMS.
>>
>> To which directory NEWLIB_SYSROOT in the /opt/rtems/5 installation tree
>> must this point?
>>
> riscv-rtems5. Or the corresponding multilib directory for your RISC-V BSP.

So, if I use --sysroot=/opt/rtems/5/riscv-rtems5, then clang will pick 
up /opt/rtems/5/riscv-rtems5/include for the headers and 
/opt/rtems/5/riscv-rtems5/lib for the libraries. I guess this works only 
for the default multilib. What do I have to do to use another multilib? 
Add a -L/build/rtems/5/riscv-rtems5/lib/rv32im/ilp32 before the 
--sysroot? Why don't you use -I and -L instead of the --sysroot? This 
--sysroot seems to me quite unsafe in combination with multilibs.

I tried to to this, unfortunately it doesn't work with assembler files:

[  65/3840] Compiling cpukit/score/cpu/riscv/riscv-counter.S
08:12:49 runner ['/build/rtems-clang-riscv/sdk/bin/clang', '-DASM', 
'-target', 'riscv32-unknown-rtems6', '-Icpukit/include', 
'-I../../../cpukit/include', '-Icpukit/score/cpu/riscv/include', 
'-I../../../cpukit/score/cpu/riscv/include', 
'../../../cpukit/score/cpu/riscv/riscv-counter.S', 
'cpukit/score/cpu/riscv/riscv-counter.S.20.o']
clang-10: error: invalid argument 'missing --sysroot= option' not 
allowed with 'rtems driver'

For C files, it is not an issue:

[  63/3840] Compiling bsps/riscv/riscv/clock/clockdrv.c
08:23:20 runner ['/build/rtems-clang-riscv/sdk/bin/clang', '-MMD', 
'-Wmissing-prototypes', '-Wimplicit-function-declaration', 
'-Wstrict-prototypes', '-Wnested-externs', '-Wall', '-O2', '-g', 
'-fdata-sections', '-ffunction-sections', '-target', 
'riscv32-unknown-rtems6', '-I/build/rtems/5/riscv-rtems5/include', 
'-Icpukit/include', '-I../../../cpukit/include', 
'-Icpukit/score/cpu/riscv/include', 
'-I../../../cpukit/score/cpu/riscv/include', '-Ibsps/include', 
'-I../../../bsps/include', '-Ibsps/riscv/include', 
'-I../../../bsps/riscv/include', '-Ibsps/riscv/riscv/include', 
'-I../../../bsps/riscv/riscv/include', 
'../../../bsps/riscv/riscv/clock/clockdrv.c', '-c', 
'-o/home/EB/sebastian_h/git-rtems-5/build/riscv/rv32imac/bsps/riscv/riscv/clock/clockdrv.c.5.o', 
'-DHAVE_CONFIG_H=1']

This looks like a bug in the RTEMS clang driver. Are you able to fix it?

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


More information about the devel mailing list