UBsan working

Hesham Almatary hesham.almatary at cl.cam.ac.uk
Sun Apr 5 17:24:43 UTC 2020


Hello,

Apologies for the lag in replies (I have a lot on my plate atm).

Two notes about RISC-V support in Clang/LLVM support. First, RISC-V
support in there is relatively new, so it's not as mature as GCC and
it lacks some features. Second, the RTEMS backend in Clang itself
doesn't exist upstream. I added support to our LLVM fork [1] for
RTEMS. I can add that repo to RSB until I have time to upstream my
RTEMS support to LLVM's upstream.

Suyash, you'll need to build the LLVM toolchain from [1] to build
RISC-V RTEMS targets. I haven't tried to build UBSan though.
Cross-compiling RTEMS using Clang/LLVM isn't straightforward; you'll
also need to build compiler-rt (libgcc's flavour of LLVM) and newlib
manually and tell RTEMS about their locations. Otherwise, you can just
use the ones from GCC, but you'll still have to tell RTEMS about where
they are by exporting them to $NEWLIB_SYSROOT [2].

Gedare and Joel, I have pending RISC-V Clang/LLVM changes to:
1) build RTEMS/RISC-V with Clang/LLVM using Waf.
2) build rtems-examples using Clang/LLVM.
3) Build libbsd using Clang/LLVM.

I will create tickets for those until I manage to submit patches for them.

Let me know if you have any questions or need help building things.

[1] https://github.com/CTSRD-CHERI/llvm-project
[2] https://github.com/RTEMS/rtems/blob/d582d0e130a463842e27070a2e85ebc1acc7b71f/bsps/riscv/riscv/config/rv32iac_clang.cfg#L8


On Sun, 5 Apr 2020 at 17:58, suyash singh <suyashsingh234 at gmail.com> wrote:
>
> 1) Build clang and UBSan with RSB
> 2) Build the supported BSPs with clang so that scan-build and UBSan work
>
> I built rv32iac_clang with scan-build
>
>
>
> scan-build seems to work for it.
>
> But the make is failing for some reason
>
> On Sun, Apr 5, 2020 at 8:23 PM Gedare Bloom <gedare at rtems.org> wrote:
>>
>> Hi Suyash,
>>
>> This is fine, but what is really needed is to know if/how they might work on RTEMS.
>>
>> Gedare
>>
>> On Sun, Apr 5, 2020 at 2:05 AM suyash singh <suyashsingh234 at gmail.com> wrote:
>>>
>>> Undefined behavior sanitizer
>>>
>>>
>>> clang's documentation is incomplete on llvm sanitizers. Also clang installs the ubsan files at wrong locations. There is no solution on google, so I wrote my own
>>>
>>>  I have written the steps for installation here
>>>
>>> https://github.com/suyashsingh234/rtems-notes/blob/master/README.md
>>>
>>>
>>> _______________________________________________
>>> devel mailing list
>>> devel at rtems.org
>>> http://lists.rtems.org/mailman/listinfo/devel
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list