Merge #141397: llvmPackages_{5,6,7}.compiler-rt: fix patches

+12 -4100
+1 -2
pkgs/development/compilers/llvm/10/compiler-rt/default.nix
··· 58 58 ./find-darwin-sdk-version.patch # don't test for macOS being >= 10.15 59 59 ./gnu-install-dirs.patch 60 60 ../../common/compiler-rt/libsanitizer-no-cyclades-11.patch 61 - ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch 62 - ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 61 + ] ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 63 62 64 63 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 65 64 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
-412
pkgs/development/compilers/llvm/10/compiler-rt/sanitizers-nongnu.patch
··· 1 - From f7a253f8f85d0f49df6b73996737a3e84ac64236 Mon Sep 17 00:00:00 2001 2 - From: Will Dietz <w@wdtz.org> 3 - Date: Mon, 24 Sep 2018 11:17:25 -0500 4 - Subject: [PATCH] Ported to 7.0, taken from gentoo-musl project. 5 - 6 - ------ 7 - Ported to compiler-rt-sanitizers-5.0.0. Taken from 8 - 9 - https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch 10 - Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> 11 - 12 - Taken from gentoo-musl project, with a few additional minor fixes. 13 - --- 14 - lib/asan/asan_linux.cc | 4 +- 15 - lib/interception/interception_linux.cc | 2 +- 16 - lib/interception/interception_linux.h | 2 +- 17 - lib/msan/msan_linux.cc | 2 +- 18 - lib/sanitizer_common/sanitizer_allocator.cc | 2 +- 19 - .../sanitizer_common_interceptors_ioctl.inc | 4 +- 20 - .../sanitizer_common_syscalls.inc | 2 +- 21 - lib/sanitizer_common/sanitizer_linux.cc | 8 +++- 22 - .../sanitizer_linux_libcdep.cc | 10 ++--- 23 - lib/sanitizer_common/sanitizer_platform.h | 6 +++ 24 - .../sanitizer_platform_interceptors.h | 4 +- 25 - .../sanitizer_platform_limits_posix.cc | 37 +++++++++++-------- 26 - lib/tsan/rtl/tsan_platform_linux.cc | 2 +- 27 - 13 files changed, 51 insertions(+), 34 deletions(-) 28 - 29 - diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc 30 - index 625f32d40..73cf77aca 100644 31 - --- a/lib/asan/asan_linux.cc 32 - +++ b/lib/asan/asan_linux.cc 33 - @@ -46,7 +46,7 @@ 34 - #include <link.h> 35 - #endif 36 - 37 - -#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS 38 - +#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 39 - #include <ucontext.h> 40 - extern "C" void* _DYNAMIC; 41 - #elif SANITIZER_NETBSD 42 - @@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { 43 - UNIMPLEMENTED(); 44 - } 45 - 46 - -#if SANITIZER_ANDROID 47 - +#if SANITIZER_ANDROID || SANITIZER_NONGNU 48 - // FIXME: should we do anything for Android? 49 - void AsanCheckDynamicRTPrereqs() {} 50 - void AsanCheckIncompatibleRT() {} 51 - diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc 52 - index 26bfcd8f6..529b234f7 100644 53 - --- a/lib/interception/interception_linux.cc 54 - +++ b/lib/interception/interception_linux.cc 55 - @@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, 56 - } 57 - 58 - // Android and Solaris do not have dlvsym 59 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 60 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 61 - void *GetFuncAddrVer(const char *func_name, const char *ver) { 62 - return dlvsym(RTLD_NEXT, func_name, ver); 63 - } 64 - diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h 65 - index 942c25609..24a4d5080 100644 66 - --- a/lib/interception/interception_linux.h 67 - +++ b/lib/interception/interception_linux.h 68 - @@ -36,7 +36,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); 69 - (::__interception::uptr) & WRAP(func)) 70 - 71 - // Android, Solaris and OpenBSD do not have dlvsym 72 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 73 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 74 - #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ 75 - (::__interception::real_##func = (func##_f)( \ 76 - unsigned long)::__interception::GetFuncAddrVer(#func, symver)) 77 - diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc 78 - index 385a650c4..6e30a8ce9 100644 79 - --- a/lib/msan/msan_linux.cc 80 - +++ b/lib/msan/msan_linux.cc 81 - @@ -13,7 +13,7 @@ 82 - //===----------------------------------------------------------------------===// 83 - 84 - #include "sanitizer_common/sanitizer_platform.h" 85 - -#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD 86 - +#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD 87 - 88 - #include "msan.h" 89 - #include "msan_report.h" 90 - diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc 91 - index 6bfd5e5ee..048f6154f 100644 92 - --- a/lib/sanitizer_common/sanitizer_allocator.cc 93 - +++ b/lib/sanitizer_common/sanitizer_allocator.cc 94 - @@ -27,7 +27,7 @@ const char *SecondaryAllocatorName = "LargeMmapAllocator"; 95 - 96 - // ThreadSanitizer for Go uses libc malloc/free. 97 - #if SANITIZER_GO || defined(SANITIZER_USE_MALLOC) 98 - -# if SANITIZER_LINUX && !SANITIZER_ANDROID 99 - +# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 100 - extern "C" void *__libc_malloc(uptr size); 101 - # if !SANITIZER_GO 102 - extern "C" void *__libc_memalign(uptr alignment, uptr size); 103 - diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 104 - index 2d633c173..b6eb23116 100644 105 - --- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 106 - +++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 107 - @@ -104,7 +104,7 @@ static void ioctl_table_fill() { 108 - _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); 109 - #endif 110 - 111 - -#if SANITIZER_LINUX 112 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 113 - // Conflicting request ids. 114 - // _(CDROMAUDIOBUFSIZ, NONE, 0); 115 - // _(SNDCTL_TMR_CONTINUE, NONE, 0); 116 - @@ -365,7 +365,7 @@ static void ioctl_table_fill() { 117 - _(VT_WAITACTIVE, NONE, 0); 118 - #endif 119 - 120 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 121 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 122 - // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE 123 - _(CYGETDEFTHRESH, WRITE, sizeof(int)); 124 - _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); 125 - diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc 126 - index 469c8eb7e..24f87867d 100644 127 - --- a/lib/sanitizer_common/sanitizer_common_syscalls.inc 128 - +++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc 129 - @@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { 130 - } 131 - } 132 - 133 - -#if !SANITIZER_ANDROID 134 - +#if !SANITIZER_ANDROID && !SANITIZER_NONGNU 135 - PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, 136 - void *old_rlim) { 137 - if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); 138 - diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc 139 - index 96d6c1eff..9e2b7fb9d 100644 140 - --- a/lib/sanitizer_common/sanitizer_linux.cc 141 - +++ b/lib/sanitizer_common/sanitizer_linux.cc 142 - @@ -541,13 +541,13 @@ const char *GetEnv(const char *name) { 143 - #endif 144 - } 145 - 146 - -#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD 147 - +#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 148 - extern "C" { 149 - SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end; 150 - } 151 - #endif 152 - 153 - -#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 154 - +#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 155 - !SANITIZER_OPENBSD 156 - static void ReadNullSepFileToArray(const char *path, char ***arr, 157 - int arr_size) { 158 - @@ -590,6 +590,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) { 159 - #elif SANITIZER_NETBSD 160 - *argv = __ps_strings->ps_argvstr; 161 - *envp = __ps_strings->ps_envstr; 162 - +#elif SANITIZER_NONGNU 163 - + static const int kMaxArgv = 2000, kMaxEnvp = 2000; 164 - + ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv); 165 - + ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp); 166 - #else // SANITIZER_FREEBSD 167 - #if !SANITIZER_GO 168 - if (&__libc_stack_end) { 169 - diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 170 - index 4962ff832..438f94dbe 100644 171 - --- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc 172 - +++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 173 - @@ -179,7 +179,7 @@ __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor, 174 - } 175 - 176 - #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \ 177 - - !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS 178 - + !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU 179 - static uptr g_tls_size; 180 - 181 - #ifdef __i386__ 182 - @@ -261,7 +261,7 @@ void InitTlsSize() { } 183 - #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) || \ 184 - defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) || \ 185 - defined(__arm__)) && \ 186 - - SANITIZER_LINUX && !SANITIZER_ANDROID 187 - + SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 188 - // sizeof(struct pthread) from glibc. 189 - static atomic_uintptr_t thread_descriptor_size; 190 - 191 - @@ -426,7 +426,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) { 192 - 193 - #if !SANITIZER_GO 194 - static void GetTls(uptr *addr, uptr *size) { 195 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 196 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 197 - # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) 198 - *addr = ThreadSelf(); 199 - *size = GetTlsSize(); 200 - @@ -470,7 +470,7 @@ static void GetTls(uptr *addr, uptr *size) { 201 - #elif SANITIZER_OPENBSD 202 - *addr = 0; 203 - *size = 0; 204 - -#elif SANITIZER_ANDROID 205 - +#elif SANITIZER_ANDROID || SANITIZER_NONGNU 206 - *addr = 0; 207 - *size = 0; 208 - #elif SANITIZER_SOLARIS 209 - @@ -486,7 +486,7 @@ static void GetTls(uptr *addr, uptr *size) { 210 - #if !SANITIZER_GO 211 - uptr GetTlsSize() { 212 - #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \ 213 - - SANITIZER_OPENBSD || SANITIZER_SOLARIS 214 - + SANITIZER_OPENBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 215 - uptr addr, size; 216 - GetTls(&addr, &size); 217 - return size; 218 - diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h 219 - index d81e25580..e10680ac8 100644 220 - --- a/lib/sanitizer_common/sanitizer_platform.h 221 - +++ b/lib/sanitizer_common/sanitizer_platform.h 222 - @@ -208,6 +208,12 @@ 223 - # define SANITIZER_SOLARIS32 0 224 - #endif 225 - 226 - +#if defined(__linux__) && !defined(__GLIBC__) 227 - +# define SANITIZER_NONGNU 1 228 - +#else 229 - +# define SANITIZER_NONGNU 0 230 - +#endif 231 - + 232 - #if defined(__myriad2__) 233 - # define SANITIZER_MYRIAD2 1 234 - #else 235 - diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h 236 - index f95539a73..6c53b3415 100644 237 - --- a/lib/sanitizer_common/sanitizer_platform_interceptors.h 238 - +++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h 239 - @@ -39,7 +39,7 @@ 240 - # include "sanitizer_platform_limits_solaris.h" 241 - #endif 242 - 243 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 244 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 245 - # define SI_LINUX_NOT_ANDROID 1 246 - #else 247 - # define SI_LINUX_NOT_ANDROID 0 248 - @@ -322,7 +322,7 @@ 249 - #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID) 250 - #define SANITIZER_INTERCEPT_SHMCTL \ 251 - (SI_NETBSD || SI_OPENBSD || SI_SOLARIS || \ 252 - - ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \ 253 - + ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \ 254 - SANITIZER_WORDSIZE == 64)) // NOLINT 255 - #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID 256 - #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX 257 - diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 258 - index 54da635d7..2f6ff69c3 100644 259 - --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 260 - +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 261 - @@ -14,6 +14,9 @@ 262 - 263 - #include "sanitizer_platform.h" 264 - 265 - +// Workaround musl <--> linux conflicting definition of 'struct sysinfo' 266 - +#define _LINUX_SYSINFO_H 267 - + 268 - #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC 269 - // Tests in this file assume that off_t-dependent data structures match the 270 - // libc ABI. For example, struct dirent here is what readdir() function (as 271 - @@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; 272 - 273 - #if SANITIZER_LINUX && !SANITIZER_ANDROID 274 - #include <glob.h> 275 - -#include <obstack.h> 276 - +# if !SANITIZER_NONGNU 277 - +# include <obstack.h> 278 - +# endif 279 - #include <mqueue.h> 280 - -#include <net/if_ppp.h> 281 - -#include <netax25/ax25.h> 282 - -#include <netipx/ipx.h> 283 - -#include <netrom/netrom.h> 284 - +#include <linux/if_ppp.h> 285 - +#include <linux/ax25.h> 286 - +#include <linux/ipx.h> 287 - +#include <linux/netrom.h> 288 - #if HAVE_RPC_XDR_H 289 - # include <rpc/xdr.h> 290 - #elif HAVE_TIRPC_RPC_XDR_H 291 - @@ -251,7 +256,7 @@ namespace __sanitizer { 292 - unsigned struct_itimerspec_sz = sizeof(struct itimerspec); 293 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 294 - 295 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 296 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 297 - // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which 298 - // has been removed from glibc 2.28. 299 - #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \ 300 - @@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); 301 - unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 302 - #endif 303 - 304 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 305 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 306 - int glob_nomatch = GLOB_NOMATCH; 307 - int glob_altdirfunc = GLOB_ALTDIRFUNC; 308 - #endif 309 - @@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 310 - unsigned struct_termios_sz = sizeof(struct termios); 311 - unsigned struct_winsize_sz = sizeof(struct winsize); 312 - 313 - -#if SANITIZER_LINUX 314 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 315 - unsigned struct_arpreq_sz = sizeof(struct arpreq); 316 - unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); 317 - unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); 318 - @@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 319 - unsigned struct_vt_mode_sz = sizeof(struct vt_mode); 320 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 321 - 322 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 323 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 324 - unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); 325 - unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); 326 - #if EV_VERSION > (0x010000) 327 - @@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 328 - unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; 329 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 330 - 331 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 332 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 333 - unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; 334 - unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; 335 - unsigned IOCTL_CYGETMON = CYGETMON; 336 - @@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); 337 - CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); 338 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 339 - 340 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 341 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 342 - CHECK_TYPE_SIZE(glob_t); 343 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); 344 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); 345 - @@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec); 346 - CHECK_SIZE_AND_OFFSET(iovec, iov_base); 347 - CHECK_SIZE_AND_OFFSET(iovec, iov_len); 348 - 349 - +#if !SANITIZER_NONGNU 350 - CHECK_TYPE_SIZE(msghdr); 351 - CHECK_SIZE_AND_OFFSET(msghdr, msg_name); 352 - CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); 353 - @@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr); 354 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); 355 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); 356 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); 357 - +#endif 358 - 359 - #ifndef __GLIBC_PREREQ 360 - #define __GLIBC_PREREQ(x, y) 0 361 - @@ -1145,7 +1152,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); 362 - 363 - CHECK_TYPE_SIZE(ether_addr); 364 - 365 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 366 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 367 - CHECK_TYPE_SIZE(ipc_perm); 368 - # if SANITIZER_FREEBSD 369 - CHECK_SIZE_AND_OFFSET(ipc_perm, key); 370 - @@ -1206,7 +1213,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); 371 - CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); 372 - #endif 373 - 374 - -#if SANITIZER_LINUX 375 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 376 - COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); 377 - #endif 378 - 379 - @@ -1256,7 +1263,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); 380 - COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); 381 - #endif 382 - 383 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 384 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 385 - COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); 386 - CHECK_SIZE_AND_OFFSET(FILE, _flags); 387 - CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); 388 - @@ -1275,7 +1282,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); 389 - CHECK_SIZE_AND_OFFSET(FILE, _fileno); 390 - #endif 391 - 392 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 393 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 394 - COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); 395 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); 396 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); 397 - diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc 398 - index de989b780..51a97b554 100644 399 - --- a/lib/tsan/rtl/tsan_platform_linux.cc 400 - +++ b/lib/tsan/rtl/tsan_platform_linux.cc 401 - @@ -294,7 +294,7 @@ void InitializePlatform() { 402 - // This is required to properly "close" the fds, because we do not see internal 403 - // closes within glibc. The code is a pure hack. 404 - int ExtractResolvFDs(void *state, int *fds, int nfd) { 405 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 406 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 407 - int cnt = 0; 408 - struct __res_state *statp = (struct __res_state*)state; 409 - for (int i = 0; i < MAXNS && cnt < nfd; i++) { 410 - -- 411 - 2.19.0 412 -
+1 -2
pkgs/development/compilers/llvm/11/compiler-rt/default.nix
··· 59 59 # extra `/`. 60 60 ./normalize-var.patch 61 61 ../../common/compiler-rt/libsanitizer-no-cyclades-11.patch 62 - ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch 63 - ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 62 + ] ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 64 63 65 64 66 65 preConfigure = lib.optionalString stdenv.hostPlatform.isDarwin ''
-412
pkgs/development/compilers/llvm/11/compiler-rt/sanitizers-nongnu.patch
··· 1 - From f7a253f8f85d0f49df6b73996737a3e84ac64236 Mon Sep 17 00:00:00 2001 2 - From: Will Dietz <w@wdtz.org> 3 - Date: Mon, 24 Sep 2018 11:17:25 -0500 4 - Subject: [PATCH] Ported to 7.0, taken from gentoo-musl project. 5 - 6 - ------ 7 - Ported to compiler-rt-sanitizers-5.0.0. Taken from 8 - 9 - https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch 10 - Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> 11 - 12 - Taken from gentoo-musl project, with a few additional minor fixes. 13 - --- 14 - lib/asan/asan_linux.cc | 4 +- 15 - lib/interception/interception_linux.cc | 2 +- 16 - lib/interception/interception_linux.h | 2 +- 17 - lib/msan/msan_linux.cc | 2 +- 18 - lib/sanitizer_common/sanitizer_allocator.cc | 2 +- 19 - .../sanitizer_common_interceptors_ioctl.inc | 4 +- 20 - .../sanitizer_common_syscalls.inc | 2 +- 21 - lib/sanitizer_common/sanitizer_linux.cc | 8 +++- 22 - .../sanitizer_linux_libcdep.cc | 10 ++--- 23 - lib/sanitizer_common/sanitizer_platform.h | 6 +++ 24 - .../sanitizer_platform_interceptors.h | 4 +- 25 - .../sanitizer_platform_limits_posix.cc | 37 +++++++++++-------- 26 - lib/tsan/rtl/tsan_platform_linux.cc | 2 +- 27 - 13 files changed, 51 insertions(+), 34 deletions(-) 28 - 29 - diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc 30 - index 625f32d40..73cf77aca 100644 31 - --- a/lib/asan/asan_linux.cc 32 - +++ b/lib/asan/asan_linux.cc 33 - @@ -46,7 +46,7 @@ 34 - #include <link.h> 35 - #endif 36 - 37 - -#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS 38 - +#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 39 - #include <ucontext.h> 40 - extern "C" void* _DYNAMIC; 41 - #elif SANITIZER_NETBSD 42 - @@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { 43 - UNIMPLEMENTED(); 44 - } 45 - 46 - -#if SANITIZER_ANDROID 47 - +#if SANITIZER_ANDROID || SANITIZER_NONGNU 48 - // FIXME: should we do anything for Android? 49 - void AsanCheckDynamicRTPrereqs() {} 50 - void AsanCheckIncompatibleRT() {} 51 - diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc 52 - index 26bfcd8f6..529b234f7 100644 53 - --- a/lib/interception/interception_linux.cc 54 - +++ b/lib/interception/interception_linux.cc 55 - @@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, 56 - } 57 - 58 - // Android and Solaris do not have dlvsym 59 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 60 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 61 - void *GetFuncAddrVer(const char *func_name, const char *ver) { 62 - return dlvsym(RTLD_NEXT, func_name, ver); 63 - } 64 - diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h 65 - index 942c25609..24a4d5080 100644 66 - --- a/lib/interception/interception_linux.h 67 - +++ b/lib/interception/interception_linux.h 68 - @@ -36,7 +36,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); 69 - (::__interception::uptr) & WRAP(func)) 70 - 71 - // Android, Solaris and OpenBSD do not have dlvsym 72 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 73 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 74 - #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ 75 - (::__interception::real_##func = (func##_f)( \ 76 - unsigned long)::__interception::GetFuncAddrVer(#func, symver)) 77 - diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc 78 - index 385a650c4..6e30a8ce9 100644 79 - --- a/lib/msan/msan_linux.cc 80 - +++ b/lib/msan/msan_linux.cc 81 - @@ -13,7 +13,7 @@ 82 - //===----------------------------------------------------------------------===// 83 - 84 - #include "sanitizer_common/sanitizer_platform.h" 85 - -#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD 86 - +#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD 87 - 88 - #include "msan.h" 89 - #include "msan_report.h" 90 - diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc 91 - index 6bfd5e5ee..048f6154f 100644 92 - --- a/lib/sanitizer_common/sanitizer_allocator.cc 93 - +++ b/lib/sanitizer_common/sanitizer_allocator.cc 94 - @@ -27,7 +27,7 @@ const char *SecondaryAllocatorName = "LargeMmapAllocator"; 95 - 96 - // ThreadSanitizer for Go uses libc malloc/free. 97 - #if SANITIZER_GO || defined(SANITIZER_USE_MALLOC) 98 - -# if SANITIZER_LINUX && !SANITIZER_ANDROID 99 - +# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 100 - extern "C" void *__libc_malloc(uptr size); 101 - # if !SANITIZER_GO 102 - extern "C" void *__libc_memalign(uptr alignment, uptr size); 103 - diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 104 - index 2d633c173..b6eb23116 100644 105 - --- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 106 - +++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 107 - @@ -104,7 +104,7 @@ static void ioctl_table_fill() { 108 - _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); 109 - #endif 110 - 111 - -#if SANITIZER_LINUX 112 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 113 - // Conflicting request ids. 114 - // _(CDROMAUDIOBUFSIZ, NONE, 0); 115 - // _(SNDCTL_TMR_CONTINUE, NONE, 0); 116 - @@ -365,7 +365,7 @@ static void ioctl_table_fill() { 117 - _(VT_WAITACTIVE, NONE, 0); 118 - #endif 119 - 120 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 121 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 122 - // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE 123 - _(CYGETDEFTHRESH, WRITE, sizeof(int)); 124 - _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); 125 - diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc 126 - index 469c8eb7e..24f87867d 100644 127 - --- a/lib/sanitizer_common/sanitizer_common_syscalls.inc 128 - +++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc 129 - @@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { 130 - } 131 - } 132 - 133 - -#if !SANITIZER_ANDROID 134 - +#if !SANITIZER_ANDROID && !SANITIZER_NONGNU 135 - PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, 136 - void *old_rlim) { 137 - if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); 138 - diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc 139 - index 96d6c1eff..9e2b7fb9d 100644 140 - --- a/lib/sanitizer_common/sanitizer_linux.cc 141 - +++ b/lib/sanitizer_common/sanitizer_linux.cc 142 - @@ -541,13 +541,13 @@ const char *GetEnv(const char *name) { 143 - #endif 144 - } 145 - 146 - -#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD 147 - +#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 148 - extern "C" { 149 - SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end; 150 - } 151 - #endif 152 - 153 - -#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 154 - +#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 155 - !SANITIZER_OPENBSD 156 - static void ReadNullSepFileToArray(const char *path, char ***arr, 157 - int arr_size) { 158 - @@ -590,6 +590,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) { 159 - #elif SANITIZER_NETBSD 160 - *argv = __ps_strings->ps_argvstr; 161 - *envp = __ps_strings->ps_envstr; 162 - +#elif SANITIZER_NONGNU 163 - + static const int kMaxArgv = 2000, kMaxEnvp = 2000; 164 - + ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv); 165 - + ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp); 166 - #else // SANITIZER_FREEBSD 167 - #if !SANITIZER_GO 168 - if (&__libc_stack_end) { 169 - diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 170 - index 4962ff832..438f94dbe 100644 171 - --- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc 172 - +++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 173 - @@ -179,7 +179,7 @@ __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor, 174 - } 175 - 176 - #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \ 177 - - !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS 178 - + !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU 179 - static uptr g_tls_size; 180 - 181 - #ifdef __i386__ 182 - @@ -261,7 +261,7 @@ void InitTlsSize() { } 183 - #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) || \ 184 - defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) || \ 185 - defined(__arm__)) && \ 186 - - SANITIZER_LINUX && !SANITIZER_ANDROID 187 - + SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 188 - // sizeof(struct pthread) from glibc. 189 - static atomic_uintptr_t thread_descriptor_size; 190 - 191 - @@ -426,7 +426,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) { 192 - 193 - #if !SANITIZER_GO 194 - static void GetTls(uptr *addr, uptr *size) { 195 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 196 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 197 - # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) 198 - *addr = ThreadSelf(); 199 - *size = GetTlsSize(); 200 - @@ -470,7 +470,7 @@ static void GetTls(uptr *addr, uptr *size) { 201 - #elif SANITIZER_OPENBSD 202 - *addr = 0; 203 - *size = 0; 204 - -#elif SANITIZER_ANDROID 205 - +#elif SANITIZER_ANDROID || SANITIZER_NONGNU 206 - *addr = 0; 207 - *size = 0; 208 - #elif SANITIZER_SOLARIS 209 - @@ -486,7 +486,7 @@ static void GetTls(uptr *addr, uptr *size) { 210 - #if !SANITIZER_GO 211 - uptr GetTlsSize() { 212 - #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \ 213 - - SANITIZER_OPENBSD || SANITIZER_SOLARIS 214 - + SANITIZER_OPENBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 215 - uptr addr, size; 216 - GetTls(&addr, &size); 217 - return size; 218 - diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h 219 - index d81e25580..e10680ac8 100644 220 - --- a/lib/sanitizer_common/sanitizer_platform.h 221 - +++ b/lib/sanitizer_common/sanitizer_platform.h 222 - @@ -208,6 +208,12 @@ 223 - # define SANITIZER_SOLARIS32 0 224 - #endif 225 - 226 - +#if defined(__linux__) && !defined(__GLIBC__) 227 - +# define SANITIZER_NONGNU 1 228 - +#else 229 - +# define SANITIZER_NONGNU 0 230 - +#endif 231 - + 232 - #if defined(__myriad2__) 233 - # define SANITIZER_MYRIAD2 1 234 - #else 235 - diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h 236 - index f95539a73..6c53b3415 100644 237 - --- a/lib/sanitizer_common/sanitizer_platform_interceptors.h 238 - +++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h 239 - @@ -39,7 +39,7 @@ 240 - # include "sanitizer_platform_limits_solaris.h" 241 - #endif 242 - 243 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 244 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 245 - # define SI_LINUX_NOT_ANDROID 1 246 - #else 247 - # define SI_LINUX_NOT_ANDROID 0 248 - @@ -322,7 +322,7 @@ 249 - #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID) 250 - #define SANITIZER_INTERCEPT_SHMCTL \ 251 - (SI_NETBSD || SI_OPENBSD || SI_SOLARIS || \ 252 - - ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \ 253 - + ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \ 254 - SANITIZER_WORDSIZE == 64)) // NOLINT 255 - #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID 256 - #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX 257 - diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 258 - index 54da635d7..2f6ff69c3 100644 259 - --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 260 - +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 261 - @@ -14,6 +14,9 @@ 262 - 263 - #include "sanitizer_platform.h" 264 - 265 - +// Workaround musl <--> linux conflicting definition of 'struct sysinfo' 266 - +#define _LINUX_SYSINFO_H 267 - + 268 - #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC 269 - // Tests in this file assume that off_t-dependent data structures match the 270 - // libc ABI. For example, struct dirent here is what readdir() function (as 271 - @@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; 272 - 273 - #if SANITIZER_LINUX && !SANITIZER_ANDROID 274 - #include <glob.h> 275 - -#include <obstack.h> 276 - +# if !SANITIZER_NONGNU 277 - +# include <obstack.h> 278 - +# endif 279 - #include <mqueue.h> 280 - -#include <net/if_ppp.h> 281 - -#include <netax25/ax25.h> 282 - -#include <netipx/ipx.h> 283 - -#include <netrom/netrom.h> 284 - +#include <linux/if_ppp.h> 285 - +#include <linux/ax25.h> 286 - +#include <linux/ipx.h> 287 - +#include <linux/netrom.h> 288 - #if HAVE_RPC_XDR_H 289 - # include <rpc/xdr.h> 290 - #elif HAVE_TIRPC_RPC_XDR_H 291 - @@ -251,7 +256,7 @@ namespace __sanitizer { 292 - unsigned struct_itimerspec_sz = sizeof(struct itimerspec); 293 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 294 - 295 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 296 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 297 - // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which 298 - // has been removed from glibc 2.28. 299 - #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \ 300 - @@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); 301 - unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 302 - #endif 303 - 304 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 305 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 306 - int glob_nomatch = GLOB_NOMATCH; 307 - int glob_altdirfunc = GLOB_ALTDIRFUNC; 308 - #endif 309 - @@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 310 - unsigned struct_termios_sz = sizeof(struct termios); 311 - unsigned struct_winsize_sz = sizeof(struct winsize); 312 - 313 - -#if SANITIZER_LINUX 314 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 315 - unsigned struct_arpreq_sz = sizeof(struct arpreq); 316 - unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); 317 - unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); 318 - @@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 319 - unsigned struct_vt_mode_sz = sizeof(struct vt_mode); 320 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 321 - 322 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 323 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 324 - unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); 325 - unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); 326 - #if EV_VERSION > (0x010000) 327 - @@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 328 - unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; 329 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 330 - 331 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 332 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 333 - unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; 334 - unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; 335 - unsigned IOCTL_CYGETMON = CYGETMON; 336 - @@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); 337 - CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); 338 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 339 - 340 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 341 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 342 - CHECK_TYPE_SIZE(glob_t); 343 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); 344 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); 345 - @@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec); 346 - CHECK_SIZE_AND_OFFSET(iovec, iov_base); 347 - CHECK_SIZE_AND_OFFSET(iovec, iov_len); 348 - 349 - +#if !SANITIZER_NONGNU 350 - CHECK_TYPE_SIZE(msghdr); 351 - CHECK_SIZE_AND_OFFSET(msghdr, msg_name); 352 - CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); 353 - @@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr); 354 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); 355 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); 356 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); 357 - +#endif 358 - 359 - #ifndef __GLIBC_PREREQ 360 - #define __GLIBC_PREREQ(x, y) 0 361 - @@ -1145,7 +1152,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); 362 - 363 - CHECK_TYPE_SIZE(ether_addr); 364 - 365 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 366 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 367 - CHECK_TYPE_SIZE(ipc_perm); 368 - # if SANITIZER_FREEBSD 369 - CHECK_SIZE_AND_OFFSET(ipc_perm, key); 370 - @@ -1206,7 +1213,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); 371 - CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); 372 - #endif 373 - 374 - -#if SANITIZER_LINUX 375 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 376 - COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); 377 - #endif 378 - 379 - @@ -1256,7 +1263,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); 380 - COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); 381 - #endif 382 - 383 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 384 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 385 - COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); 386 - CHECK_SIZE_AND_OFFSET(FILE, _flags); 387 - CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); 388 - @@ -1275,7 +1282,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); 389 - CHECK_SIZE_AND_OFFSET(FILE, _fileno); 390 - #endif 391 - 392 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 393 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 394 - COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); 395 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); 396 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); 397 - diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc 398 - index de989b780..51a97b554 100644 399 - --- a/lib/tsan/rtl/tsan_platform_linux.cc 400 - +++ b/lib/tsan/rtl/tsan_platform_linux.cc 401 - @@ -294,7 +294,7 @@ void InitializePlatform() { 402 - // This is required to properly "close" the fds, because we do not see internal 403 - // closes within glibc. The code is a pure hack. 404 - int ExtractResolvFDs(void *state, int *fds, int nfd) { 405 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 406 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 407 - int cnt = 0; 408 - struct __res_state *statp = (struct __res_state*)state; 409 - for (int i = 0; i < MAXNS && cnt < nfd; i++) { 410 - -- 411 - 2.19.0 412 -
+1 -2
pkgs/development/compilers/llvm/12/compiler-rt/default.nix
··· 58 58 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 59 59 # extra `/`. 60 60 ./normalize-var.patch 61 - ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch 62 - ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 61 + ] ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 63 62 64 63 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 65 64 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
-412
pkgs/development/compilers/llvm/12/compiler-rt/sanitizers-nongnu.patch
··· 1 - From f7a253f8f85d0f49df6b73996737a3e84ac64236 Mon Sep 17 00:00:00 2001 2 - From: Will Dietz <w@wdtz.org> 3 - Date: Mon, 24 Sep 2018 11:17:25 -0500 4 - Subject: [PATCH] Ported to 7.0, taken from gentoo-musl project. 5 - 6 - ------ 7 - Ported to compiler-rt-sanitizers-5.0.0. Taken from 8 - 9 - https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch 10 - Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> 11 - 12 - Taken from gentoo-musl project, with a few additional minor fixes. 13 - --- 14 - lib/asan/asan_linux.cc | 4 +- 15 - lib/interception/interception_linux.cc | 2 +- 16 - lib/interception/interception_linux.h | 2 +- 17 - lib/msan/msan_linux.cc | 2 +- 18 - lib/sanitizer_common/sanitizer_allocator.cc | 2 +- 19 - .../sanitizer_common_interceptors_ioctl.inc | 4 +- 20 - .../sanitizer_common_syscalls.inc | 2 +- 21 - lib/sanitizer_common/sanitizer_linux.cc | 8 +++- 22 - .../sanitizer_linux_libcdep.cc | 10 ++--- 23 - lib/sanitizer_common/sanitizer_platform.h | 6 +++ 24 - .../sanitizer_platform_interceptors.h | 4 +- 25 - .../sanitizer_platform_limits_posix.cc | 37 +++++++++++-------- 26 - lib/tsan/rtl/tsan_platform_linux.cc | 2 +- 27 - 13 files changed, 51 insertions(+), 34 deletions(-) 28 - 29 - diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc 30 - index 625f32d40..73cf77aca 100644 31 - --- a/lib/asan/asan_linux.cc 32 - +++ b/lib/asan/asan_linux.cc 33 - @@ -46,7 +46,7 @@ 34 - #include <link.h> 35 - #endif 36 - 37 - -#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS 38 - +#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 39 - #include <ucontext.h> 40 - extern "C" void* _DYNAMIC; 41 - #elif SANITIZER_NETBSD 42 - @@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { 43 - UNIMPLEMENTED(); 44 - } 45 - 46 - -#if SANITIZER_ANDROID 47 - +#if SANITIZER_ANDROID || SANITIZER_NONGNU 48 - // FIXME: should we do anything for Android? 49 - void AsanCheckDynamicRTPrereqs() {} 50 - void AsanCheckIncompatibleRT() {} 51 - diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc 52 - index 26bfcd8f6..529b234f7 100644 53 - --- a/lib/interception/interception_linux.cc 54 - +++ b/lib/interception/interception_linux.cc 55 - @@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, 56 - } 57 - 58 - // Android and Solaris do not have dlvsym 59 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 60 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 61 - void *GetFuncAddrVer(const char *func_name, const char *ver) { 62 - return dlvsym(RTLD_NEXT, func_name, ver); 63 - } 64 - diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h 65 - index 942c25609..24a4d5080 100644 66 - --- a/lib/interception/interception_linux.h 67 - +++ b/lib/interception/interception_linux.h 68 - @@ -36,7 +36,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); 69 - (::__interception::uptr) & WRAP(func)) 70 - 71 - // Android, Solaris and OpenBSD do not have dlvsym 72 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 73 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 74 - #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ 75 - (::__interception::real_##func = (func##_f)( \ 76 - unsigned long)::__interception::GetFuncAddrVer(#func, symver)) 77 - diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc 78 - index 385a650c4..6e30a8ce9 100644 79 - --- a/lib/msan/msan_linux.cc 80 - +++ b/lib/msan/msan_linux.cc 81 - @@ -13,7 +13,7 @@ 82 - //===----------------------------------------------------------------------===// 83 - 84 - #include "sanitizer_common/sanitizer_platform.h" 85 - -#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD 86 - +#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD 87 - 88 - #include "msan.h" 89 - #include "msan_report.h" 90 - diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc 91 - index 6bfd5e5ee..048f6154f 100644 92 - --- a/lib/sanitizer_common/sanitizer_allocator.cc 93 - +++ b/lib/sanitizer_common/sanitizer_allocator.cc 94 - @@ -27,7 +27,7 @@ const char *SecondaryAllocatorName = "LargeMmapAllocator"; 95 - 96 - // ThreadSanitizer for Go uses libc malloc/free. 97 - #if SANITIZER_GO || defined(SANITIZER_USE_MALLOC) 98 - -# if SANITIZER_LINUX && !SANITIZER_ANDROID 99 - +# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 100 - extern "C" void *__libc_malloc(uptr size); 101 - # if !SANITIZER_GO 102 - extern "C" void *__libc_memalign(uptr alignment, uptr size); 103 - diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 104 - index 2d633c173..b6eb23116 100644 105 - --- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 106 - +++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 107 - @@ -104,7 +104,7 @@ static void ioctl_table_fill() { 108 - _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); 109 - #endif 110 - 111 - -#if SANITIZER_LINUX 112 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 113 - // Conflicting request ids. 114 - // _(CDROMAUDIOBUFSIZ, NONE, 0); 115 - // _(SNDCTL_TMR_CONTINUE, NONE, 0); 116 - @@ -365,7 +365,7 @@ static void ioctl_table_fill() { 117 - _(VT_WAITACTIVE, NONE, 0); 118 - #endif 119 - 120 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 121 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 122 - // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE 123 - _(CYGETDEFTHRESH, WRITE, sizeof(int)); 124 - _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); 125 - diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc 126 - index 469c8eb7e..24f87867d 100644 127 - --- a/lib/sanitizer_common/sanitizer_common_syscalls.inc 128 - +++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc 129 - @@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { 130 - } 131 - } 132 - 133 - -#if !SANITIZER_ANDROID 134 - +#if !SANITIZER_ANDROID && !SANITIZER_NONGNU 135 - PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, 136 - void *old_rlim) { 137 - if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); 138 - diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc 139 - index 96d6c1eff..9e2b7fb9d 100644 140 - --- a/lib/sanitizer_common/sanitizer_linux.cc 141 - +++ b/lib/sanitizer_common/sanitizer_linux.cc 142 - @@ -541,13 +541,13 @@ const char *GetEnv(const char *name) { 143 - #endif 144 - } 145 - 146 - -#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD 147 - +#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 148 - extern "C" { 149 - SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end; 150 - } 151 - #endif 152 - 153 - -#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 154 - +#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 155 - !SANITIZER_OPENBSD 156 - static void ReadNullSepFileToArray(const char *path, char ***arr, 157 - int arr_size) { 158 - @@ -590,6 +590,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) { 159 - #elif SANITIZER_NETBSD 160 - *argv = __ps_strings->ps_argvstr; 161 - *envp = __ps_strings->ps_envstr; 162 - +#elif SANITIZER_NONGNU 163 - + static const int kMaxArgv = 2000, kMaxEnvp = 2000; 164 - + ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv); 165 - + ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp); 166 - #else // SANITIZER_FREEBSD 167 - #if !SANITIZER_GO 168 - if (&__libc_stack_end) { 169 - diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 170 - index 4962ff832..438f94dbe 100644 171 - --- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc 172 - +++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 173 - @@ -179,7 +179,7 @@ __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor, 174 - } 175 - 176 - #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \ 177 - - !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS 178 - + !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU 179 - static uptr g_tls_size; 180 - 181 - #ifdef __i386__ 182 - @@ -261,7 +261,7 @@ void InitTlsSize() { } 183 - #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) || \ 184 - defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) || \ 185 - defined(__arm__)) && \ 186 - - SANITIZER_LINUX && !SANITIZER_ANDROID 187 - + SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 188 - // sizeof(struct pthread) from glibc. 189 - static atomic_uintptr_t thread_descriptor_size; 190 - 191 - @@ -426,7 +426,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) { 192 - 193 - #if !SANITIZER_GO 194 - static void GetTls(uptr *addr, uptr *size) { 195 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 196 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 197 - # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) 198 - *addr = ThreadSelf(); 199 - *size = GetTlsSize(); 200 - @@ -470,7 +470,7 @@ static void GetTls(uptr *addr, uptr *size) { 201 - #elif SANITIZER_OPENBSD 202 - *addr = 0; 203 - *size = 0; 204 - -#elif SANITIZER_ANDROID 205 - +#elif SANITIZER_ANDROID || SANITIZER_NONGNU 206 - *addr = 0; 207 - *size = 0; 208 - #elif SANITIZER_SOLARIS 209 - @@ -486,7 +486,7 @@ static void GetTls(uptr *addr, uptr *size) { 210 - #if !SANITIZER_GO 211 - uptr GetTlsSize() { 212 - #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \ 213 - - SANITIZER_OPENBSD || SANITIZER_SOLARIS 214 - + SANITIZER_OPENBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 215 - uptr addr, size; 216 - GetTls(&addr, &size); 217 - return size; 218 - diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h 219 - index d81e25580..e10680ac8 100644 220 - --- a/lib/sanitizer_common/sanitizer_platform.h 221 - +++ b/lib/sanitizer_common/sanitizer_platform.h 222 - @@ -208,6 +208,12 @@ 223 - # define SANITIZER_SOLARIS32 0 224 - #endif 225 - 226 - +#if defined(__linux__) && !defined(__GLIBC__) 227 - +# define SANITIZER_NONGNU 1 228 - +#else 229 - +# define SANITIZER_NONGNU 0 230 - +#endif 231 - + 232 - #if defined(__myriad2__) 233 - # define SANITIZER_MYRIAD2 1 234 - #else 235 - diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h 236 - index f95539a73..6c53b3415 100644 237 - --- a/lib/sanitizer_common/sanitizer_platform_interceptors.h 238 - +++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h 239 - @@ -39,7 +39,7 @@ 240 - # include "sanitizer_platform_limits_solaris.h" 241 - #endif 242 - 243 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 244 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 245 - # define SI_LINUX_NOT_ANDROID 1 246 - #else 247 - # define SI_LINUX_NOT_ANDROID 0 248 - @@ -322,7 +322,7 @@ 249 - #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID) 250 - #define SANITIZER_INTERCEPT_SHMCTL \ 251 - (SI_NETBSD || SI_OPENBSD || SI_SOLARIS || \ 252 - - ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \ 253 - + ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \ 254 - SANITIZER_WORDSIZE == 64)) // NOLINT 255 - #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID 256 - #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX 257 - diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 258 - index 54da635d7..2f6ff69c3 100644 259 - --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 260 - +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 261 - @@ -14,6 +14,9 @@ 262 - 263 - #include "sanitizer_platform.h" 264 - 265 - +// Workaround musl <--> linux conflicting definition of 'struct sysinfo' 266 - +#define _LINUX_SYSINFO_H 267 - + 268 - #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC 269 - // Tests in this file assume that off_t-dependent data structures match the 270 - // libc ABI. For example, struct dirent here is what readdir() function (as 271 - @@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; 272 - 273 - #if SANITIZER_LINUX && !SANITIZER_ANDROID 274 - #include <glob.h> 275 - -#include <obstack.h> 276 - +# if !SANITIZER_NONGNU 277 - +# include <obstack.h> 278 - +# endif 279 - #include <mqueue.h> 280 - -#include <net/if_ppp.h> 281 - -#include <netax25/ax25.h> 282 - -#include <netipx/ipx.h> 283 - -#include <netrom/netrom.h> 284 - +#include <linux/if_ppp.h> 285 - +#include <linux/ax25.h> 286 - +#include <linux/ipx.h> 287 - +#include <linux/netrom.h> 288 - #if HAVE_RPC_XDR_H 289 - # include <rpc/xdr.h> 290 - #elif HAVE_TIRPC_RPC_XDR_H 291 - @@ -251,7 +256,7 @@ namespace __sanitizer { 292 - unsigned struct_itimerspec_sz = sizeof(struct itimerspec); 293 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 294 - 295 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 296 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 297 - // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which 298 - // has been removed from glibc 2.28. 299 - #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \ 300 - @@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); 301 - unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 302 - #endif 303 - 304 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 305 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 306 - int glob_nomatch = GLOB_NOMATCH; 307 - int glob_altdirfunc = GLOB_ALTDIRFUNC; 308 - #endif 309 - @@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 310 - unsigned struct_termios_sz = sizeof(struct termios); 311 - unsigned struct_winsize_sz = sizeof(struct winsize); 312 - 313 - -#if SANITIZER_LINUX 314 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 315 - unsigned struct_arpreq_sz = sizeof(struct arpreq); 316 - unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); 317 - unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); 318 - @@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 319 - unsigned struct_vt_mode_sz = sizeof(struct vt_mode); 320 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 321 - 322 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 323 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 324 - unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); 325 - unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); 326 - #if EV_VERSION > (0x010000) 327 - @@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 328 - unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; 329 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 330 - 331 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 332 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 333 - unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; 334 - unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; 335 - unsigned IOCTL_CYGETMON = CYGETMON; 336 - @@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); 337 - CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); 338 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 339 - 340 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 341 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 342 - CHECK_TYPE_SIZE(glob_t); 343 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); 344 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); 345 - @@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec); 346 - CHECK_SIZE_AND_OFFSET(iovec, iov_base); 347 - CHECK_SIZE_AND_OFFSET(iovec, iov_len); 348 - 349 - +#if !SANITIZER_NONGNU 350 - CHECK_TYPE_SIZE(msghdr); 351 - CHECK_SIZE_AND_OFFSET(msghdr, msg_name); 352 - CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); 353 - @@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr); 354 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); 355 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); 356 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); 357 - +#endif 358 - 359 - #ifndef __GLIBC_PREREQ 360 - #define __GLIBC_PREREQ(x, y) 0 361 - @@ -1145,7 +1152,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); 362 - 363 - CHECK_TYPE_SIZE(ether_addr); 364 - 365 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 366 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 367 - CHECK_TYPE_SIZE(ipc_perm); 368 - # if SANITIZER_FREEBSD 369 - CHECK_SIZE_AND_OFFSET(ipc_perm, key); 370 - @@ -1206,7 +1213,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); 371 - CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); 372 - #endif 373 - 374 - -#if SANITIZER_LINUX 375 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 376 - COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); 377 - #endif 378 - 379 - @@ -1256,7 +1263,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); 380 - COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); 381 - #endif 382 - 383 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 384 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 385 - COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); 386 - CHECK_SIZE_AND_OFFSET(FILE, _flags); 387 - CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); 388 - @@ -1275,7 +1282,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); 389 - CHECK_SIZE_AND_OFFSET(FILE, _fileno); 390 - #endif 391 - 392 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 393 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 394 - COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); 395 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); 396 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); 397 - diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc 398 - index de989b780..51a97b554 100644 399 - --- a/lib/tsan/rtl/tsan_platform_linux.cc 400 - +++ b/lib/tsan/rtl/tsan_platform_linux.cc 401 - @@ -294,7 +294,7 @@ void InitializePlatform() { 402 - // This is required to properly "close" the fds, because we do not see internal 403 - // closes within glibc. The code is a pure hack. 404 - int ExtractResolvFDs(void *state, int *fds, int nfd) { 405 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 406 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 407 - int cnt = 0; 408 - struct __res_state *statp = (struct __res_state*)state; 409 - for (int i = 0; i < MAXNS && cnt < nfd; i++) { 410 - -- 411 - 2.19.0 412 -
+1 -2
pkgs/development/compilers/llvm/13/compiler-rt/default.nix
··· 60 60 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 61 61 # extra `/`. 62 62 ./normalize-var.patch 63 - ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch 64 - # Prevent a compilation error on darwin 63 + ] # Prevent a compilation error on darwin 65 64 ++ lib.optional stdenv.hostPlatform.isDarwin ./darwin-targetconditionals.patch 66 65 ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 67 66
-412
pkgs/development/compilers/llvm/13/compiler-rt/sanitizers-nongnu.patch
··· 1 - From f7a253f8f85d0f49df6b73996737a3e84ac64236 Mon Sep 17 00:00:00 2001 2 - From: Will Dietz <w@wdtz.org> 3 - Date: Mon, 24 Sep 2018 11:17:25 -0500 4 - Subject: [PATCH] Ported to 7.0, taken from gentoo-musl project. 5 - 6 - ------ 7 - Ported to compiler-rt-sanitizers-5.0.0. Taken from 8 - 9 - https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch 10 - Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> 11 - 12 - Taken from gentoo-musl project, with a few additional minor fixes. 13 - --- 14 - lib/asan/asan_linux.cc | 4 +- 15 - lib/interception/interception_linux.cc | 2 +- 16 - lib/interception/interception_linux.h | 2 +- 17 - lib/msan/msan_linux.cc | 2 +- 18 - lib/sanitizer_common/sanitizer_allocator.cc | 2 +- 19 - .../sanitizer_common_interceptors_ioctl.inc | 4 +- 20 - .../sanitizer_common_syscalls.inc | 2 +- 21 - lib/sanitizer_common/sanitizer_linux.cc | 8 +++- 22 - .../sanitizer_linux_libcdep.cc | 10 ++--- 23 - lib/sanitizer_common/sanitizer_platform.h | 6 +++ 24 - .../sanitizer_platform_interceptors.h | 4 +- 25 - .../sanitizer_platform_limits_posix.cc | 37 +++++++++++-------- 26 - lib/tsan/rtl/tsan_platform_linux.cc | 2 +- 27 - 13 files changed, 51 insertions(+), 34 deletions(-) 28 - 29 - diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc 30 - index 625f32d40..73cf77aca 100644 31 - --- a/lib/asan/asan_linux.cc 32 - +++ b/lib/asan/asan_linux.cc 33 - @@ -46,7 +46,7 @@ 34 - #include <link.h> 35 - #endif 36 - 37 - -#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS 38 - +#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 39 - #include <ucontext.h> 40 - extern "C" void* _DYNAMIC; 41 - #elif SANITIZER_NETBSD 42 - @@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { 43 - UNIMPLEMENTED(); 44 - } 45 - 46 - -#if SANITIZER_ANDROID 47 - +#if SANITIZER_ANDROID || SANITIZER_NONGNU 48 - // FIXME: should we do anything for Android? 49 - void AsanCheckDynamicRTPrereqs() {} 50 - void AsanCheckIncompatibleRT() {} 51 - diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc 52 - index 26bfcd8f6..529b234f7 100644 53 - --- a/lib/interception/interception_linux.cc 54 - +++ b/lib/interception/interception_linux.cc 55 - @@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, 56 - } 57 - 58 - // Android and Solaris do not have dlvsym 59 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 60 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 61 - void *GetFuncAddrVer(const char *func_name, const char *ver) { 62 - return dlvsym(RTLD_NEXT, func_name, ver); 63 - } 64 - diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h 65 - index 942c25609..24a4d5080 100644 66 - --- a/lib/interception/interception_linux.h 67 - +++ b/lib/interception/interception_linux.h 68 - @@ -36,7 +36,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); 69 - (::__interception::uptr) & WRAP(func)) 70 - 71 - // Android, Solaris and OpenBSD do not have dlvsym 72 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 73 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 74 - #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ 75 - (::__interception::real_##func = (func##_f)( \ 76 - unsigned long)::__interception::GetFuncAddrVer(#func, symver)) 77 - diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc 78 - index 385a650c4..6e30a8ce9 100644 79 - --- a/lib/msan/msan_linux.cc 80 - +++ b/lib/msan/msan_linux.cc 81 - @@ -13,7 +13,7 @@ 82 - //===----------------------------------------------------------------------===// 83 - 84 - #include "sanitizer_common/sanitizer_platform.h" 85 - -#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD 86 - +#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD 87 - 88 - #include "msan.h" 89 - #include "msan_report.h" 90 - diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc 91 - index 6bfd5e5ee..048f6154f 100644 92 - --- a/lib/sanitizer_common/sanitizer_allocator.cc 93 - +++ b/lib/sanitizer_common/sanitizer_allocator.cc 94 - @@ -27,7 +27,7 @@ const char *SecondaryAllocatorName = "LargeMmapAllocator"; 95 - 96 - // ThreadSanitizer for Go uses libc malloc/free. 97 - #if SANITIZER_GO || defined(SANITIZER_USE_MALLOC) 98 - -# if SANITIZER_LINUX && !SANITIZER_ANDROID 99 - +# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 100 - extern "C" void *__libc_malloc(uptr size); 101 - # if !SANITIZER_GO 102 - extern "C" void *__libc_memalign(uptr alignment, uptr size); 103 - diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 104 - index 2d633c173..b6eb23116 100644 105 - --- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 106 - +++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 107 - @@ -104,7 +104,7 @@ static void ioctl_table_fill() { 108 - _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); 109 - #endif 110 - 111 - -#if SANITIZER_LINUX 112 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 113 - // Conflicting request ids. 114 - // _(CDROMAUDIOBUFSIZ, NONE, 0); 115 - // _(SNDCTL_TMR_CONTINUE, NONE, 0); 116 - @@ -365,7 +365,7 @@ static void ioctl_table_fill() { 117 - _(VT_WAITACTIVE, NONE, 0); 118 - #endif 119 - 120 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 121 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 122 - // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE 123 - _(CYGETDEFTHRESH, WRITE, sizeof(int)); 124 - _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); 125 - diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc 126 - index 469c8eb7e..24f87867d 100644 127 - --- a/lib/sanitizer_common/sanitizer_common_syscalls.inc 128 - +++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc 129 - @@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { 130 - } 131 - } 132 - 133 - -#if !SANITIZER_ANDROID 134 - +#if !SANITIZER_ANDROID && !SANITIZER_NONGNU 135 - PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, 136 - void *old_rlim) { 137 - if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); 138 - diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc 139 - index 96d6c1eff..9e2b7fb9d 100644 140 - --- a/lib/sanitizer_common/sanitizer_linux.cc 141 - +++ b/lib/sanitizer_common/sanitizer_linux.cc 142 - @@ -541,13 +541,13 @@ const char *GetEnv(const char *name) { 143 - #endif 144 - } 145 - 146 - -#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD 147 - +#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 148 - extern "C" { 149 - SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end; 150 - } 151 - #endif 152 - 153 - -#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 154 - +#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 155 - !SANITIZER_OPENBSD 156 - static void ReadNullSepFileToArray(const char *path, char ***arr, 157 - int arr_size) { 158 - @@ -590,6 +590,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) { 159 - #elif SANITIZER_NETBSD 160 - *argv = __ps_strings->ps_argvstr; 161 - *envp = __ps_strings->ps_envstr; 162 - +#elif SANITIZER_NONGNU 163 - + static const int kMaxArgv = 2000, kMaxEnvp = 2000; 164 - + ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv); 165 - + ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp); 166 - #else // SANITIZER_FREEBSD 167 - #if !SANITIZER_GO 168 - if (&__libc_stack_end) { 169 - diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 170 - index 4962ff832..438f94dbe 100644 171 - --- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc 172 - +++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 173 - @@ -179,7 +179,7 @@ __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor, 174 - } 175 - 176 - #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \ 177 - - !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS 178 - + !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU 179 - static uptr g_tls_size; 180 - 181 - #ifdef __i386__ 182 - @@ -261,7 +261,7 @@ void InitTlsSize() { } 183 - #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) || \ 184 - defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) || \ 185 - defined(__arm__)) && \ 186 - - SANITIZER_LINUX && !SANITIZER_ANDROID 187 - + SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 188 - // sizeof(struct pthread) from glibc. 189 - static atomic_uintptr_t thread_descriptor_size; 190 - 191 - @@ -426,7 +426,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) { 192 - 193 - #if !SANITIZER_GO 194 - static void GetTls(uptr *addr, uptr *size) { 195 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 196 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 197 - # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) 198 - *addr = ThreadSelf(); 199 - *size = GetTlsSize(); 200 - @@ -470,7 +470,7 @@ static void GetTls(uptr *addr, uptr *size) { 201 - #elif SANITIZER_OPENBSD 202 - *addr = 0; 203 - *size = 0; 204 - -#elif SANITIZER_ANDROID 205 - +#elif SANITIZER_ANDROID || SANITIZER_NONGNU 206 - *addr = 0; 207 - *size = 0; 208 - #elif SANITIZER_SOLARIS 209 - @@ -486,7 +486,7 @@ static void GetTls(uptr *addr, uptr *size) { 210 - #if !SANITIZER_GO 211 - uptr GetTlsSize() { 212 - #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \ 213 - - SANITIZER_OPENBSD || SANITIZER_SOLARIS 214 - + SANITIZER_OPENBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 215 - uptr addr, size; 216 - GetTls(&addr, &size); 217 - return size; 218 - diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h 219 - index d81e25580..e10680ac8 100644 220 - --- a/lib/sanitizer_common/sanitizer_platform.h 221 - +++ b/lib/sanitizer_common/sanitizer_platform.h 222 - @@ -208,6 +208,12 @@ 223 - # define SANITIZER_SOLARIS32 0 224 - #endif 225 - 226 - +#if defined(__linux__) && !defined(__GLIBC__) 227 - +# define SANITIZER_NONGNU 1 228 - +#else 229 - +# define SANITIZER_NONGNU 0 230 - +#endif 231 - + 232 - #if defined(__myriad2__) 233 - # define SANITIZER_MYRIAD2 1 234 - #else 235 - diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h 236 - index f95539a73..6c53b3415 100644 237 - --- a/lib/sanitizer_common/sanitizer_platform_interceptors.h 238 - +++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h 239 - @@ -39,7 +39,7 @@ 240 - # include "sanitizer_platform_limits_solaris.h" 241 - #endif 242 - 243 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 244 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 245 - # define SI_LINUX_NOT_ANDROID 1 246 - #else 247 - # define SI_LINUX_NOT_ANDROID 0 248 - @@ -322,7 +322,7 @@ 249 - #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID) 250 - #define SANITIZER_INTERCEPT_SHMCTL \ 251 - (SI_NETBSD || SI_OPENBSD || SI_SOLARIS || \ 252 - - ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \ 253 - + ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \ 254 - SANITIZER_WORDSIZE == 64)) // NOLINT 255 - #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID 256 - #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX 257 - diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 258 - index 54da635d7..2f6ff69c3 100644 259 - --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 260 - +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 261 - @@ -14,6 +14,9 @@ 262 - 263 - #include "sanitizer_platform.h" 264 - 265 - +// Workaround musl <--> linux conflicting definition of 'struct sysinfo' 266 - +#define _LINUX_SYSINFO_H 267 - + 268 - #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC 269 - // Tests in this file assume that off_t-dependent data structures match the 270 - // libc ABI. For example, struct dirent here is what readdir() function (as 271 - @@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; 272 - 273 - #if SANITIZER_LINUX && !SANITIZER_ANDROID 274 - #include <glob.h> 275 - -#include <obstack.h> 276 - +# if !SANITIZER_NONGNU 277 - +# include <obstack.h> 278 - +# endif 279 - #include <mqueue.h> 280 - -#include <net/if_ppp.h> 281 - -#include <netax25/ax25.h> 282 - -#include <netipx/ipx.h> 283 - -#include <netrom/netrom.h> 284 - +#include <linux/if_ppp.h> 285 - +#include <linux/ax25.h> 286 - +#include <linux/ipx.h> 287 - +#include <linux/netrom.h> 288 - #if HAVE_RPC_XDR_H 289 - # include <rpc/xdr.h> 290 - #elif HAVE_TIRPC_RPC_XDR_H 291 - @@ -251,7 +256,7 @@ namespace __sanitizer { 292 - unsigned struct_itimerspec_sz = sizeof(struct itimerspec); 293 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 294 - 295 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 296 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 297 - // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which 298 - // has been removed from glibc 2.28. 299 - #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \ 300 - @@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); 301 - unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 302 - #endif 303 - 304 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 305 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 306 - int glob_nomatch = GLOB_NOMATCH; 307 - int glob_altdirfunc = GLOB_ALTDIRFUNC; 308 - #endif 309 - @@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 310 - unsigned struct_termios_sz = sizeof(struct termios); 311 - unsigned struct_winsize_sz = sizeof(struct winsize); 312 - 313 - -#if SANITIZER_LINUX 314 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 315 - unsigned struct_arpreq_sz = sizeof(struct arpreq); 316 - unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); 317 - unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); 318 - @@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 319 - unsigned struct_vt_mode_sz = sizeof(struct vt_mode); 320 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 321 - 322 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 323 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 324 - unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); 325 - unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); 326 - #if EV_VERSION > (0x010000) 327 - @@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 328 - unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; 329 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 330 - 331 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 332 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 333 - unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; 334 - unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; 335 - unsigned IOCTL_CYGETMON = CYGETMON; 336 - @@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); 337 - CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); 338 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 339 - 340 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 341 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 342 - CHECK_TYPE_SIZE(glob_t); 343 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); 344 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); 345 - @@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec); 346 - CHECK_SIZE_AND_OFFSET(iovec, iov_base); 347 - CHECK_SIZE_AND_OFFSET(iovec, iov_len); 348 - 349 - +#if !SANITIZER_NONGNU 350 - CHECK_TYPE_SIZE(msghdr); 351 - CHECK_SIZE_AND_OFFSET(msghdr, msg_name); 352 - CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); 353 - @@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr); 354 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); 355 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); 356 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); 357 - +#endif 358 - 359 - #ifndef __GLIBC_PREREQ 360 - #define __GLIBC_PREREQ(x, y) 0 361 - @@ -1145,7 +1152,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); 362 - 363 - CHECK_TYPE_SIZE(ether_addr); 364 - 365 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 366 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 367 - CHECK_TYPE_SIZE(ipc_perm); 368 - # if SANITIZER_FREEBSD 369 - CHECK_SIZE_AND_OFFSET(ipc_perm, key); 370 - @@ -1206,7 +1213,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); 371 - CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); 372 - #endif 373 - 374 - -#if SANITIZER_LINUX 375 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 376 - COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); 377 - #endif 378 - 379 - @@ -1256,7 +1263,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); 380 - COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); 381 - #endif 382 - 383 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 384 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 385 - COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); 386 - CHECK_SIZE_AND_OFFSET(FILE, _flags); 387 - CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); 388 - @@ -1275,7 +1282,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); 389 - CHECK_SIZE_AND_OFFSET(FILE, _fileno); 390 - #endif 391 - 392 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 393 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 394 - COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); 395 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); 396 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); 397 - diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc 398 - index de989b780..51a97b554 100644 399 - --- a/lib/tsan/rtl/tsan_platform_linux.cc 400 - +++ b/lib/tsan/rtl/tsan_platform_linux.cc 401 - @@ -294,7 +294,7 @@ void InitializePlatform() { 402 - // This is required to properly "close" the fds, because we do not see internal 403 - // closes within glibc. The code is a pure hack. 404 - int ExtractResolvFDs(void *state, int *fds, int nfd) { 405 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 406 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 407 - int cnt = 0; 408 - struct __res_state *statp = (struct __res_state*)state; 409 - for (int i = 0; i < MAXNS && cnt < nfd; i++) { 410 - -- 411 - 2.19.0 412 -
+4 -4
pkgs/development/compilers/llvm/5/compiler-rt/default.nix
··· 55 55 # https://github.com/llvm/llvm-project/commit/947f9692440836dcb8d88b74b69dd379d85974ce 56 56 ../../common/compiler-rt/glibc.patch 57 57 ./gnu-install-dirs.patch 58 - ] ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch 59 - ++ lib.optional (stdenv.hostPlatform.libc == "glibc") ./sys-ustat.patch 60 - ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch 61 - ++ [ ../../common/compiler-rt/libsanitizer-no-cyclades-9.patch ]; 58 + 59 + ./sys-ustat.patch 60 + ../../common/compiler-rt/libsanitizer-no-cyclades-9.patch 61 + ] ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 62 62 63 63 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 64 64 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
-370
pkgs/development/compilers/llvm/5/compiler-rt/sanitizers-nongnu.patch
··· 1 - From 3e1fcb7d4909db8f0f7dd0109b2eee20115c8be3 Mon Sep 17 00:00:00 2001 2 - From: "Jory A. Pratt" <anarchy@gentoo.org> 3 - Date: Sat, 9 Sep 2017 08:31:15 -0500 4 - Subject: [PATCH] Ported to compiler-rt-sanitizers-5.0.0. Taken from 5 - 6 - https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch 7 - Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> 8 - 9 - Taken from gentoo-musl project, with a few additional minor fixes. 10 - --- 11 - lib/asan/asan_linux.cc | 4 +-- 12 - lib/interception/interception_linux.cc | 2 +- 13 - lib/interception/interception_linux.h | 2 +- 14 - lib/msan/msan_linux.cc | 2 +- 15 - .../sanitizer_common_interceptors_ioctl.inc | 4 +-- 16 - lib/sanitizer_common/sanitizer_common_syscalls.inc | 2 +- 17 - lib/sanitizer_common/sanitizer_linux_libcdep.cc | 12 +++---- 18 - lib/sanitizer_common/sanitizer_platform.h | 7 ++++ 19 - .../sanitizer_platform_interceptors.h | 2 +- 20 - .../sanitizer_platform_limits_posix.cc | 40 +++++++++++++--------- 21 - lib/tsan/rtl/tsan_platform_linux.cc | 2 +- 22 - 11 files changed, 47 insertions(+), 32 deletions(-) 23 - 24 - diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc 25 - index 6d47ba432..c58dd4864 100644 26 - --- a/lib/asan/asan_linux.cc 27 - +++ b/lib/asan/asan_linux.cc 28 - @@ -39,7 +39,7 @@ 29 - #include <sys/link_elf.h> 30 - #endif 31 - 32 - -#if SANITIZER_ANDROID || SANITIZER_FREEBSD 33 - +#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_NONGNU 34 - #include <ucontext.h> 35 - extern "C" void* _DYNAMIC; 36 - #else 37 - @@ -86,7 +86,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { 38 - UNIMPLEMENTED(); 39 - } 40 - 41 - -#if SANITIZER_ANDROID 42 - +#if SANITIZER_ANDROID || SANITIZER_NONGNU 43 - // FIXME: should we do anything for Android? 44 - void AsanCheckDynamicRTPrereqs() {} 45 - void AsanCheckIncompatibleRT() {} 46 - diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc 47 - index 6e908ac01..76c1688ce 100644 48 - --- a/lib/interception/interception_linux.cc 49 - +++ b/lib/interception/interception_linux.cc 50 - @@ -24,7 +24,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, 51 - return real == wrapper; 52 - } 53 - 54 - -#if !defined(__ANDROID__) // android does not have dlvsym 55 - +#if !defined(__ANDROID__) && defined(__GLIBC__) // android does not have dlvsym 56 - void *GetFuncAddrVer(const char *func_name, const char *ver) { 57 - return dlvsym(RTLD_NEXT, func_name, ver); 58 - } 59 - diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h 60 - index 27a66c882..f60c38991 100644 61 - --- a/lib/interception/interception_linux.h 62 - +++ b/lib/interception/interception_linux.h 63 - @@ -34,7 +34,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); 64 - (::__interception::uptr) & (func), \ 65 - (::__interception::uptr) & WRAP(func)) 66 - 67 - -#if !defined(__ANDROID__) // android does not have dlvsym 68 - +#if !defined(__ANDROID__) && !SANITIZER_NONGNU // android does not have dlvsym 69 - #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ 70 - (::__interception::real_##func = (func##_f)( \ 71 - unsigned long)::__interception::GetFuncAddrVer(#func, symver)) 72 - diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc 73 - index 0a687f620..0852d97d7 100644 74 - --- a/lib/msan/msan_linux.cc 75 - +++ b/lib/msan/msan_linux.cc 76 - @@ -13,7 +13,7 @@ 77 - //===----------------------------------------------------------------------===// 78 - 79 - #include "sanitizer_common/sanitizer_platform.h" 80 - -#if SANITIZER_FREEBSD || SANITIZER_LINUX 81 - +#if SANITIZER_FREEBSD || SANITIZER_LINUX && !SANITIZER_NONGNU 82 - 83 - #include "msan.h" 84 - #include "msan_thread.h" 85 - diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 86 - index 4ed9afedf..64f584e93 100644 87 - --- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 88 - +++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 89 - @@ -100,7 +100,7 @@ static void ioctl_table_fill() { 90 - _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); 91 - #endif 92 - 93 - -#if SANITIZER_LINUX 94 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 95 - // Conflicting request ids. 96 - // _(CDROMAUDIOBUFSIZ, NONE, 0); 97 - // _(SNDCTL_TMR_CONTINUE, NONE, 0); 98 - @@ -361,7 +361,7 @@ static void ioctl_table_fill() { 99 - _(VT_WAITACTIVE, NONE, 0); 100 - #endif 101 - 102 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 103 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 104 - // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE 105 - _(CYGETDEFTHRESH, WRITE, sizeof(int)); 106 - _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); 107 - diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc 108 - index 469c8eb7e..24f87867d 100644 109 - --- a/lib/sanitizer_common/sanitizer_common_syscalls.inc 110 - +++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc 111 - @@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { 112 - } 113 - } 114 - 115 - -#if !SANITIZER_ANDROID 116 - +#if !SANITIZER_ANDROID && !SANITIZER_NONGNU 117 - PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, 118 - void *old_rlim) { 119 - if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); 120 - diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 121 - index 52196db12..045d9331f 100644 122 - --- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc 123 - +++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 124 - @@ -148,7 +148,7 @@ bool SanitizerGetThreadName(char *name, int max_len) { 125 - #endif 126 - } 127 - 128 - -#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO 129 - +#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU 130 - static uptr g_tls_size; 131 - 132 - #ifdef __i386__ 133 - @@ -176,11 +176,11 @@ void InitTlsSize() { 134 - } 135 - #else 136 - void InitTlsSize() { } 137 - -#endif // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO 138 - +#endif // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU 139 - 140 - #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \ 141 - || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) \ 142 - - || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID 143 - + || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 144 - // sizeof(struct pthread) from glibc. 145 - static atomic_uintptr_t kThreadDescriptorSize; 146 - 147 - @@ -335,7 +335,7 @@ uptr ThreadSelf() { 148 - 149 - #if !SANITIZER_GO 150 - static void GetTls(uptr *addr, uptr *size) { 151 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 152 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 153 - # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) 154 - *addr = ThreadSelf(); 155 - *size = GetTlsSize(); 156 - @@ -362,7 +362,7 @@ static void GetTls(uptr *addr, uptr *size) { 157 - *addr = (uptr) dtv[2]; 158 - *size = (*addr == 0) ? 0 : ((uptr) segbase[0] - (uptr) dtv[2]); 159 - } 160 - -#elif SANITIZER_ANDROID 161 - +#elif SANITIZER_ANDROID || SANITIZER_NONGNU 162 - *addr = 0; 163 - *size = 0; 164 - #else 165 - @@ -373,7 +373,7 @@ static void GetTls(uptr *addr, uptr *size) { 166 - 167 - #if !SANITIZER_GO 168 - uptr GetTlsSize() { 169 - -#if SANITIZER_FREEBSD || SANITIZER_ANDROID 170 - +#if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NONGNU 171 - uptr addr, size; 172 - GetTls(&addr, &size); 173 - return size; 174 - diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h 175 - index 396f7c934..5af6f1ed5 100644 176 - --- a/lib/sanitizer_common/sanitizer_platform.h 177 - +++ b/lib/sanitizer_common/sanitizer_platform.h 178 - @@ -175,6 +175,13 @@ 179 - # define SANITIZER_ARM 0 180 - #endif 181 - 182 - + 183 - +#if defined(__linux__) && !defined(__GLIBC__) 184 - +# define SANITIZER_NONGNU 1 185 - +#else 186 - +# define SANITIZER_NONGNU 0 187 - +#endif 188 - + 189 - // By default we allow to use SizeClassAllocator64 on 64-bit platform. 190 - // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64 191 - // does not work well and we need to fallback to SizeClassAllocator32. 192 - diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h 193 - index 0380cee92..0a39abbd0 100644 194 - --- a/lib/sanitizer_common/sanitizer_platform_interceptors.h 195 - +++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h 196 - @@ -31,7 +31,7 @@ 197 - # define SI_POSIX 0 198 - #endif 199 - 200 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 201 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 202 - # define SI_LINUX_NOT_ANDROID 1 203 - #else 204 - # define SI_LINUX_NOT_ANDROID 0 205 - diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 206 - index 83f4fd22f..fa8c1b8bd 100644 207 - --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 208 - +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 209 - @@ -14,6 +14,9 @@ 210 - 211 - #include "sanitizer_platform.h" 212 - 213 - +// Workaround musl <--> linux conflicting definition of 'struct sysinfo' 214 - +#define _LINUX_SYSINFO_H 215 - + 216 - #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC 217 - // Tests in this file assume that off_t-dependent data structures match the 218 - // libc ABI. For example, struct dirent here is what readdir() function (as 219 - @@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; 220 - 221 - #if SANITIZER_LINUX && !SANITIZER_ANDROID 222 - #include <glob.h> 223 - -#include <obstack.h> 224 - +# if !SANITIZER_NONGNU 225 - +# include <obstack.h> 226 - +# endif 227 - #include <mqueue.h> 228 - -#include <net/if_ppp.h> 229 - -#include <netax25/ax25.h> 230 - -#include <netipx/ipx.h> 231 - -#include <netrom/netrom.h> 232 - +#include <linux/if_ppp.h> 233 - +#include <linux/ax25.h> 234 - +#include <linux/ipx.h> 235 - +#include <linux/netrom.h> 236 - #if HAVE_RPC_XDR_H 237 - # include <rpc/xdr.h> 238 - #elif HAVE_TIRPC_RPC_XDR_H 239 - @@ -159,7 +164,8 @@ typedef struct user_fpregs elf_fpregset_t; 240 - # include <sys/procfs.h> 241 - #endif 242 - #include <sys/user.h> 243 - -#include <sys/ustat.h> 244 - +// #include <sys/ustat.h> 245 - +#include <sys/statfs.h> 246 - #include <linux/cyclades.h> 247 - #include <linux/if_eql.h> 248 - #include <linux/if_plip.h> 249 - @@ -251,7 +257,7 @@ namespace __sanitizer { 250 - unsigned struct_itimerspec_sz = sizeof(struct itimerspec); 251 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 252 - 253 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 254 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 255 - unsigned struct_ustat_sz = sizeof(struct ustat); 256 - unsigned struct_rlimit64_sz = sizeof(struct rlimit64); 257 - unsigned struct_statvfs64_sz = sizeof(struct statvfs64); 258 - @@ -309,7 +315,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); 259 - unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 260 - #endif 261 - 262 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 263 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 264 - int glob_nomatch = GLOB_NOMATCH; 265 - int glob_altdirfunc = GLOB_ALTDIRFUNC; 266 - #endif 267 - @@ -403,7 +409,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 268 - unsigned struct_termios_sz = sizeof(struct termios); 269 - unsigned struct_winsize_sz = sizeof(struct winsize); 270 - 271 - -#if SANITIZER_LINUX 272 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 273 - unsigned struct_arpreq_sz = sizeof(struct arpreq); 274 - unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); 275 - unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); 276 - @@ -453,7 +459,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 277 - unsigned struct_vt_mode_sz = sizeof(struct vt_mode); 278 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 279 - 280 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 281 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 282 - unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); 283 - unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); 284 - #if EV_VERSION > (0x010000) 285 - @@ -821,7 +827,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 286 - unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; 287 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 288 - 289 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 290 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 291 - unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; 292 - unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; 293 - unsigned IOCTL_CYGETMON = CYGETMON; 294 - @@ -976,7 +982,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); 295 - CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); 296 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 297 - 298 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 299 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 300 - CHECK_TYPE_SIZE(glob_t); 301 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); 302 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); 303 - @@ -1010,6 +1016,7 @@ CHECK_TYPE_SIZE(iovec); 304 - CHECK_SIZE_AND_OFFSET(iovec, iov_base); 305 - CHECK_SIZE_AND_OFFSET(iovec, iov_len); 306 - 307 - +#if !SANITIZER_NONGNU 308 - CHECK_TYPE_SIZE(msghdr); 309 - CHECK_SIZE_AND_OFFSET(msghdr, msg_name); 310 - CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); 311 - @@ -1023,6 +1030,7 @@ CHECK_TYPE_SIZE(cmsghdr); 312 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); 313 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); 314 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); 315 - +#endif 316 - 317 - COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent)); 318 - CHECK_SIZE_AND_OFFSET(dirent, d_ino); 319 - @@ -1125,7 +1133,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); 320 - 321 - CHECK_TYPE_SIZE(ether_addr); 322 - 323 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 324 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 325 - CHECK_TYPE_SIZE(ipc_perm); 326 - # if SANITIZER_FREEBSD 327 - CHECK_SIZE_AND_OFFSET(ipc_perm, key); 328 - @@ -1186,7 +1194,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); 329 - CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); 330 - #endif 331 - 332 - -#if SANITIZER_LINUX 333 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 334 - COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); 335 - #endif 336 - 337 - @@ -1236,7 +1244,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); 338 - COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); 339 - #endif 340 - 341 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 342 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 343 - COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); 344 - CHECK_SIZE_AND_OFFSET(FILE, _flags); 345 - CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); 346 - @@ -1255,7 +1263,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); 347 - CHECK_SIZE_AND_OFFSET(FILE, _fileno); 348 - #endif 349 - 350 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 351 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 352 - COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); 353 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); 354 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); 355 - diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc 356 - index ead1e5704..2c020e3fe 100644 357 - --- a/lib/tsan/rtl/tsan_platform_linux.cc 358 - +++ b/lib/tsan/rtl/tsan_platform_linux.cc 359 - @@ -284,7 +284,7 @@ void InitializePlatform() { 360 - // This is required to properly "close" the fds, because we do not see internal 361 - // closes within glibc. The code is a pure hack. 362 - int ExtractResolvFDs(void *state, int *fds, int nfd) { 363 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 364 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 365 - int cnt = 0; 366 - struct __res_state *statp = (struct __res_state*)state; 367 - for (int i = 0; i < MAXNS && cnt < nfd; i++) { 368 - -- 369 - 2.16.2 370 -
+1 -2
pkgs/development/compilers/llvm/6/compiler-rt/default.nix
··· 56 56 ../../common/compiler-rt/glibc.patch 57 57 ./gnu-install-dirs.patch 58 58 ../../common/compiler-rt/libsanitizer-no-cyclades-9.patch 59 - ] ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch 60 - ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 59 + ] ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 61 60 62 61 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 63 62 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
-413
pkgs/development/compilers/llvm/6/compiler-rt/sanitizers-nongnu.patch
··· 1 - From 7b4b3333a2718628b1d510ec1d8438ad67308299 Mon Sep 17 00:00:00 2001 2 - From: Will Dietz <w@wdtz.org> 3 - Date: Fri, 29 Jun 2018 09:48:59 -0500 4 - Subject: [PATCH] Ported to 6.0, taken from gentoo-musl project. 5 - 6 - ------ 7 - Ported to compiler-rt-sanitizers-5.0.0. Taken from 8 - 9 - https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch 10 - Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> 11 - 12 - Taken from gentoo-musl project, with a few additional minor fixes. 13 - --- 14 - lib/asan/asan_linux.cc | 4 +- 15 - lib/interception/interception_linux.cc | 2 +- 16 - lib/interception/interception_linux.h | 3 +- 17 - lib/msan/msan_linux.cc | 2 +- 18 - lib/sanitizer_common/sanitizer_allocator.cc | 2 +- 19 - .../sanitizer_common_interceptors_ioctl.inc | 4 +- 20 - .../sanitizer_common_syscalls.inc | 2 +- 21 - lib/sanitizer_common/sanitizer_linux.cc | 8 +++- 22 - .../sanitizer_linux_libcdep.cc | 10 ++--- 23 - lib/sanitizer_common/sanitizer_platform.h | 6 +++ 24 - .../sanitizer_platform_interceptors.h | 4 +- 25 - .../sanitizer_platform_limits_posix.cc | 37 +++++++++++-------- 26 - lib/tsan/rtl/tsan_platform_linux.cc | 2 +- 27 - 13 files changed, 51 insertions(+), 35 deletions(-) 28 - 29 - diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc 30 - index 625f32d40..73cf77aca 100644 31 - --- a/lib/asan/asan_linux.cc 32 - +++ b/lib/asan/asan_linux.cc 33 - @@ -46,7 +46,7 @@ 34 - #include <link.h> 35 - #endif 36 - 37 - -#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS 38 - +#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 39 - #include <ucontext.h> 40 - extern "C" void* _DYNAMIC; 41 - #elif SANITIZER_NETBSD 42 - @@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { 43 - UNIMPLEMENTED(); 44 - } 45 - 46 - -#if SANITIZER_ANDROID 47 - +#if SANITIZER_ANDROID || SANITIZER_NONGNU 48 - // FIXME: should we do anything for Android? 49 - void AsanCheckDynamicRTPrereqs() {} 50 - void AsanCheckIncompatibleRT() {} 51 - diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc 52 - index c991550a4..2b706418b 100644 53 - --- a/lib/interception/interception_linux.cc 54 - +++ b/lib/interception/interception_linux.cc 55 - @@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, 56 - } 57 - 58 - // Android and Solaris do not have dlvsym 59 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS 60 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_NONGNU 61 - void *GetFuncAddrVer(const char *func_name, const char *ver) { 62 - return dlvsym(RTLD_NEXT, func_name, ver); 63 - } 64 - diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h 65 - index 98fe51b85..c13302b98 100644 66 - --- a/lib/interception/interception_linux.h 67 - +++ b/lib/interception/interception_linux.h 68 - @@ -35,8 +35,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); 69 - (::__interception::uptr) & (func), \ 70 - (::__interception::uptr) & WRAP(func)) 71 - 72 - -// Android and Solaris do not have dlvsym 73 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS 74 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_NONGNU 75 - #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ 76 - (::__interception::real_##func = (func##_f)( \ 77 - unsigned long)::__interception::GetFuncAddrVer(#func, symver)) 78 - diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc 79 - index 4e6321fcb..4d50feb82 100644 80 - --- a/lib/msan/msan_linux.cc 81 - +++ b/lib/msan/msan_linux.cc 82 - @@ -13,7 +13,7 @@ 83 - //===----------------------------------------------------------------------===// 84 - 85 - #include "sanitizer_common/sanitizer_platform.h" 86 - -#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD 87 - +#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD 88 - 89 - #include "msan.h" 90 - #include "msan_thread.h" 91 - diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc 92 - index fc4f7a75a..76cf4f769 100644 93 - --- a/lib/sanitizer_common/sanitizer_allocator.cc 94 - +++ b/lib/sanitizer_common/sanitizer_allocator.cc 95 - @@ -23,7 +23,7 @@ namespace __sanitizer { 96 - 97 - // ThreadSanitizer for Go uses libc malloc/free. 98 - #if SANITIZER_GO || defined(SANITIZER_USE_MALLOC) 99 - -# if SANITIZER_LINUX && !SANITIZER_ANDROID 100 - +# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 101 - extern "C" void *__libc_malloc(uptr size); 102 - # if !SANITIZER_GO 103 - extern "C" void *__libc_memalign(uptr alignment, uptr size); 104 - diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 105 - index 24e7548a5..20259b1d6 100644 106 - --- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 107 - +++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 108 - @@ -102,7 +102,7 @@ static void ioctl_table_fill() { 109 - _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); 110 - #endif 111 - 112 - -#if SANITIZER_LINUX 113 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 114 - // Conflicting request ids. 115 - // _(CDROMAUDIOBUFSIZ, NONE, 0); 116 - // _(SNDCTL_TMR_CONTINUE, NONE, 0); 117 - @@ -363,7 +363,7 @@ static void ioctl_table_fill() { 118 - _(VT_WAITACTIVE, NONE, 0); 119 - #endif 120 - 121 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 122 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 123 - // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE 124 - _(CYGETDEFTHRESH, WRITE, sizeof(int)); 125 - _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); 126 - diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc 127 - index 469c8eb7e..24f87867d 100644 128 - --- a/lib/sanitizer_common/sanitizer_common_syscalls.inc 129 - +++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc 130 - @@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { 131 - } 132 - } 133 - 134 - -#if !SANITIZER_ANDROID 135 - +#if !SANITIZER_ANDROID && !SANITIZER_NONGNU 136 - PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, 137 - void *old_rlim) { 138 - if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); 139 - diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc 140 - index 6c83e8db4..542c4fe64 100644 141 - --- a/lib/sanitizer_common/sanitizer_linux.cc 142 - +++ b/lib/sanitizer_common/sanitizer_linux.cc 143 - @@ -522,13 +522,13 @@ const char *GetEnv(const char *name) { 144 - #endif 145 - } 146 - 147 - -#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD 148 - +#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_NONGNU 149 - extern "C" { 150 - SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end; 151 - } 152 - #endif 153 - 154 - -#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD 155 - +#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD 156 - static void ReadNullSepFileToArray(const char *path, char ***arr, 157 - int arr_size) { 158 - char *buff; 159 - @@ -569,6 +569,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) { 160 - #elif SANITIZER_NETBSD 161 - *argv = __ps_strings->ps_argvstr; 162 - *argv = __ps_strings->ps_envstr; 163 - +#elif SANITIZER_NONGNU 164 - + static const int kMaxArgv = 2000, kMaxEnvp = 2000; 165 - + ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv); 166 - + ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp); 167 - #else 168 - #if !SANITIZER_GO 169 - if (&__libc_stack_end) { 170 - diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 171 - index 56fdfc870..a932d5db1 100644 172 - --- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc 173 - +++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 174 - @@ -174,7 +174,7 @@ bool SanitizerGetThreadName(char *name, int max_len) { 175 - } 176 - 177 - #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \ 178 - - !SANITIZER_NETBSD && !SANITIZER_SOLARIS 179 - + !SANITIZER_NETBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU 180 - static uptr g_tls_size; 181 - 182 - #ifdef __i386__ 183 - @@ -207,7 +207,7 @@ void InitTlsSize() { } 184 - 185 - #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \ 186 - || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) \ 187 - - || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID 188 - + || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 189 - // sizeof(struct pthread) from glibc. 190 - static atomic_uintptr_t kThreadDescriptorSize; 191 - 192 - @@ -391,7 +391,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) { 193 - 194 - #if !SANITIZER_GO 195 - static void GetTls(uptr *addr, uptr *size) { 196 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 197 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 198 - # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) 199 - *addr = ThreadSelf(); 200 - *size = GetTlsSize(); 201 - @@ -432,7 +432,7 @@ static void GetTls(uptr *addr, uptr *size) { 202 - *addr = (uptr)tcb->tcb_dtv[1]; 203 - } 204 - } 205 - -#elif SANITIZER_ANDROID 206 - +#elif SANITIZER_ANDROID || SANITIZER_NONGNU 207 - *addr = 0; 208 - *size = 0; 209 - #elif SANITIZER_SOLARIS 210 - @@ -448,7 +448,7 @@ static void GetTls(uptr *addr, uptr *size) { 211 - #if !SANITIZER_GO 212 - uptr GetTlsSize() { 213 - #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \ 214 - - SANITIZER_SOLARIS 215 - + SANITIZER_SOLARIS || SANITIZER_NONGNU 216 - uptr addr, size; 217 - GetTls(&addr, &size); 218 - return size; 219 - diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h 220 - index 334903c26..fc2afac2c 100644 221 - --- a/lib/sanitizer_common/sanitizer_platform.h 222 - +++ b/lib/sanitizer_common/sanitizer_platform.h 223 - @@ -195,6 +195,12 @@ 224 - # define SANITIZER_SOLARIS32 0 225 - #endif 226 - 227 - +#if defined(__linux__) && !defined(__GLIBC__) 228 - +# define SANITIZER_NONGNU 1 229 - +#else 230 - +# define SANITIZER_NONGNU 0 231 - +#endif 232 - + 233 - // By default we allow to use SizeClassAllocator64 on 64-bit platform. 234 - // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64 235 - // does not work well and we need to fallback to SizeClassAllocator32. 236 - diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h 237 - index b99ac4480..628d226a1 100644 238 - --- a/lib/sanitizer_common/sanitizer_platform_interceptors.h 239 - +++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h 240 - @@ -38,7 +38,7 @@ 241 - # include "sanitizer_platform_limits_solaris.h" 242 - #endif 243 - 244 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 245 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 246 - # define SI_LINUX_NOT_ANDROID 1 247 - #else 248 - # define SI_LINUX_NOT_ANDROID 0 249 - @@ -291,7 +291,7 @@ 250 - (SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID) 251 - #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID) 252 - #define SANITIZER_INTERCEPT_SHMCTL \ 253 - - (SI_NETBSD || SI_SOLARIS || ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \ 254 - + (SI_NETBSD || SI_SOLARIS || ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \ 255 - SANITIZER_WORDSIZE == 64)) // NOLINT 256 - #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID 257 - #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX 258 - diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 259 - index feb7bad6f..4e89ab2a6 100644 260 - --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 261 - +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 262 - @@ -14,6 +14,9 @@ 263 - 264 - #include "sanitizer_platform.h" 265 - 266 - +// Workaround musl <--> linux conflicting definition of 'struct sysinfo' 267 - +#define _LINUX_SYSINFO_H 268 - + 269 - #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC 270 - // Tests in this file assume that off_t-dependent data structures match the 271 - // libc ABI. For example, struct dirent here is what readdir() function (as 272 - @@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; 273 - 274 - #if SANITIZER_LINUX && !SANITIZER_ANDROID 275 - #include <glob.h> 276 - -#include <obstack.h> 277 - +# if !SANITIZER_NONGNU 278 - +# include <obstack.h> 279 - +# endif 280 - #include <mqueue.h> 281 - -#include <net/if_ppp.h> 282 - -#include <netax25/ax25.h> 283 - -#include <netipx/ipx.h> 284 - -#include <netrom/netrom.h> 285 - +#include <linux/if_ppp.h> 286 - +#include <linux/ax25.h> 287 - +#include <linux/ipx.h> 288 - +#include <linux/netrom.h> 289 - #if HAVE_RPC_XDR_H 290 - # include <rpc/xdr.h> 291 - #elif HAVE_TIRPC_RPC_XDR_H 292 - @@ -251,7 +256,7 @@ namespace __sanitizer { 293 - unsigned struct_itimerspec_sz = sizeof(struct itimerspec); 294 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 295 - 296 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 297 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 298 - // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which 299 - // has been removed from glibc 2.28. 300 - #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \ 301 - @@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); 302 - unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 303 - #endif 304 - 305 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 306 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 307 - int glob_nomatch = GLOB_NOMATCH; 308 - int glob_altdirfunc = GLOB_ALTDIRFUNC; 309 - #endif 310 - @@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 311 - unsigned struct_termios_sz = sizeof(struct termios); 312 - unsigned struct_winsize_sz = sizeof(struct winsize); 313 - 314 - -#if SANITIZER_LINUX 315 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 316 - unsigned struct_arpreq_sz = sizeof(struct arpreq); 317 - unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); 318 - unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); 319 - @@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 320 - unsigned struct_vt_mode_sz = sizeof(struct vt_mode); 321 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 322 - 323 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 324 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 325 - unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); 326 - unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); 327 - #if EV_VERSION > (0x010000) 328 - @@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 329 - unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; 330 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 331 - 332 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 333 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 334 - unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; 335 - unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; 336 - unsigned IOCTL_CYGETMON = CYGETMON; 337 - @@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); 338 - CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); 339 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 340 - 341 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 342 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 343 - CHECK_TYPE_SIZE(glob_t); 344 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); 345 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); 346 - @@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec); 347 - CHECK_SIZE_AND_OFFSET(iovec, iov_base); 348 - CHECK_SIZE_AND_OFFSET(iovec, iov_len); 349 - 350 - +#if !SANITIZER_NONGNU 351 - CHECK_TYPE_SIZE(msghdr); 352 - CHECK_SIZE_AND_OFFSET(msghdr, msg_name); 353 - CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); 354 - @@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr); 355 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); 356 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); 357 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); 358 - +#endif 359 - 360 - COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent)); 361 - CHECK_SIZE_AND_OFFSET(dirent, d_ino); 362 - @@ -1138,7 +1145,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); 363 - 364 - CHECK_TYPE_SIZE(ether_addr); 365 - 366 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 367 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 368 - CHECK_TYPE_SIZE(ipc_perm); 369 - # if SANITIZER_FREEBSD 370 - CHECK_SIZE_AND_OFFSET(ipc_perm, key); 371 - @@ -1199,7 +1206,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); 372 - CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); 373 - #endif 374 - 375 - -#if SANITIZER_LINUX 376 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 377 - COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); 378 - #endif 379 - 380 - @@ -1249,7 +1256,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); 381 - COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); 382 - #endif 383 - 384 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 385 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 386 - COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); 387 - CHECK_SIZE_AND_OFFSET(FILE, _flags); 388 - CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); 389 - @@ -1268,7 +1275,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); 390 - CHECK_SIZE_AND_OFFSET(FILE, _fileno); 391 - #endif 392 - 393 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 394 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 395 - COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); 396 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); 397 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); 398 - diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc 399 - index e14d5f575..389a3bc88 100644 400 - --- a/lib/tsan/rtl/tsan_platform_linux.cc 401 - +++ b/lib/tsan/rtl/tsan_platform_linux.cc 402 - @@ -285,7 +285,7 @@ void InitializePlatform() { 403 - // This is required to properly "close" the fds, because we do not see internal 404 - // closes within glibc. The code is a pure hack. 405 - int ExtractResolvFDs(void *state, int *fds, int nfd) { 406 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 407 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 408 - int cnt = 0; 409 - struct __res_state *statp = (struct __res_state*)state; 410 - for (int i = 0; i < MAXNS && cnt < nfd; i++) { 411 - -- 412 - 2.18.0 413 -
-1
pkgs/development/compilers/llvm/7/compiler-rt/default.nix
··· 59 59 ./gnu-install-dirs.patch 60 60 ../../common/compiler-rt/libsanitizer-no-cyclades-9.patch 61 61 ] ++ lib.optional (useLLVM) ./crtbegin-and-end.patch 62 - ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch 63 62 ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 64 63 65 64 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
-412
pkgs/development/compilers/llvm/7/compiler-rt/sanitizers-nongnu.patch
··· 1 - From f7a253f8f85d0f49df6b73996737a3e84ac64236 Mon Sep 17 00:00:00 2001 2 - From: Will Dietz <w@wdtz.org> 3 - Date: Mon, 24 Sep 2018 11:17:25 -0500 4 - Subject: [PATCH] Ported to 7.0, taken from gentoo-musl project. 5 - 6 - ------ 7 - Ported to compiler-rt-sanitizers-5.0.0. Taken from 8 - 9 - https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch 10 - Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> 11 - 12 - Taken from gentoo-musl project, with a few additional minor fixes. 13 - --- 14 - lib/asan/asan_linux.cc | 4 +- 15 - lib/interception/interception_linux.cc | 2 +- 16 - lib/interception/interception_linux.h | 2 +- 17 - lib/msan/msan_linux.cc | 2 +- 18 - lib/sanitizer_common/sanitizer_allocator.cc | 2 +- 19 - .../sanitizer_common_interceptors_ioctl.inc | 4 +- 20 - .../sanitizer_common_syscalls.inc | 2 +- 21 - lib/sanitizer_common/sanitizer_linux.cc | 8 +++- 22 - .../sanitizer_linux_libcdep.cc | 10 ++--- 23 - lib/sanitizer_common/sanitizer_platform.h | 6 +++ 24 - .../sanitizer_platform_interceptors.h | 4 +- 25 - .../sanitizer_platform_limits_posix.cc | 37 +++++++++++-------- 26 - lib/tsan/rtl/tsan_platform_linux.cc | 2 +- 27 - 13 files changed, 51 insertions(+), 34 deletions(-) 28 - 29 - diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc 30 - index 625f32d40..73cf77aca 100644 31 - --- a/lib/asan/asan_linux.cc 32 - +++ b/lib/asan/asan_linux.cc 33 - @@ -46,7 +46,7 @@ 34 - #include <link.h> 35 - #endif 36 - 37 - -#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS 38 - +#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 39 - #include <ucontext.h> 40 - extern "C" void* _DYNAMIC; 41 - #elif SANITIZER_NETBSD 42 - @@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { 43 - UNIMPLEMENTED(); 44 - } 45 - 46 - -#if SANITIZER_ANDROID 47 - +#if SANITIZER_ANDROID || SANITIZER_NONGNU 48 - // FIXME: should we do anything for Android? 49 - void AsanCheckDynamicRTPrereqs() {} 50 - void AsanCheckIncompatibleRT() {} 51 - diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc 52 - index 26bfcd8f6..529b234f7 100644 53 - --- a/lib/interception/interception_linux.cc 54 - +++ b/lib/interception/interception_linux.cc 55 - @@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, 56 - } 57 - 58 - // Android and Solaris do not have dlvsym 59 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 60 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 61 - void *GetFuncAddrVer(const char *func_name, const char *ver) { 62 - return dlvsym(RTLD_NEXT, func_name, ver); 63 - } 64 - diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h 65 - index 942c25609..24a4d5080 100644 66 - --- a/lib/interception/interception_linux.h 67 - +++ b/lib/interception/interception_linux.h 68 - @@ -36,7 +36,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); 69 - (::__interception::uptr) & WRAP(func)) 70 - 71 - // Android, Solaris and OpenBSD do not have dlvsym 72 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 73 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 74 - #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ 75 - (::__interception::real_##func = (func##_f)( \ 76 - unsigned long)::__interception::GetFuncAddrVer(#func, symver)) 77 - diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc 78 - index 385a650c4..6e30a8ce9 100644 79 - --- a/lib/msan/msan_linux.cc 80 - +++ b/lib/msan/msan_linux.cc 81 - @@ -13,7 +13,7 @@ 82 - //===----------------------------------------------------------------------===// 83 - 84 - #include "sanitizer_common/sanitizer_platform.h" 85 - -#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD 86 - +#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD 87 - 88 - #include "msan.h" 89 - #include "msan_report.h" 90 - diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc 91 - index 6bfd5e5ee..048f6154f 100644 92 - --- a/lib/sanitizer_common/sanitizer_allocator.cc 93 - +++ b/lib/sanitizer_common/sanitizer_allocator.cc 94 - @@ -27,7 +27,7 @@ const char *SecondaryAllocatorName = "LargeMmapAllocator"; 95 - 96 - // ThreadSanitizer for Go uses libc malloc/free. 97 - #if SANITIZER_GO || defined(SANITIZER_USE_MALLOC) 98 - -# if SANITIZER_LINUX && !SANITIZER_ANDROID 99 - +# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 100 - extern "C" void *__libc_malloc(uptr size); 101 - # if !SANITIZER_GO 102 - extern "C" void *__libc_memalign(uptr alignment, uptr size); 103 - diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 104 - index 2d633c173..b6eb23116 100644 105 - --- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 106 - +++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 107 - @@ -104,7 +104,7 @@ static void ioctl_table_fill() { 108 - _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); 109 - #endif 110 - 111 - -#if SANITIZER_LINUX 112 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 113 - // Conflicting request ids. 114 - // _(CDROMAUDIOBUFSIZ, NONE, 0); 115 - // _(SNDCTL_TMR_CONTINUE, NONE, 0); 116 - @@ -365,7 +365,7 @@ static void ioctl_table_fill() { 117 - _(VT_WAITACTIVE, NONE, 0); 118 - #endif 119 - 120 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 121 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 122 - // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE 123 - _(CYGETDEFTHRESH, WRITE, sizeof(int)); 124 - _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); 125 - diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc 126 - index 469c8eb7e..24f87867d 100644 127 - --- a/lib/sanitizer_common/sanitizer_common_syscalls.inc 128 - +++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc 129 - @@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { 130 - } 131 - } 132 - 133 - -#if !SANITIZER_ANDROID 134 - +#if !SANITIZER_ANDROID && !SANITIZER_NONGNU 135 - PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, 136 - void *old_rlim) { 137 - if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); 138 - diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc 139 - index 96d6c1eff..9e2b7fb9d 100644 140 - --- a/lib/sanitizer_common/sanitizer_linux.cc 141 - +++ b/lib/sanitizer_common/sanitizer_linux.cc 142 - @@ -541,13 +541,13 @@ const char *GetEnv(const char *name) { 143 - #endif 144 - } 145 - 146 - -#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD 147 - +#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 148 - extern "C" { 149 - SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end; 150 - } 151 - #endif 152 - 153 - -#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 154 - +#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 155 - !SANITIZER_OPENBSD 156 - static void ReadNullSepFileToArray(const char *path, char ***arr, 157 - int arr_size) { 158 - @@ -590,6 +590,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) { 159 - #elif SANITIZER_NETBSD 160 - *argv = __ps_strings->ps_argvstr; 161 - *envp = __ps_strings->ps_envstr; 162 - +#elif SANITIZER_NONGNU 163 - + static const int kMaxArgv = 2000, kMaxEnvp = 2000; 164 - + ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv); 165 - + ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp); 166 - #else // SANITIZER_FREEBSD 167 - #if !SANITIZER_GO 168 - if (&__libc_stack_end) { 169 - diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 170 - index 4962ff832..438f94dbe 100644 171 - --- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc 172 - +++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 173 - @@ -179,7 +179,7 @@ __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor, 174 - } 175 - 176 - #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \ 177 - - !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS 178 - + !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU 179 - static uptr g_tls_size; 180 - 181 - #ifdef __i386__ 182 - @@ -261,7 +261,7 @@ void InitTlsSize() { } 183 - #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) || \ 184 - defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) || \ 185 - defined(__arm__)) && \ 186 - - SANITIZER_LINUX && !SANITIZER_ANDROID 187 - + SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 188 - // sizeof(struct pthread) from glibc. 189 - static atomic_uintptr_t thread_descriptor_size; 190 - 191 - @@ -426,7 +426,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) { 192 - 193 - #if !SANITIZER_GO 194 - static void GetTls(uptr *addr, uptr *size) { 195 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 196 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 197 - # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) 198 - *addr = ThreadSelf(); 199 - *size = GetTlsSize(); 200 - @@ -470,7 +470,7 @@ static void GetTls(uptr *addr, uptr *size) { 201 - #elif SANITIZER_OPENBSD 202 - *addr = 0; 203 - *size = 0; 204 - -#elif SANITIZER_ANDROID 205 - +#elif SANITIZER_ANDROID || SANITIZER_NONGNU 206 - *addr = 0; 207 - *size = 0; 208 - #elif SANITIZER_SOLARIS 209 - @@ -486,7 +486,7 @@ static void GetTls(uptr *addr, uptr *size) { 210 - #if !SANITIZER_GO 211 - uptr GetTlsSize() { 212 - #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \ 213 - - SANITIZER_OPENBSD || SANITIZER_SOLARIS 214 - + SANITIZER_OPENBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 215 - uptr addr, size; 216 - GetTls(&addr, &size); 217 - return size; 218 - diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h 219 - index d81e25580..e10680ac8 100644 220 - --- a/lib/sanitizer_common/sanitizer_platform.h 221 - +++ b/lib/sanitizer_common/sanitizer_platform.h 222 - @@ -208,6 +208,12 @@ 223 - # define SANITIZER_SOLARIS32 0 224 - #endif 225 - 226 - +#if defined(__linux__) && !defined(__GLIBC__) 227 - +# define SANITIZER_NONGNU 1 228 - +#else 229 - +# define SANITIZER_NONGNU 0 230 - +#endif 231 - + 232 - #if defined(__myriad2__) 233 - # define SANITIZER_MYRIAD2 1 234 - #else 235 - diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h 236 - index f95539a73..6c53b3415 100644 237 - --- a/lib/sanitizer_common/sanitizer_platform_interceptors.h 238 - +++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h 239 - @@ -39,7 +39,7 @@ 240 - # include "sanitizer_platform_limits_solaris.h" 241 - #endif 242 - 243 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 244 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 245 - # define SI_LINUX_NOT_ANDROID 1 246 - #else 247 - # define SI_LINUX_NOT_ANDROID 0 248 - @@ -322,7 +322,7 @@ 249 - #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID) 250 - #define SANITIZER_INTERCEPT_SHMCTL \ 251 - (SI_NETBSD || SI_OPENBSD || SI_SOLARIS || \ 252 - - ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \ 253 - + ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \ 254 - SANITIZER_WORDSIZE == 64)) // NOLINT 255 - #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID 256 - #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX 257 - diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 258 - index 54da635d7..2f6ff69c3 100644 259 - --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 260 - +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 261 - @@ -14,6 +14,9 @@ 262 - 263 - #include "sanitizer_platform.h" 264 - 265 - +// Workaround musl <--> linux conflicting definition of 'struct sysinfo' 266 - +#define _LINUX_SYSINFO_H 267 - + 268 - #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC 269 - // Tests in this file assume that off_t-dependent data structures match the 270 - // libc ABI. For example, struct dirent here is what readdir() function (as 271 - @@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; 272 - 273 - #if SANITIZER_LINUX && !SANITIZER_ANDROID 274 - #include <glob.h> 275 - -#include <obstack.h> 276 - +# if !SANITIZER_NONGNU 277 - +# include <obstack.h> 278 - +# endif 279 - #include <mqueue.h> 280 - -#include <net/if_ppp.h> 281 - -#include <netax25/ax25.h> 282 - -#include <netipx/ipx.h> 283 - -#include <netrom/netrom.h> 284 - +#include <linux/if_ppp.h> 285 - +#include <linux/ax25.h> 286 - +#include <linux/ipx.h> 287 - +#include <linux/netrom.h> 288 - #if HAVE_RPC_XDR_H 289 - # include <rpc/xdr.h> 290 - #elif HAVE_TIRPC_RPC_XDR_H 291 - @@ -251,7 +256,7 @@ namespace __sanitizer { 292 - unsigned struct_itimerspec_sz = sizeof(struct itimerspec); 293 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 294 - 295 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 296 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 297 - // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which 298 - // has been removed from glibc 2.28. 299 - #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \ 300 - @@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); 301 - unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 302 - #endif 303 - 304 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 305 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 306 - int glob_nomatch = GLOB_NOMATCH; 307 - int glob_altdirfunc = GLOB_ALTDIRFUNC; 308 - #endif 309 - @@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 310 - unsigned struct_termios_sz = sizeof(struct termios); 311 - unsigned struct_winsize_sz = sizeof(struct winsize); 312 - 313 - -#if SANITIZER_LINUX 314 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 315 - unsigned struct_arpreq_sz = sizeof(struct arpreq); 316 - unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); 317 - unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); 318 - @@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 319 - unsigned struct_vt_mode_sz = sizeof(struct vt_mode); 320 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 321 - 322 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 323 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 324 - unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); 325 - unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); 326 - #if EV_VERSION > (0x010000) 327 - @@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 328 - unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; 329 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 330 - 331 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 332 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 333 - unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; 334 - unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; 335 - unsigned IOCTL_CYGETMON = CYGETMON; 336 - @@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); 337 - CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); 338 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 339 - 340 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 341 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 342 - CHECK_TYPE_SIZE(glob_t); 343 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); 344 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); 345 - @@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec); 346 - CHECK_SIZE_AND_OFFSET(iovec, iov_base); 347 - CHECK_SIZE_AND_OFFSET(iovec, iov_len); 348 - 349 - +#if !SANITIZER_NONGNU 350 - CHECK_TYPE_SIZE(msghdr); 351 - CHECK_SIZE_AND_OFFSET(msghdr, msg_name); 352 - CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); 353 - @@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr); 354 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); 355 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); 356 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); 357 - +#endif 358 - 359 - #ifndef __GLIBC_PREREQ 360 - #define __GLIBC_PREREQ(x, y) 0 361 - @@ -1145,7 +1152,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); 362 - 363 - CHECK_TYPE_SIZE(ether_addr); 364 - 365 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 366 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 367 - CHECK_TYPE_SIZE(ipc_perm); 368 - # if SANITIZER_FREEBSD 369 - CHECK_SIZE_AND_OFFSET(ipc_perm, key); 370 - @@ -1206,7 +1213,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); 371 - CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); 372 - #endif 373 - 374 - -#if SANITIZER_LINUX 375 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 376 - COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); 377 - #endif 378 - 379 - @@ -1256,7 +1263,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); 380 - COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); 381 - #endif 382 - 383 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 384 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 385 - COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); 386 - CHECK_SIZE_AND_OFFSET(FILE, _flags); 387 - CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); 388 - @@ -1275,7 +1282,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); 389 - CHECK_SIZE_AND_OFFSET(FILE, _fileno); 390 - #endif 391 - 392 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 393 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 394 - COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); 395 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); 396 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); 397 - diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc 398 - index de989b780..51a97b554 100644 399 - --- a/lib/tsan/rtl/tsan_platform_linux.cc 400 - +++ b/lib/tsan/rtl/tsan_platform_linux.cc 401 - @@ -294,7 +294,7 @@ void InitializePlatform() { 402 - // This is required to properly "close" the fds, because we do not see internal 403 - // closes within glibc. The code is a pure hack. 404 - int ExtractResolvFDs(void *state, int *fds, int nfd) { 405 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 406 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 407 - int cnt = 0; 408 - struct __res_state *statp = (struct __res_state*)state; 409 - for (int i = 0; i < MAXNS && cnt < nfd; i++) { 410 - -- 411 - 2.19.0 412 -
+1 -2
pkgs/development/compilers/llvm/8/compiler-rt/default.nix
··· 58 58 ./codesign.patch # Revert compiler-rt commit that makes codesign mandatory 59 59 ./gnu-install-dirs.patch 60 60 ../../common/compiler-rt/libsanitizer-no-cyclades-9.patch 61 - ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch 62 - ++ lib.optional (useLLVM) ./crtbegin-and-end.patch 61 + ] ++ lib.optional (useLLVM) ./crtbegin-and-end.patch 63 62 ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 64 63 65 64 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
-412
pkgs/development/compilers/llvm/8/compiler-rt/sanitizers-nongnu.patch
··· 1 - From f7a253f8f85d0f49df6b73996737a3e84ac64236 Mon Sep 17 00:00:00 2001 2 - From: Will Dietz <w@wdtz.org> 3 - Date: Mon, 24 Sep 2018 11:17:25 -0500 4 - Subject: [PATCH] Ported to 7.0, taken from gentoo-musl project. 5 - 6 - ------ 7 - Ported to compiler-rt-sanitizers-5.0.0. Taken from 8 - 9 - https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch 10 - Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> 11 - 12 - Taken from gentoo-musl project, with a few additional minor fixes. 13 - --- 14 - lib/asan/asan_linux.cc | 4 +- 15 - lib/interception/interception_linux.cc | 2 +- 16 - lib/interception/interception_linux.h | 2 +- 17 - lib/msan/msan_linux.cc | 2 +- 18 - lib/sanitizer_common/sanitizer_allocator.cc | 2 +- 19 - .../sanitizer_common_interceptors_ioctl.inc | 4 +- 20 - .../sanitizer_common_syscalls.inc | 2 +- 21 - lib/sanitizer_common/sanitizer_linux.cc | 8 +++- 22 - .../sanitizer_linux_libcdep.cc | 10 ++--- 23 - lib/sanitizer_common/sanitizer_platform.h | 6 +++ 24 - .../sanitizer_platform_interceptors.h | 4 +- 25 - .../sanitizer_platform_limits_posix.cc | 37 +++++++++++-------- 26 - lib/tsan/rtl/tsan_platform_linux.cc | 2 +- 27 - 13 files changed, 51 insertions(+), 34 deletions(-) 28 - 29 - diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc 30 - index 625f32d40..73cf77aca 100644 31 - --- a/lib/asan/asan_linux.cc 32 - +++ b/lib/asan/asan_linux.cc 33 - @@ -46,7 +46,7 @@ 34 - #include <link.h> 35 - #endif 36 - 37 - -#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS 38 - +#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 39 - #include <ucontext.h> 40 - extern "C" void* _DYNAMIC; 41 - #elif SANITIZER_NETBSD 42 - @@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { 43 - UNIMPLEMENTED(); 44 - } 45 - 46 - -#if SANITIZER_ANDROID 47 - +#if SANITIZER_ANDROID || SANITIZER_NONGNU 48 - // FIXME: should we do anything for Android? 49 - void AsanCheckDynamicRTPrereqs() {} 50 - void AsanCheckIncompatibleRT() {} 51 - diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc 52 - index 26bfcd8f6..529b234f7 100644 53 - --- a/lib/interception/interception_linux.cc 54 - +++ b/lib/interception/interception_linux.cc 55 - @@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, 56 - } 57 - 58 - // Android and Solaris do not have dlvsym 59 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 60 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 61 - void *GetFuncAddrVer(const char *func_name, const char *ver) { 62 - return dlvsym(RTLD_NEXT, func_name, ver); 63 - } 64 - diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h 65 - index 942c25609..24a4d5080 100644 66 - --- a/lib/interception/interception_linux.h 67 - +++ b/lib/interception/interception_linux.h 68 - @@ -36,7 +36,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); 69 - (::__interception::uptr) & WRAP(func)) 70 - 71 - // Android, Solaris and OpenBSD do not have dlvsym 72 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 73 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 74 - #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ 75 - (::__interception::real_##func = (func##_f)( \ 76 - unsigned long)::__interception::GetFuncAddrVer(#func, symver)) 77 - diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc 78 - index 385a650c4..6e30a8ce9 100644 79 - --- a/lib/msan/msan_linux.cc 80 - +++ b/lib/msan/msan_linux.cc 81 - @@ -13,7 +13,7 @@ 82 - //===----------------------------------------------------------------------===// 83 - 84 - #include "sanitizer_common/sanitizer_platform.h" 85 - -#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD 86 - +#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD 87 - 88 - #include "msan.h" 89 - #include "msan_report.h" 90 - diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc 91 - index 6bfd5e5ee..048f6154f 100644 92 - --- a/lib/sanitizer_common/sanitizer_allocator.cc 93 - +++ b/lib/sanitizer_common/sanitizer_allocator.cc 94 - @@ -27,7 +27,7 @@ const char *SecondaryAllocatorName = "LargeMmapAllocator"; 95 - 96 - // ThreadSanitizer for Go uses libc malloc/free. 97 - #if SANITIZER_GO || defined(SANITIZER_USE_MALLOC) 98 - -# if SANITIZER_LINUX && !SANITIZER_ANDROID 99 - +# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 100 - extern "C" void *__libc_malloc(uptr size); 101 - # if !SANITIZER_GO 102 - extern "C" void *__libc_memalign(uptr alignment, uptr size); 103 - diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 104 - index 2d633c173..b6eb23116 100644 105 - --- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 106 - +++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 107 - @@ -104,7 +104,7 @@ static void ioctl_table_fill() { 108 - _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); 109 - #endif 110 - 111 - -#if SANITIZER_LINUX 112 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 113 - // Conflicting request ids. 114 - // _(CDROMAUDIOBUFSIZ, NONE, 0); 115 - // _(SNDCTL_TMR_CONTINUE, NONE, 0); 116 - @@ -365,7 +365,7 @@ static void ioctl_table_fill() { 117 - _(VT_WAITACTIVE, NONE, 0); 118 - #endif 119 - 120 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 121 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 122 - // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE 123 - _(CYGETDEFTHRESH, WRITE, sizeof(int)); 124 - _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); 125 - diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc 126 - index 469c8eb7e..24f87867d 100644 127 - --- a/lib/sanitizer_common/sanitizer_common_syscalls.inc 128 - +++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc 129 - @@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { 130 - } 131 - } 132 - 133 - -#if !SANITIZER_ANDROID 134 - +#if !SANITIZER_ANDROID && !SANITIZER_NONGNU 135 - PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, 136 - void *old_rlim) { 137 - if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); 138 - diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc 139 - index 96d6c1eff..9e2b7fb9d 100644 140 - --- a/lib/sanitizer_common/sanitizer_linux.cc 141 - +++ b/lib/sanitizer_common/sanitizer_linux.cc 142 - @@ -541,13 +541,13 @@ const char *GetEnv(const char *name) { 143 - #endif 144 - } 145 - 146 - -#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD 147 - +#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 148 - extern "C" { 149 - SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end; 150 - } 151 - #endif 152 - 153 - -#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 154 - +#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 155 - !SANITIZER_OPENBSD 156 - static void ReadNullSepFileToArray(const char *path, char ***arr, 157 - int arr_size) { 158 - @@ -590,6 +590,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) { 159 - #elif SANITIZER_NETBSD 160 - *argv = __ps_strings->ps_argvstr; 161 - *envp = __ps_strings->ps_envstr; 162 - +#elif SANITIZER_NONGNU 163 - + static const int kMaxArgv = 2000, kMaxEnvp = 2000; 164 - + ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv); 165 - + ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp); 166 - #else // SANITIZER_FREEBSD 167 - #if !SANITIZER_GO 168 - if (&__libc_stack_end) { 169 - diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 170 - index 4962ff832..438f94dbe 100644 171 - --- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc 172 - +++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 173 - @@ -179,7 +179,7 @@ __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor, 174 - } 175 - 176 - #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \ 177 - - !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS 178 - + !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU 179 - static uptr g_tls_size; 180 - 181 - #ifdef __i386__ 182 - @@ -261,7 +261,7 @@ void InitTlsSize() { } 183 - #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) || \ 184 - defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) || \ 185 - defined(__arm__)) && \ 186 - - SANITIZER_LINUX && !SANITIZER_ANDROID 187 - + SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 188 - // sizeof(struct pthread) from glibc. 189 - static atomic_uintptr_t thread_descriptor_size; 190 - 191 - @@ -426,7 +426,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) { 192 - 193 - #if !SANITIZER_GO 194 - static void GetTls(uptr *addr, uptr *size) { 195 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 196 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 197 - # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) 198 - *addr = ThreadSelf(); 199 - *size = GetTlsSize(); 200 - @@ -470,7 +470,7 @@ static void GetTls(uptr *addr, uptr *size) { 201 - #elif SANITIZER_OPENBSD 202 - *addr = 0; 203 - *size = 0; 204 - -#elif SANITIZER_ANDROID 205 - +#elif SANITIZER_ANDROID || SANITIZER_NONGNU 206 - *addr = 0; 207 - *size = 0; 208 - #elif SANITIZER_SOLARIS 209 - @@ -486,7 +486,7 @@ static void GetTls(uptr *addr, uptr *size) { 210 - #if !SANITIZER_GO 211 - uptr GetTlsSize() { 212 - #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \ 213 - - SANITIZER_OPENBSD || SANITIZER_SOLARIS 214 - + SANITIZER_OPENBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 215 - uptr addr, size; 216 - GetTls(&addr, &size); 217 - return size; 218 - diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h 219 - index d81e25580..e10680ac8 100644 220 - --- a/lib/sanitizer_common/sanitizer_platform.h 221 - +++ b/lib/sanitizer_common/sanitizer_platform.h 222 - @@ -208,6 +208,12 @@ 223 - # define SANITIZER_SOLARIS32 0 224 - #endif 225 - 226 - +#if defined(__linux__) && !defined(__GLIBC__) 227 - +# define SANITIZER_NONGNU 1 228 - +#else 229 - +# define SANITIZER_NONGNU 0 230 - +#endif 231 - + 232 - #if defined(__myriad2__) 233 - # define SANITIZER_MYRIAD2 1 234 - #else 235 - diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h 236 - index f95539a73..6c53b3415 100644 237 - --- a/lib/sanitizer_common/sanitizer_platform_interceptors.h 238 - +++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h 239 - @@ -39,7 +39,7 @@ 240 - # include "sanitizer_platform_limits_solaris.h" 241 - #endif 242 - 243 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 244 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 245 - # define SI_LINUX_NOT_ANDROID 1 246 - #else 247 - # define SI_LINUX_NOT_ANDROID 0 248 - @@ -322,7 +322,7 @@ 249 - #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID) 250 - #define SANITIZER_INTERCEPT_SHMCTL \ 251 - (SI_NETBSD || SI_OPENBSD || SI_SOLARIS || \ 252 - - ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \ 253 - + ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \ 254 - SANITIZER_WORDSIZE == 64)) // NOLINT 255 - #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID 256 - #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX 257 - diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 258 - index 54da635d7..2f6ff69c3 100644 259 - --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 260 - +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 261 - @@ -14,6 +14,9 @@ 262 - 263 - #include "sanitizer_platform.h" 264 - 265 - +// Workaround musl <--> linux conflicting definition of 'struct sysinfo' 266 - +#define _LINUX_SYSINFO_H 267 - + 268 - #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC 269 - // Tests in this file assume that off_t-dependent data structures match the 270 - // libc ABI. For example, struct dirent here is what readdir() function (as 271 - @@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; 272 - 273 - #if SANITIZER_LINUX && !SANITIZER_ANDROID 274 - #include <glob.h> 275 - -#include <obstack.h> 276 - +# if !SANITIZER_NONGNU 277 - +# include <obstack.h> 278 - +# endif 279 - #include <mqueue.h> 280 - -#include <net/if_ppp.h> 281 - -#include <netax25/ax25.h> 282 - -#include <netipx/ipx.h> 283 - -#include <netrom/netrom.h> 284 - +#include <linux/if_ppp.h> 285 - +#include <linux/ax25.h> 286 - +#include <linux/ipx.h> 287 - +#include <linux/netrom.h> 288 - #if HAVE_RPC_XDR_H 289 - # include <rpc/xdr.h> 290 - #elif HAVE_TIRPC_RPC_XDR_H 291 - @@ -251,7 +256,7 @@ namespace __sanitizer { 292 - unsigned struct_itimerspec_sz = sizeof(struct itimerspec); 293 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 294 - 295 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 296 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 297 - // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which 298 - // has been removed from glibc 2.28. 299 - #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \ 300 - @@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); 301 - unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 302 - #endif 303 - 304 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 305 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 306 - int glob_nomatch = GLOB_NOMATCH; 307 - int glob_altdirfunc = GLOB_ALTDIRFUNC; 308 - #endif 309 - @@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 310 - unsigned struct_termios_sz = sizeof(struct termios); 311 - unsigned struct_winsize_sz = sizeof(struct winsize); 312 - 313 - -#if SANITIZER_LINUX 314 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 315 - unsigned struct_arpreq_sz = sizeof(struct arpreq); 316 - unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); 317 - unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); 318 - @@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 319 - unsigned struct_vt_mode_sz = sizeof(struct vt_mode); 320 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 321 - 322 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 323 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 324 - unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); 325 - unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); 326 - #if EV_VERSION > (0x010000) 327 - @@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 328 - unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; 329 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 330 - 331 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 332 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 333 - unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; 334 - unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; 335 - unsigned IOCTL_CYGETMON = CYGETMON; 336 - @@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); 337 - CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); 338 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 339 - 340 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 341 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 342 - CHECK_TYPE_SIZE(glob_t); 343 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); 344 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); 345 - @@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec); 346 - CHECK_SIZE_AND_OFFSET(iovec, iov_base); 347 - CHECK_SIZE_AND_OFFSET(iovec, iov_len); 348 - 349 - +#if !SANITIZER_NONGNU 350 - CHECK_TYPE_SIZE(msghdr); 351 - CHECK_SIZE_AND_OFFSET(msghdr, msg_name); 352 - CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); 353 - @@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr); 354 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); 355 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); 356 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); 357 - +#endif 358 - 359 - #ifndef __GLIBC_PREREQ 360 - #define __GLIBC_PREREQ(x, y) 0 361 - @@ -1145,7 +1152,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); 362 - 363 - CHECK_TYPE_SIZE(ether_addr); 364 - 365 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 366 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 367 - CHECK_TYPE_SIZE(ipc_perm); 368 - # if SANITIZER_FREEBSD 369 - CHECK_SIZE_AND_OFFSET(ipc_perm, key); 370 - @@ -1206,7 +1213,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); 371 - CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); 372 - #endif 373 - 374 - -#if SANITIZER_LINUX 375 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 376 - COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); 377 - #endif 378 - 379 - @@ -1256,7 +1263,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); 380 - COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); 381 - #endif 382 - 383 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 384 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 385 - COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); 386 - CHECK_SIZE_AND_OFFSET(FILE, _flags); 387 - CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); 388 - @@ -1275,7 +1282,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); 389 - CHECK_SIZE_AND_OFFSET(FILE, _fileno); 390 - #endif 391 - 392 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 393 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 394 - COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); 395 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); 396 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); 397 - diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc 398 - index de989b780..51a97b554 100644 399 - --- a/lib/tsan/rtl/tsan_platform_linux.cc 400 - +++ b/lib/tsan/rtl/tsan_platform_linux.cc 401 - @@ -294,7 +294,7 @@ void InitializePlatform() { 402 - // This is required to properly "close" the fds, because we do not see internal 403 - // closes within glibc. The code is a pure hack. 404 - int ExtractResolvFDs(void *state, int *fds, int nfd) { 405 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 406 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 407 - int cnt = 0; 408 - struct __res_state *statp = (struct __res_state*)state; 409 - for (int i = 0; i < MAXNS && cnt < nfd; i++) { 410 - -- 411 - 2.19.0 412 -
+1 -2
pkgs/development/compilers/llvm/9/compiler-rt/default.nix
··· 58 58 ./codesign.patch # Revert compiler-rt commit that makes codesign mandatory 59 59 ./gnu-install-dirs.patch 60 60 ../../common/compiler-rt/libsanitizer-no-cyclades-9.patch 61 - ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch 62 - ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 61 + ] ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 63 62 64 63 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 65 64 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
-412
pkgs/development/compilers/llvm/9/compiler-rt/sanitizers-nongnu.patch
··· 1 - From f7a253f8f85d0f49df6b73996737a3e84ac64236 Mon Sep 17 00:00:00 2001 2 - From: Will Dietz <w@wdtz.org> 3 - Date: Mon, 24 Sep 2018 11:17:25 -0500 4 - Subject: [PATCH] Ported to 7.0, taken from gentoo-musl project. 5 - 6 - ------ 7 - Ported to compiler-rt-sanitizers-5.0.0. Taken from 8 - 9 - https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch 10 - Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> 11 - 12 - Taken from gentoo-musl project, with a few additional minor fixes. 13 - --- 14 - lib/asan/asan_linux.cc | 4 +- 15 - lib/interception/interception_linux.cc | 2 +- 16 - lib/interception/interception_linux.h | 2 +- 17 - lib/msan/msan_linux.cc | 2 +- 18 - lib/sanitizer_common/sanitizer_allocator.cc | 2 +- 19 - .../sanitizer_common_interceptors_ioctl.inc | 4 +- 20 - .../sanitizer_common_syscalls.inc | 2 +- 21 - lib/sanitizer_common/sanitizer_linux.cc | 8 +++- 22 - .../sanitizer_linux_libcdep.cc | 10 ++--- 23 - lib/sanitizer_common/sanitizer_platform.h | 6 +++ 24 - .../sanitizer_platform_interceptors.h | 4 +- 25 - .../sanitizer_platform_limits_posix.cc | 37 +++++++++++-------- 26 - lib/tsan/rtl/tsan_platform_linux.cc | 2 +- 27 - 13 files changed, 51 insertions(+), 34 deletions(-) 28 - 29 - diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc 30 - index 625f32d40..73cf77aca 100644 31 - --- a/lib/asan/asan_linux.cc 32 - +++ b/lib/asan/asan_linux.cc 33 - @@ -46,7 +46,7 @@ 34 - #include <link.h> 35 - #endif 36 - 37 - -#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS 38 - +#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 39 - #include <ucontext.h> 40 - extern "C" void* _DYNAMIC; 41 - #elif SANITIZER_NETBSD 42 - @@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { 43 - UNIMPLEMENTED(); 44 - } 45 - 46 - -#if SANITIZER_ANDROID 47 - +#if SANITIZER_ANDROID || SANITIZER_NONGNU 48 - // FIXME: should we do anything for Android? 49 - void AsanCheckDynamicRTPrereqs() {} 50 - void AsanCheckIncompatibleRT() {} 51 - diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc 52 - index 26bfcd8f6..529b234f7 100644 53 - --- a/lib/interception/interception_linux.cc 54 - +++ b/lib/interception/interception_linux.cc 55 - @@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, 56 - } 57 - 58 - // Android and Solaris do not have dlvsym 59 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 60 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 61 - void *GetFuncAddrVer(const char *func_name, const char *ver) { 62 - return dlvsym(RTLD_NEXT, func_name, ver); 63 - } 64 - diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h 65 - index 942c25609..24a4d5080 100644 66 - --- a/lib/interception/interception_linux.h 67 - +++ b/lib/interception/interception_linux.h 68 - @@ -36,7 +36,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); 69 - (::__interception::uptr) & WRAP(func)) 70 - 71 - // Android, Solaris and OpenBSD do not have dlvsym 72 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 73 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 74 - #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ 75 - (::__interception::real_##func = (func##_f)( \ 76 - unsigned long)::__interception::GetFuncAddrVer(#func, symver)) 77 - diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc 78 - index 385a650c4..6e30a8ce9 100644 79 - --- a/lib/msan/msan_linux.cc 80 - +++ b/lib/msan/msan_linux.cc 81 - @@ -13,7 +13,7 @@ 82 - //===----------------------------------------------------------------------===// 83 - 84 - #include "sanitizer_common/sanitizer_platform.h" 85 - -#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD 86 - +#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD 87 - 88 - #include "msan.h" 89 - #include "msan_report.h" 90 - diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc 91 - index 6bfd5e5ee..048f6154f 100644 92 - --- a/lib/sanitizer_common/sanitizer_allocator.cc 93 - +++ b/lib/sanitizer_common/sanitizer_allocator.cc 94 - @@ -27,7 +27,7 @@ const char *SecondaryAllocatorName = "LargeMmapAllocator"; 95 - 96 - // ThreadSanitizer for Go uses libc malloc/free. 97 - #if SANITIZER_GO || defined(SANITIZER_USE_MALLOC) 98 - -# if SANITIZER_LINUX && !SANITIZER_ANDROID 99 - +# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 100 - extern "C" void *__libc_malloc(uptr size); 101 - # if !SANITIZER_GO 102 - extern "C" void *__libc_memalign(uptr alignment, uptr size); 103 - diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 104 - index 2d633c173..b6eb23116 100644 105 - --- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 106 - +++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 107 - @@ -104,7 +104,7 @@ static void ioctl_table_fill() { 108 - _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); 109 - #endif 110 - 111 - -#if SANITIZER_LINUX 112 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 113 - // Conflicting request ids. 114 - // _(CDROMAUDIOBUFSIZ, NONE, 0); 115 - // _(SNDCTL_TMR_CONTINUE, NONE, 0); 116 - @@ -365,7 +365,7 @@ static void ioctl_table_fill() { 117 - _(VT_WAITACTIVE, NONE, 0); 118 - #endif 119 - 120 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 121 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 122 - // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE 123 - _(CYGETDEFTHRESH, WRITE, sizeof(int)); 124 - _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); 125 - diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc 126 - index 469c8eb7e..24f87867d 100644 127 - --- a/lib/sanitizer_common/sanitizer_common_syscalls.inc 128 - +++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc 129 - @@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { 130 - } 131 - } 132 - 133 - -#if !SANITIZER_ANDROID 134 - +#if !SANITIZER_ANDROID && !SANITIZER_NONGNU 135 - PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, 136 - void *old_rlim) { 137 - if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); 138 - diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc 139 - index 96d6c1eff..9e2b7fb9d 100644 140 - --- a/lib/sanitizer_common/sanitizer_linux.cc 141 - +++ b/lib/sanitizer_common/sanitizer_linux.cc 142 - @@ -541,13 +541,13 @@ const char *GetEnv(const char *name) { 143 - #endif 144 - } 145 - 146 - -#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD 147 - +#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 148 - extern "C" { 149 - SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end; 150 - } 151 - #endif 152 - 153 - -#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 154 - +#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 155 - !SANITIZER_OPENBSD 156 - static void ReadNullSepFileToArray(const char *path, char ***arr, 157 - int arr_size) { 158 - @@ -590,6 +590,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) { 159 - #elif SANITIZER_NETBSD 160 - *argv = __ps_strings->ps_argvstr; 161 - *envp = __ps_strings->ps_envstr; 162 - +#elif SANITIZER_NONGNU 163 - + static const int kMaxArgv = 2000, kMaxEnvp = 2000; 164 - + ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv); 165 - + ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp); 166 - #else // SANITIZER_FREEBSD 167 - #if !SANITIZER_GO 168 - if (&__libc_stack_end) { 169 - diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 170 - index 4962ff832..438f94dbe 100644 171 - --- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc 172 - +++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 173 - @@ -179,7 +179,7 @@ __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor, 174 - } 175 - 176 - #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \ 177 - - !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS 178 - + !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU 179 - static uptr g_tls_size; 180 - 181 - #ifdef __i386__ 182 - @@ -261,7 +261,7 @@ void InitTlsSize() { } 183 - #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) || \ 184 - defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) || \ 185 - defined(__arm__)) && \ 186 - - SANITIZER_LINUX && !SANITIZER_ANDROID 187 - + SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 188 - // sizeof(struct pthread) from glibc. 189 - static atomic_uintptr_t thread_descriptor_size; 190 - 191 - @@ -426,7 +426,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) { 192 - 193 - #if !SANITIZER_GO 194 - static void GetTls(uptr *addr, uptr *size) { 195 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 196 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 197 - # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) 198 - *addr = ThreadSelf(); 199 - *size = GetTlsSize(); 200 - @@ -470,7 +470,7 @@ static void GetTls(uptr *addr, uptr *size) { 201 - #elif SANITIZER_OPENBSD 202 - *addr = 0; 203 - *size = 0; 204 - -#elif SANITIZER_ANDROID 205 - +#elif SANITIZER_ANDROID || SANITIZER_NONGNU 206 - *addr = 0; 207 - *size = 0; 208 - #elif SANITIZER_SOLARIS 209 - @@ -486,7 +486,7 @@ static void GetTls(uptr *addr, uptr *size) { 210 - #if !SANITIZER_GO 211 - uptr GetTlsSize() { 212 - #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \ 213 - - SANITIZER_OPENBSD || SANITIZER_SOLARIS 214 - + SANITIZER_OPENBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 215 - uptr addr, size; 216 - GetTls(&addr, &size); 217 - return size; 218 - diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h 219 - index d81e25580..e10680ac8 100644 220 - --- a/lib/sanitizer_common/sanitizer_platform.h 221 - +++ b/lib/sanitizer_common/sanitizer_platform.h 222 - @@ -208,6 +208,12 @@ 223 - # define SANITIZER_SOLARIS32 0 224 - #endif 225 - 226 - +#if defined(__linux__) && !defined(__GLIBC__) 227 - +# define SANITIZER_NONGNU 1 228 - +#else 229 - +# define SANITIZER_NONGNU 0 230 - +#endif 231 - + 232 - #if defined(__myriad2__) 233 - # define SANITIZER_MYRIAD2 1 234 - #else 235 - diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h 236 - index f95539a73..6c53b3415 100644 237 - --- a/lib/sanitizer_common/sanitizer_platform_interceptors.h 238 - +++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h 239 - @@ -39,7 +39,7 @@ 240 - # include "sanitizer_platform_limits_solaris.h" 241 - #endif 242 - 243 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 244 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 245 - # define SI_LINUX_NOT_ANDROID 1 246 - #else 247 - # define SI_LINUX_NOT_ANDROID 0 248 - @@ -322,7 +322,7 @@ 249 - #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID) 250 - #define SANITIZER_INTERCEPT_SHMCTL \ 251 - (SI_NETBSD || SI_OPENBSD || SI_SOLARIS || \ 252 - - ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \ 253 - + ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \ 254 - SANITIZER_WORDSIZE == 64)) // NOLINT 255 - #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID 256 - #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX 257 - diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 258 - index 54da635d7..2f6ff69c3 100644 259 - --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 260 - +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 261 - @@ -14,6 +14,9 @@ 262 - 263 - #include "sanitizer_platform.h" 264 - 265 - +// Workaround musl <--> linux conflicting definition of 'struct sysinfo' 266 - +#define _LINUX_SYSINFO_H 267 - + 268 - #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC 269 - // Tests in this file assume that off_t-dependent data structures match the 270 - // libc ABI. For example, struct dirent here is what readdir() function (as 271 - @@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; 272 - 273 - #if SANITIZER_LINUX && !SANITIZER_ANDROID 274 - #include <glob.h> 275 - -#include <obstack.h> 276 - +# if !SANITIZER_NONGNU 277 - +# include <obstack.h> 278 - +# endif 279 - #include <mqueue.h> 280 - -#include <net/if_ppp.h> 281 - -#include <netax25/ax25.h> 282 - -#include <netipx/ipx.h> 283 - -#include <netrom/netrom.h> 284 - +#include <linux/if_ppp.h> 285 - +#include <linux/ax25.h> 286 - +#include <linux/ipx.h> 287 - +#include <linux/netrom.h> 288 - #if HAVE_RPC_XDR_H 289 - # include <rpc/xdr.h> 290 - #elif HAVE_TIRPC_RPC_XDR_H 291 - @@ -251,7 +256,7 @@ namespace __sanitizer { 292 - unsigned struct_itimerspec_sz = sizeof(struct itimerspec); 293 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 294 - 295 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 296 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 297 - // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which 298 - // has been removed from glibc 2.28. 299 - #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \ 300 - @@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); 301 - unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 302 - #endif 303 - 304 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 305 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 306 - int glob_nomatch = GLOB_NOMATCH; 307 - int glob_altdirfunc = GLOB_ALTDIRFUNC; 308 - #endif 309 - @@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 310 - unsigned struct_termios_sz = sizeof(struct termios); 311 - unsigned struct_winsize_sz = sizeof(struct winsize); 312 - 313 - -#if SANITIZER_LINUX 314 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 315 - unsigned struct_arpreq_sz = sizeof(struct arpreq); 316 - unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); 317 - unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); 318 - @@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 319 - unsigned struct_vt_mode_sz = sizeof(struct vt_mode); 320 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 321 - 322 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 323 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 324 - unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); 325 - unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); 326 - #if EV_VERSION > (0x010000) 327 - @@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 328 - unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; 329 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 330 - 331 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 332 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 333 - unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; 334 - unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; 335 - unsigned IOCTL_CYGETMON = CYGETMON; 336 - @@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); 337 - CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); 338 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 339 - 340 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 341 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 342 - CHECK_TYPE_SIZE(glob_t); 343 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); 344 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); 345 - @@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec); 346 - CHECK_SIZE_AND_OFFSET(iovec, iov_base); 347 - CHECK_SIZE_AND_OFFSET(iovec, iov_len); 348 - 349 - +#if !SANITIZER_NONGNU 350 - CHECK_TYPE_SIZE(msghdr); 351 - CHECK_SIZE_AND_OFFSET(msghdr, msg_name); 352 - CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); 353 - @@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr); 354 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); 355 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); 356 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); 357 - +#endif 358 - 359 - #ifndef __GLIBC_PREREQ 360 - #define __GLIBC_PREREQ(x, y) 0 361 - @@ -1145,7 +1152,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); 362 - 363 - CHECK_TYPE_SIZE(ether_addr); 364 - 365 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 366 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 367 - CHECK_TYPE_SIZE(ipc_perm); 368 - # if SANITIZER_FREEBSD 369 - CHECK_SIZE_AND_OFFSET(ipc_perm, key); 370 - @@ -1206,7 +1213,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); 371 - CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); 372 - #endif 373 - 374 - -#if SANITIZER_LINUX 375 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 376 - COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); 377 - #endif 378 - 379 - @@ -1256,7 +1263,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); 380 - COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); 381 - #endif 382 - 383 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 384 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 385 - COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); 386 - CHECK_SIZE_AND_OFFSET(FILE, _flags); 387 - CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); 388 - @@ -1275,7 +1282,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); 389 - CHECK_SIZE_AND_OFFSET(FILE, _fileno); 390 - #endif 391 - 392 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 393 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 394 - COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); 395 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); 396 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); 397 - diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc 398 - index de989b780..51a97b554 100644 399 - --- a/lib/tsan/rtl/tsan_platform_linux.cc 400 - +++ b/lib/tsan/rtl/tsan_platform_linux.cc 401 - @@ -294,7 +294,7 @@ void InitializePlatform() { 402 - // This is required to properly "close" the fds, because we do not see internal 403 - // closes within glibc. The code is a pure hack. 404 - int ExtractResolvFDs(void *state, int *fds, int nfd) { 405 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 406 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 407 - int cnt = 0; 408 - struct __res_state *statp = (struct __res_state*)state; 409 - for (int i = 0; i < MAXNS && cnt < nfd; i++) { 410 - -- 411 - 2.19.0 412 -
+1 -2
pkgs/development/compilers/llvm/git/compiler-rt/default.nix
··· 59 59 # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the 60 60 # extra `/`. 61 61 ./normalize-var.patch 62 - ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch 63 - # Prevent a compilation error on darwin 62 + ] # Prevent a compilation error on darwin 64 63 ++ lib.optional stdenv.hostPlatform.isDarwin ./darwin-targetconditionals.patch 65 64 ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 66 65
-412
pkgs/development/compilers/llvm/git/compiler-rt/sanitizers-nongnu.patch
··· 1 - From f7a253f8f85d0f49df6b73996737a3e84ac64236 Mon Sep 17 00:00:00 2001 2 - From: Will Dietz <w@wdtz.org> 3 - Date: Mon, 24 Sep 2018 11:17:25 -0500 4 - Subject: [PATCH] Ported to 7.0, taken from gentoo-musl project. 5 - 6 - ------ 7 - Ported to compiler-rt-sanitizers-5.0.0. Taken from 8 - 9 - https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch 10 - Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> 11 - 12 - Taken from gentoo-musl project, with a few additional minor fixes. 13 - --- 14 - lib/asan/asan_linux.cc | 4 +- 15 - lib/interception/interception_linux.cc | 2 +- 16 - lib/interception/interception_linux.h | 2 +- 17 - lib/msan/msan_linux.cc | 2 +- 18 - lib/sanitizer_common/sanitizer_allocator.cc | 2 +- 19 - .../sanitizer_common_interceptors_ioctl.inc | 4 +- 20 - .../sanitizer_common_syscalls.inc | 2 +- 21 - lib/sanitizer_common/sanitizer_linux.cc | 8 +++- 22 - .../sanitizer_linux_libcdep.cc | 10 ++--- 23 - lib/sanitizer_common/sanitizer_platform.h | 6 +++ 24 - .../sanitizer_platform_interceptors.h | 4 +- 25 - .../sanitizer_platform_limits_posix.cc | 37 +++++++++++-------- 26 - lib/tsan/rtl/tsan_platform_linux.cc | 2 +- 27 - 13 files changed, 51 insertions(+), 34 deletions(-) 28 - 29 - diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc 30 - index 625f32d40..73cf77aca 100644 31 - --- a/lib/asan/asan_linux.cc 32 - +++ b/lib/asan/asan_linux.cc 33 - @@ -46,7 +46,7 @@ 34 - #include <link.h> 35 - #endif 36 - 37 - -#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS 38 - +#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 39 - #include <ucontext.h> 40 - extern "C" void* _DYNAMIC; 41 - #elif SANITIZER_NETBSD 42 - @@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { 43 - UNIMPLEMENTED(); 44 - } 45 - 46 - -#if SANITIZER_ANDROID 47 - +#if SANITIZER_ANDROID || SANITIZER_NONGNU 48 - // FIXME: should we do anything for Android? 49 - void AsanCheckDynamicRTPrereqs() {} 50 - void AsanCheckIncompatibleRT() {} 51 - diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc 52 - index 26bfcd8f6..529b234f7 100644 53 - --- a/lib/interception/interception_linux.cc 54 - +++ b/lib/interception/interception_linux.cc 55 - @@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, 56 - } 57 - 58 - // Android and Solaris do not have dlvsym 59 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 60 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 61 - void *GetFuncAddrVer(const char *func_name, const char *ver) { 62 - return dlvsym(RTLD_NEXT, func_name, ver); 63 - } 64 - diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h 65 - index 942c25609..24a4d5080 100644 66 - --- a/lib/interception/interception_linux.h 67 - +++ b/lib/interception/interception_linux.h 68 - @@ -36,7 +36,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); 69 - (::__interception::uptr) & WRAP(func)) 70 - 71 - // Android, Solaris and OpenBSD do not have dlvsym 72 - -#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD 73 - +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 74 - #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ 75 - (::__interception::real_##func = (func##_f)( \ 76 - unsigned long)::__interception::GetFuncAddrVer(#func, symver)) 77 - diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc 78 - index 385a650c4..6e30a8ce9 100644 79 - --- a/lib/msan/msan_linux.cc 80 - +++ b/lib/msan/msan_linux.cc 81 - @@ -13,7 +13,7 @@ 82 - //===----------------------------------------------------------------------===// 83 - 84 - #include "sanitizer_common/sanitizer_platform.h" 85 - -#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD 86 - +#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD 87 - 88 - #include "msan.h" 89 - #include "msan_report.h" 90 - diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc 91 - index 6bfd5e5ee..048f6154f 100644 92 - --- a/lib/sanitizer_common/sanitizer_allocator.cc 93 - +++ b/lib/sanitizer_common/sanitizer_allocator.cc 94 - @@ -27,7 +27,7 @@ const char *SecondaryAllocatorName = "LargeMmapAllocator"; 95 - 96 - // ThreadSanitizer for Go uses libc malloc/free. 97 - #if SANITIZER_GO || defined(SANITIZER_USE_MALLOC) 98 - -# if SANITIZER_LINUX && !SANITIZER_ANDROID 99 - +# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 100 - extern "C" void *__libc_malloc(uptr size); 101 - # if !SANITIZER_GO 102 - extern "C" void *__libc_memalign(uptr alignment, uptr size); 103 - diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 104 - index 2d633c173..b6eb23116 100644 105 - --- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 106 - +++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 107 - @@ -104,7 +104,7 @@ static void ioctl_table_fill() { 108 - _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); 109 - #endif 110 - 111 - -#if SANITIZER_LINUX 112 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 113 - // Conflicting request ids. 114 - // _(CDROMAUDIOBUFSIZ, NONE, 0); 115 - // _(SNDCTL_TMR_CONTINUE, NONE, 0); 116 - @@ -365,7 +365,7 @@ static void ioctl_table_fill() { 117 - _(VT_WAITACTIVE, NONE, 0); 118 - #endif 119 - 120 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 121 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 122 - // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE 123 - _(CYGETDEFTHRESH, WRITE, sizeof(int)); 124 - _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); 125 - diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc 126 - index 469c8eb7e..24f87867d 100644 127 - --- a/lib/sanitizer_common/sanitizer_common_syscalls.inc 128 - +++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc 129 - @@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { 130 - } 131 - } 132 - 133 - -#if !SANITIZER_ANDROID 134 - +#if !SANITIZER_ANDROID && !SANITIZER_NONGNU 135 - PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, 136 - void *old_rlim) { 137 - if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); 138 - diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc 139 - index 96d6c1eff..9e2b7fb9d 100644 140 - --- a/lib/sanitizer_common/sanitizer_linux.cc 141 - +++ b/lib/sanitizer_common/sanitizer_linux.cc 142 - @@ -541,13 +541,13 @@ const char *GetEnv(const char *name) { 143 - #endif 144 - } 145 - 146 - -#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD 147 - +#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_NONGNU 148 - extern "C" { 149 - SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end; 150 - } 151 - #endif 152 - 153 - -#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 154 - +#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ 155 - !SANITIZER_OPENBSD 156 - static void ReadNullSepFileToArray(const char *path, char ***arr, 157 - int arr_size) { 158 - @@ -590,6 +590,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) { 159 - #elif SANITIZER_NETBSD 160 - *argv = __ps_strings->ps_argvstr; 161 - *envp = __ps_strings->ps_envstr; 162 - +#elif SANITIZER_NONGNU 163 - + static const int kMaxArgv = 2000, kMaxEnvp = 2000; 164 - + ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv); 165 - + ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp); 166 - #else // SANITIZER_FREEBSD 167 - #if !SANITIZER_GO 168 - if (&__libc_stack_end) { 169 - diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 170 - index 4962ff832..438f94dbe 100644 171 - --- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc 172 - +++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 173 - @@ -179,7 +179,7 @@ __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor, 174 - } 175 - 176 - #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \ 177 - - !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS 178 - + !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU 179 - static uptr g_tls_size; 180 - 181 - #ifdef __i386__ 182 - @@ -261,7 +261,7 @@ void InitTlsSize() { } 183 - #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) || \ 184 - defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) || \ 185 - defined(__arm__)) && \ 186 - - SANITIZER_LINUX && !SANITIZER_ANDROID 187 - + SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 188 - // sizeof(struct pthread) from glibc. 189 - static atomic_uintptr_t thread_descriptor_size; 190 - 191 - @@ -426,7 +426,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) { 192 - 193 - #if !SANITIZER_GO 194 - static void GetTls(uptr *addr, uptr *size) { 195 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 196 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 197 - # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) 198 - *addr = ThreadSelf(); 199 - *size = GetTlsSize(); 200 - @@ -470,7 +470,7 @@ static void GetTls(uptr *addr, uptr *size) { 201 - #elif SANITIZER_OPENBSD 202 - *addr = 0; 203 - *size = 0; 204 - -#elif SANITIZER_ANDROID 205 - +#elif SANITIZER_ANDROID || SANITIZER_NONGNU 206 - *addr = 0; 207 - *size = 0; 208 - #elif SANITIZER_SOLARIS 209 - @@ -486,7 +486,7 @@ static void GetTls(uptr *addr, uptr *size) { 210 - #if !SANITIZER_GO 211 - uptr GetTlsSize() { 212 - #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \ 213 - - SANITIZER_OPENBSD || SANITIZER_SOLARIS 214 - + SANITIZER_OPENBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU 215 - uptr addr, size; 216 - GetTls(&addr, &size); 217 - return size; 218 - diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h 219 - index d81e25580..e10680ac8 100644 220 - --- a/lib/sanitizer_common/sanitizer_platform.h 221 - +++ b/lib/sanitizer_common/sanitizer_platform.h 222 - @@ -208,6 +208,12 @@ 223 - # define SANITIZER_SOLARIS32 0 224 - #endif 225 - 226 - +#if defined(__linux__) && !defined(__GLIBC__) 227 - +# define SANITIZER_NONGNU 1 228 - +#else 229 - +# define SANITIZER_NONGNU 0 230 - +#endif 231 - + 232 - #if defined(__myriad2__) 233 - # define SANITIZER_MYRIAD2 1 234 - #else 235 - diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h 236 - index f95539a73..6c53b3415 100644 237 - --- a/lib/sanitizer_common/sanitizer_platform_interceptors.h 238 - +++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h 239 - @@ -39,7 +39,7 @@ 240 - # include "sanitizer_platform_limits_solaris.h" 241 - #endif 242 - 243 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 244 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 245 - # define SI_LINUX_NOT_ANDROID 1 246 - #else 247 - # define SI_LINUX_NOT_ANDROID 0 248 - @@ -322,7 +322,7 @@ 249 - #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID) 250 - #define SANITIZER_INTERCEPT_SHMCTL \ 251 - (SI_NETBSD || SI_OPENBSD || SI_SOLARIS || \ 252 - - ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \ 253 - + ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \ 254 - SANITIZER_WORDSIZE == 64)) // NOLINT 255 - #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID 256 - #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX 257 - diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 258 - index 54da635d7..2f6ff69c3 100644 259 - --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 260 - +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 261 - @@ -14,6 +14,9 @@ 262 - 263 - #include "sanitizer_platform.h" 264 - 265 - +// Workaround musl <--> linux conflicting definition of 'struct sysinfo' 266 - +#define _LINUX_SYSINFO_H 267 - + 268 - #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC 269 - // Tests in this file assume that off_t-dependent data structures match the 270 - // libc ABI. For example, struct dirent here is what readdir() function (as 271 - @@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; 272 - 273 - #if SANITIZER_LINUX && !SANITIZER_ANDROID 274 - #include <glob.h> 275 - -#include <obstack.h> 276 - +# if !SANITIZER_NONGNU 277 - +# include <obstack.h> 278 - +# endif 279 - #include <mqueue.h> 280 - -#include <net/if_ppp.h> 281 - -#include <netax25/ax25.h> 282 - -#include <netipx/ipx.h> 283 - -#include <netrom/netrom.h> 284 - +#include <linux/if_ppp.h> 285 - +#include <linux/ax25.h> 286 - +#include <linux/ipx.h> 287 - +#include <linux/netrom.h> 288 - #if HAVE_RPC_XDR_H 289 - # include <rpc/xdr.h> 290 - #elif HAVE_TIRPC_RPC_XDR_H 291 - @@ -251,7 +256,7 @@ namespace __sanitizer { 292 - unsigned struct_itimerspec_sz = sizeof(struct itimerspec); 293 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 294 - 295 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 296 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 297 - // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which 298 - // has been removed from glibc 2.28. 299 - #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \ 300 - @@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); 301 - unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 302 - #endif 303 - 304 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 305 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 306 - int glob_nomatch = GLOB_NOMATCH; 307 - int glob_altdirfunc = GLOB_ALTDIRFUNC; 308 - #endif 309 - @@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 310 - unsigned struct_termios_sz = sizeof(struct termios); 311 - unsigned struct_winsize_sz = sizeof(struct winsize); 312 - 313 - -#if SANITIZER_LINUX 314 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 315 - unsigned struct_arpreq_sz = sizeof(struct arpreq); 316 - unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); 317 - unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); 318 - @@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 319 - unsigned struct_vt_mode_sz = sizeof(struct vt_mode); 320 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 321 - 322 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 323 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 324 - unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); 325 - unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); 326 - #if EV_VERSION > (0x010000) 327 - @@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 328 - unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; 329 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 330 - 331 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 332 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 333 - unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; 334 - unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; 335 - unsigned IOCTL_CYGETMON = CYGETMON; 336 - @@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); 337 - CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); 338 - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 339 - 340 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 341 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 342 - CHECK_TYPE_SIZE(glob_t); 343 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); 344 - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); 345 - @@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec); 346 - CHECK_SIZE_AND_OFFSET(iovec, iov_base); 347 - CHECK_SIZE_AND_OFFSET(iovec, iov_len); 348 - 349 - +#if !SANITIZER_NONGNU 350 - CHECK_TYPE_SIZE(msghdr); 351 - CHECK_SIZE_AND_OFFSET(msghdr, msg_name); 352 - CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); 353 - @@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr); 354 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); 355 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); 356 - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); 357 - +#endif 358 - 359 - #ifndef __GLIBC_PREREQ 360 - #define __GLIBC_PREREQ(x, y) 0 361 - @@ -1145,7 +1152,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); 362 - 363 - CHECK_TYPE_SIZE(ether_addr); 364 - 365 - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 366 - +#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 367 - CHECK_TYPE_SIZE(ipc_perm); 368 - # if SANITIZER_FREEBSD 369 - CHECK_SIZE_AND_OFFSET(ipc_perm, key); 370 - @@ -1206,7 +1213,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); 371 - CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); 372 - #endif 373 - 374 - -#if SANITIZER_LINUX 375 - +#if SANITIZER_LINUX && !SANITIZER_NONGNU 376 - COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); 377 - #endif 378 - 379 - @@ -1256,7 +1263,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); 380 - COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); 381 - #endif 382 - 383 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 384 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 385 - COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); 386 - CHECK_SIZE_AND_OFFSET(FILE, _flags); 387 - CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); 388 - @@ -1275,7 +1282,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); 389 - CHECK_SIZE_AND_OFFSET(FILE, _fileno); 390 - #endif 391 - 392 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 393 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 394 - COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); 395 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); 396 - CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); 397 - diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc 398 - index de989b780..51a97b554 100644 399 - --- a/lib/tsan/rtl/tsan_platform_linux.cc 400 - +++ b/lib/tsan/rtl/tsan_platform_linux.cc 401 - @@ -294,7 +294,7 @@ void InitializePlatform() { 402 - // This is required to properly "close" the fds, because we do not see internal 403 - // closes within glibc. The code is a pure hack. 404 - int ExtractResolvFDs(void *state, int *fds, int nfd) { 405 - -#if SANITIZER_LINUX && !SANITIZER_ANDROID 406 - +#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 407 - int cnt = 0; 408 - struct __res_state *statp = (struct __res_state*)state; 409 - for (int i = 0; i < MAXNS && cnt < nfd; i++) { 410 - -- 411 - 2.19.0 412 -