[cfe-commits] r168168 - in /cfe/trunk: lib/Driver/ToolChains.cpp lib/Driver/Tools.cpp runtime/compiler-rt/Makefile

Chandler Carruth chandlerc at google.com
Mon Nov 19 08:37:45 PST 2012


This needs a regression test for the driver.
On Nov 16, 2012 4:55 AM, "Alexey Samsonov" <samsonov at google.com> wrote:

> Author: samsonov
> Date: Fri Nov 16 06:53:14 2012
> New Revision: 168168
>
> URL: http://llvm.org/viewvc/llvm-project?rev=168168&view=rev
> Log:
> UBSan: enable proper linking with UBsan runtime on Darwin. Turn on
> building ubsan on OS X in 'make' build system. Patch by Jean-Daniel Dupas.
>
> Modified:
>     cfe/trunk/lib/Driver/ToolChains.cpp
>     cfe/trunk/lib/Driver/Tools.cpp
>     cfe/trunk/runtime/compiler-rt/Makefile
>
> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=168168&r1=168167&r2=168168&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Nov 16 06:53:14 2012
> @@ -317,12 +317,29 @@
>
>    SanitizerArgs Sanitize(getDriver(), Args);
>
> +  // Add Ubsan runtime library, if required.
> +  if (Sanitize.needsUbsanRt()) {
> +    if (Args.hasArg(options::OPT_dynamiclib) ||
> +        Args.hasArg(options::OPT_bundle)) {
> +      // Assume the binary will provide the Ubsan runtime.
> +    } else if (isTargetIPhoneOS()) {
> +      getDriver().Diag(diag::err_drv_clang_unsupported_per_platform)
> +        << "-fsanitize=undefined";
> +    } else {
> +      AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.ubsan_osx.a");
> +
> +      // The Ubsan runtime library requires C++.
> +      AddCXXStdlibLibArgs(Args, CmdArgs);
> +    }
> +  }
> +
>    // Add ASAN runtime library, if required. Dynamic libraries and bundles
>    // should not be linked with the runtime library.
>    if (Sanitize.needsAsanRt()) {
>      if (Args.hasArg(options::OPT_dynamiclib) ||
> -        Args.hasArg(options::OPT_bundle)) return;
> -    if (isTargetIPhoneOS()) {
> +        Args.hasArg(options::OPT_bundle)) {
> +      // Assume the binary will provide the ASan runtime.
> +    } else if (isTargetIPhoneOS()) {
>        getDriver().Diag(diag::err_drv_clang_unsupported_per_platform)
>          << "-fsanitize=address";
>      } else {
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=168168&r1=168167&r2=168168&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Fri Nov 16 06:53:14 2012
> @@ -4710,10 +4710,11 @@
>    Args.AddAllArgs(CmdArgs, options::OPT_L);
>
>    SanitizerArgs Sanitize(getToolChain().getDriver(), Args);
> -  // If we're building a dynamic lib with -fsanitize=address, unresolved
> -  // symbols may appear. Mark all of them as dynamic_lookup.
> -  // Linking executables is handled in lib/Driver/ToolChains.cpp.
> -  if (Sanitize.needsAsanRt()) {
> +  // If we're building a dynamic lib with -fsanitize=address, or
> +  // -fsanitize=undefined, unresolved symbols may appear. Mark all
> +  // of them as dynamic_lookup. Linking executables is handled in
> +  // lib/Driver/ToolChains.cpp.
> +  if (Sanitize.needsAsanRt() || Sanitize.needsUbsanRt()) {
>      if (Args.hasArg(options::OPT_dynamiclib) ||
>          Args.hasArg(options::OPT_bundle)) {
>        CmdArgs.push_back("-undefined");
>
> Modified: cfe/trunk/runtime/compiler-rt/Makefile
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/compiler-rt/Makefile?rev=168168&r1=168167&r2=168168&view=diff
>
> ==============================================================================
> --- cfe/trunk/runtime/compiler-rt/Makefile (original)
> +++ cfe/trunk/runtime/compiler-rt/Makefile Fri Nov 16 06:53:14 2012
> @@ -76,7 +76,8 @@
>  RuntimeLibrary.darwin.Configs := \
>         eprintf.a 10.4.a osx.a ios.a cc_kext.a cc_kext_ios5.a \
>         asan_osx.a asan_osx_dynamic.dylib \
> -       profile_osx.a profile_ios.a
> +       profile_osx.a profile_ios.a \
> +       ubsan_osx.a
>  endif
>
>  # On Linux, include a library which has all the runtime functions.
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121119/5ebd9f0d/attachment.html>


More information about the cfe-commits mailing list