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

Hans Wennborg hans at chromium.org
Tue Aug 27 11:37:12 PDT 2013


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

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 :/



More information about the llvm-commits mailing list