[compiler-rt] r189356 - Properly generate lists of exported symbols for sanitizer runtimes

Alexey Samsonov samsonov at google.com
Tue Aug 27 12:17:46 PDT 2013


On Tue, Aug 27, 2013 at 10:37 PM, Hans Wennborg <hans at chromium.org> wrote:

> Is there any way we can make this work in the MSVC build too?
>

Hm... I don't know if we need this for Windows/MSVC - what is the link
strategy for -fsanitize=foo
flag there (do we also link sanitizer runtimes into executables, but not
into dll's and therfore have to
export all the necessary symbols?)


>
> On Tue, Aug 27, 2013 at 8:08 AM, Alexey Samsonov <samsonov at google.com>
> wrote:
> > Author: samsonov
> > Date: Tue Aug 27 10:08:02 2013
> > New Revision: 189356
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=189356&view=rev
> > Log:
> > Properly generate lists of exported symbols for sanitizer runtimes
> >
> > This change adds a Python script that is invoked for
> > the just-built sanitizer runtime to generate the list of exported symbols
> > passed to the linker. By default, it contains interceptors and sanitizer
> > interface functions, but can be extended with tool-specific lists.
> >
> ...
> > --- compiler-rt/trunk/cmake/Modules/SanitizerUtils.cmake (added)
> > +++ compiler-rt/trunk/cmake/Modules/SanitizerUtils.cmake Tue Aug 27
> 10:08:02 2013
> > @@ -0,0 +1,22 @@
> > +include(LLVMParseArguments)
> > +
> > +set(SANITIZER_GEN_DYNAMIC_LIST
> > +
>  ${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/scripts/gen_dynamic_list.py)
> > +
> > +# Create a target "<name>-symbols" that would generate the list of
> symbols
> > +# that need to be exported from sanitizer runtime "<name>". Function
> > +# interceptors are exported automatically, user can also provide files
> with
> > +# symbol names that should be exported as well.
> > +#   add_sanitizer_rt_symbols(<name> <files with extra symbols to
> export>)
> > +macro(add_sanitizer_rt_symbols name)
> > +  get_target_property(libfile ${name} LOCATION)
> > +  set(symsfile "${libfile}.syms")
> > +  add_custom_target(${name}-symbols ALL
> > +    COMMAND ${SANITIZER_GEN_DYNAMIC_LIST} ${libfile} ${ARGN}
> > +      > ${symsfile}
>
> I think this should be COMMAND ${PYTHON_EXECUTABLE}
> ${SANITIZER_GEN_DYNAMIC_LIST}
>
> Otherwise, Windows won't know how to open/run the .py file.
>
> > --- compiler-rt/trunk/lib/sanitizer_common/scripts/gen_dynamic_list.py
> (added)
> > +++ compiler-rt/trunk/lib/sanitizer_common/scripts/gen_dynamic_list.py
> Tue Aug 27 10:08:02 2013
> > @@ -0,0 +1,76 @@
> > +#!/usr/bin/env python
> > +#===- lib/sanitizer_common/scripts/gen_dynamic_list.py
> ---------------------===#
> > +#
> > +#                     The LLVM Compiler Infrastructure
> > +#
> > +# This file is distributed under the University of Illinois Open Source
> > +# License. See LICENSE.TXT for details.
> > +#
> >
> +#===------------------------------------------------------------------------===#
> > +#
> > +# Generates the list of functions that should be exported from sanitizer
> > +# runtimes. The output format is recognized by --dynamic-list linker
> option.
> > +# Usage:
> > +#   gen_dynamic_list.py libclang_rt.*san*.a [ files ... ]
> > +#
> >
> +#===------------------------------------------------------------------------===#
> > +import re
> > +import os
> > +import subprocess
> > +import sys
> > +
> > +def get_global_functions(library):
> > +  functions = []
> > +  nm_proc = subprocess.Popen(['nm', library], stdout=subprocess.PIPE)
>
> In the MSVC build, 'nm' is not available. This breaks the build :/
>

See my note above - for now I suggest to "fix" this by only running this
script on Linux
(make add_sanitizer_rt_symbols(...) a no-op or don't call it on another
systems). I would only be able
to do this tomorrow - I'd be grateful if you fix this now to unblock you...
We should also
move Windows CMake compiler-rt build to our buildbot. Timur?

-- 
Alexey Samsonov, MSK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130827/1d4db1b0/attachment.html>


More information about the llvm-commits mailing list