[PATCH] Driver: implement --runtime-sysroot option.

Peter Collingbourne peter at pcc.me.uk
Fri May 24 04:57:34 PDT 2013


On Thu, May 23, 2013 at 09:43:09PM +0200, Joerg Sonnenberger wrote:
> On Thu, May 23, 2013 at 03:21:18PM -0400, Rafael EspĂ­ndola wrote:
> > This option is not present in gcc. If it is just to select the dynamic
> > linker, why not use -Wl,--dynamic-linker?
> 
> I agree with Rafael that I find this a very strange option.

Rafael, Joerg,

I thought that I would give some more information about the background
and motivations behind this patch.

Currently, our dynamic instrumentation tools (ASan, TSan, MSan)
must correctly model libc functions without instrumenting libc.  We
currently do this either by intercepting them or (in the case of MSan)
using dynamic binary instrumentation.  Interception involves manually
writing an instrumented version of each relevant libc function, which
is time consuming and not necessarily precise, while dynamic binary
instrumentation is generally slower than compile-time instrumentation.

To solve these problems, I am working on an alternative approach
where libc is also instrumented using *San (i.e., full-process
compile-time instrumentation).  Since the instrumented libc (including
the dynamic loader, which on Linux is closely tied to glibc) cannot
live in the root directory, an alternative sysroot must be used.
Hence the --runtime-sysroot option.

Why not use -Wl,--dynamic-linker for this?  Well, one of the goals of
the sanitizer tools is ease of use.  It would not be user friendly to
require the user to supply the correct path to the dynamic loader
(which can vary depending on the platform) in order to enable
full-process compile-time instrumentation.  One could also consider
infrastructure which would cause -fsanitize=* options to imply an
appropriate runtime sysroot, for which the ability to specify the
runtime sysroot would be an important prerequisite.

Thanks,
-- 
Peter



More information about the cfe-commits mailing list