[cfe-commits] [llvm-commits] [PATCH] Add -fcatch-undefined-behavior runtime library

PaX Team pageexec at freemail.hu
Sat Oct 6 04:31:25 PDT 2012


On 4 Oct 2012 at 11:53, Richard Smith wrote:

> On Thu, Oct 4, 2012 at 3:36 AM, PaX Team <pageexec at freemail.hu> wrote:
> > would it be possible to check for -ffreestanding here and not add the
> > library
> > forcibly in that case? i'm (once again ;) thinking of a kernel environment
> > here
> > where using such a library may not be an option (no c++ allowed for one)
> > and the
> > kernel would like to handle these functions in its own way (much like it
> > handles
> > memcpy, etc already).
> 
> 
> It would certainly be possible, but I'm not in favor of it, because I'm not
> happy to make API stability guarantees for the compiler->runtime interface.
> I'd much rather provide a stable API for some (replaceable) diagnostic
> reporting facility within the runtime.

the problem is that whatever stable API you come up with, it may very well
be unusable in freestanding environments, or at least in kernel contexts:

 - certain projects like linux don't accept C++ code in their codebase at
   all, and no amount of C wrappers will help that,
 - there're also runtime contexts when you don't want to execute any more
   complex code than an "ud2".

> You can get the effect you're asking for by not specifying
> -fcatch-undefined-behavior when you link, but if you go down this path,
> I won't promise not to break you. 

for projects like linux there's no choice for the above mentioned reasons
so one will have to cope with the interface changes regardless of whether
clang forces the use of the ubsan library or not.




More information about the cfe-commits mailing list