[PATCH] Working on reconciling out-of-tree patches to compiler-rt for building for iOS.

Justin Bogner mail at justinbogner.com
Fri Jun 19 17:03:25 PDT 2015


Chris Bieneman <beanz at apple.com> writes:
> This is one of many changes needed for compiler-rt to get it building on iOS.
>
> This change does the following:
> - Don't include crt_externs on iOS (it isn't available)
> - Support ARM thread state objects
>
> Note: this change does not enable building for iOS, as there are more
> changes to come.

LGTM. One comment below.

> http://reviews.llvm.org/D10510
>
> Files:
>   lib/sanitizer_common/sanitizer_mac.cc
>
> Index: lib/sanitizer_common/sanitizer_mac.cc
> ===================================================================
> --- lib/sanitizer_common/sanitizer_mac.cc
> +++ lib/sanitizer_common/sanitizer_mac.cc
> @@ -30,7 +30,12 @@
>  #include "sanitizer_platform_limits_posix.h"
>  #include "sanitizer_procmaps.h"
>  
> +#if !TARGET_OS_IPHONE
>  #include <crt_externs.h>  // for _NSGetEnviron
> +#else
> +extern char **environ;
> +#endif
> +
>  #include <errno.h>
>  #include <fcntl.h>
>  #include <libkern/OSAtomic.h>
> @@ -191,13 +196,15 @@
>  }
>  
>  const char *GetEnv(const char *name) {
> +#if !TARGET_OS_IPHONE
>    char ***env_ptr = _NSGetEnviron();
>    if (!env_ptr) {
>      Report("_NSGetEnviron() returned NULL. Please make sure __asan_init() is "
>             "called after libSystem_initializer().\n");
>      CHECK(env_ptr);
>    }
>    char **environ = *env_ptr;
> +#endif
>    CHECK(environ);
>    uptr name_len = internal_strlen(name);
>    while (*environ != 0) {
> @@ -358,15 +365,30 @@
>  
>  void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
>    ucontext_t *ucontext = (ucontext_t*)context;
> -# if SANITIZER_WORDSIZE == 64
> +# if defined(__aarch64__)
> +  *pc = ucontext->uc_mcontext->__ss.__pc;
> +  // See <rdar://19552184>.
> +# if defined(__IPHONE_8_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
> +  *bp = ucontext->uc_mcontext->__ss.__fp;
> +# else
> +  *bp = ucontext->uc_mcontext->__ss.__lr;
> +# endif
> +  *sp = ucontext->uc_mcontext->__ss.__sp;
> +# elif defined(__x86_64__)
>    *pc = ucontext->uc_mcontext->__ss.__rip;
>    *bp = ucontext->uc_mcontext->__ss.__rbp;
>    *sp = ucontext->uc_mcontext->__ss.__rsp;
> -# else
> +# elif defined(__arm__)
> +  *pc = ucontext->uc_mcontext->__ss.__pc;
> +  *bp = ucontext->uc_mcontext->__ss.__r[7];
> +  *sp = ucontext->uc_mcontext->__ss.__sp;
> +# elif defined(__i386__)
>    *pc = ucontext->uc_mcontext->__ss.__eip;
>    *bp = ucontext->uc_mcontext->__ss.__ebp;
>    *sp = ucontext->uc_mcontext->__ss.__esp;
> -# endif  // SANITIZER_WORDSIZE
> +# else
> +# error "Unknown architecture"
> +# endif
>  }
>  
>  }  // namespace __sanitizer
>
> EMAIL PREFERENCES
>   http://reviews.llvm.org/settings/panel/emailpreferences/
> Index: lib/sanitizer_common/sanitizer_mac.cc
> ===================================================================
> --- lib/sanitizer_common/sanitizer_mac.cc
> +++ lib/sanitizer_common/sanitizer_mac.cc
> @@ -30,7 +30,12 @@
>  #include "sanitizer_platform_limits_posix.h"
>  #include "sanitizer_procmaps.h"
>  
> +#if !TARGET_OS_IPHONE
>  #include <crt_externs.h>  // for _NSGetEnviron
> +#else
> +extern char **environ;
> +#endif
> +
>  #include <errno.h>
>  #include <fcntl.h>
>  #include <libkern/OSAtomic.h>
> @@ -191,13 +196,15 @@
>  }
>  
>  const char *GetEnv(const char *name) {
> +#if !TARGET_OS_IPHONE
>    char ***env_ptr = _NSGetEnviron();
>    if (!env_ptr) {
>      Report("_NSGetEnviron() returned NULL. Please make sure __asan_init() is "
>             "called after libSystem_initializer().\n");
>      CHECK(env_ptr);
>    }
>    char **environ = *env_ptr;
> +#endif
>    CHECK(environ);
>    uptr name_len = internal_strlen(name);
>    while (*environ != 0) {
> @@ -358,15 +365,30 @@
>  
>  void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
>    ucontext_t *ucontext = (ucontext_t*)context;
> -# if SANITIZER_WORDSIZE == 64
> +# if defined(__aarch64__)
> +  *pc = ucontext->uc_mcontext->__ss.__pc;
> +  // See <rdar://19552184>.

This comment doesn't add anything. Remove it.

> +# if defined(__IPHONE_8_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
> +  *bp = ucontext->uc_mcontext->__ss.__fp;
> +# else
> +  *bp = ucontext->uc_mcontext->__ss.__lr;
> +# endif
> +  *sp = ucontext->uc_mcontext->__ss.__sp;
> +# elif defined(__x86_64__)
>    *pc = ucontext->uc_mcontext->__ss.__rip;
>    *bp = ucontext->uc_mcontext->__ss.__rbp;
>    *sp = ucontext->uc_mcontext->__ss.__rsp;
> -# else
> +# elif defined(__arm__)
> +  *pc = ucontext->uc_mcontext->__ss.__pc;
> +  *bp = ucontext->uc_mcontext->__ss.__r[7];
> +  *sp = ucontext->uc_mcontext->__ss.__sp;
> +# elif defined(__i386__)
>    *pc = ucontext->uc_mcontext->__ss.__eip;
>    *bp = ucontext->uc_mcontext->__ss.__ebp;
>    *sp = ucontext->uc_mcontext->__ss.__esp;
> -# endif  // SANITIZER_WORDSIZE
> +# else
> +# error "Unknown architecture"
> +# endif
>  }
>  
>  }  // namespace __sanitizer
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list