[PATCH] D56000: [compiler-rt] [xray] Disable alignas() for thread_local objects on NetBSD

Kamil Rytarowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 21 08:41:25 PST 2018


krytarowski added inline comments.


================
Comment at: lib/xray/xray_basic_logging.cc:58
 
-struct alignas(64) ThreadLocalData {
+struct
+/* TLD is not aligned properly on NetBSD, resulting in segfault */
----------------
krytarowski wrote:
> mgorny wrote:
> > krytarowski wrote:
> > > Can we introduce a macro like:
> > > 
> > > ```
> > > #if SANITIZER_NETBSD
> > > #define XRAY_TLS_ALIGNAS64 /* Nor supported */
> > > #else
> > > #define XRAY_TLS_ALIGNED_SUPPORTED
> > > #define XRAY_TLS_ALIGNAS64 alignas(64)
> > > #endif
> > > ```
> > > 
> > > And later:
> > > 
> > > ```
> > > struct XRAY_TLS_ALIGNAS64 ThreadLocalData {
> > > ```
> > > 
> > > and
> > > 
> > > ```
> > > #ifdef XRAY_TLS_ALIGNED_SUPPORTED
> > > static_assert(alignof(ThreadLocalData) >= 64,
> > >               "ThreadLocalData must be cache line aligned.");
> > > #endif
> > > ```
> > Maybe. Though i suppose it'd make more sense to make `64` an argument to the macro.
> ```
> #if !SANITIZER_NETBSD
> #define XRAY_TLS_ALIGNAS(x) alignas(x)
> #endif
> ```
> 
> ```
> struct XRAY_TLS_ALIGNAS(64) ThreadLocalData {
> ```
> 
> and
> 
> ```
> #ifdef XRAY_TLS_ALIGNAS
> static_assert(alignof(ThreadLocalData) >= 64,
>               "ThreadLocalData must be cache line aligned.");
> #endif
> ```
Oops, actually not fully correct, but some variation of the above.


Repository:
  rCRT Compiler Runtime

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56000/new/

https://reviews.llvm.org/D56000





More information about the llvm-commits mailing list