[PATCH] Allow to use -fsanitize=address for iOS simulator

Alexander Potapenko glider at google.com
Sun Mar 17 12:31:19 PDT 2013


To some extent. I'm able to compile and link small Chrome tests with this
patch, and they work fine under the simulator.
I'm still not sure whether we need to build a separate version of the
runtime targeting the simulator.
On Mar 15, 2013 8:49 PM, "Anna Zaks" <ganna at apple.com> wrote:

> Alex,
>
> Does this mean that ASan is now supported on the iOS simulator?
>
> Thanks,
> Anna.
>
> On Mar 15, 2013, at 9:13 AM, Alexander Potapenko <glider at google.com>
> wrote:
>
> +Ted, Anna
>
> On Fri, Mar 15, 2013 at 8:13 PM, Alexander Potapenko <glider at google.com>
> wrote:
>
> This patch lets the users invoke `clang -fsanitize=address` to link
> binaries targeting the iOS simulator.
>
> http://llvm-reviews.chandlerc.com/D545
>
> Files:
>  lib/Driver/ToolChains.cpp
>
> Index: lib/Driver/ToolChains.cpp
> ===================================================================
> --- lib/Driver/ToolChains.cpp
> +++ lib/Driver/ToolChains.cpp
> @@ -335,17 +335,19 @@
>   // 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)) {
> -      // Assume the binary will provide the ASan runtime.
> -    } else if (isTargetIPhoneOS()) {
> +    if (isTargetIPhoneOS() && !isTargetIOSSimulator()) {
>       getDriver().Diag(diag::err_drv_clang_unsupported_per_platform)
>         << "-fsanitize=address";
>     } else {
> -      AddLinkRuntimeLib(Args, CmdArgs,
> "libclang_rt.asan_osx_dynamic.dylib", true);
> -
> -      // The ASAN runtime library requires C++.
> -      AddCXXStdlibLibArgs(Args, CmdArgs);
> +      if (Args.hasArg(options::OPT_dynamiclib) ||
> +          Args.hasArg(options::OPT_bundle)) {
> +        // Assume the binary will provide the ASan runtime.
> +      } else {
> +        AddLinkRuntimeLib(Args, CmdArgs,
> +                          "libclang_rt.asan_osx_dynamic.dylib", true);
> +        // The ASAN runtime library requires C++.
> +        AddCXXStdlibLibArgs(Args, CmdArgs);
> +      }
>     }
>   }
>
>
>
>
> --
> Alexander Potapenko
> Software Engineer
> Google Moscow
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130317/dbfb5d26/attachment.html>


More information about the cfe-commits mailing list