git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #37049 from dtzWill/experimental/musl-sanitizers

llvm-{4,5,6}: patch compiler-rt to enable basic sanitizer and xray support on musl

commitd4be6b330e0a61f996aadf5a6cc1b2ad2f18c383 authorWill Dietz <github@wdtz.org> dateWed 14 Mar 2018, 23:21 (9 years ago) parent3ebc49cb2e6952
6 files changed+1118−9
pkgs/development/compilers/llvm/4/llvm.nix+1−3 pkgs/development/compilers/llvm/4/sanitizers-nongnu.patch+368 pkgs/development/compilers/llvm/5/llvm.nix+1−3 pkgs/development/compilers/llvm/5/sanitizers-nongnu.patch+370 pkgs/development/compilers/llvm/6/llvm.nix+1−3 pkgs/development/compilers/llvm/6/sanitizers-nongnu.patch+377
pkgs/development/compilers/llvm/4/llvm.nix+1−3
@@ -83,6 +83,7 @@ in stdenv.mkDerivation (rec {
8383 '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
8484 patch -p1 -i ${../TLI-musl.patch}
8585 patch -p1 -i ${./dynamiclibrary-musl.patch}
86+ patch -p1 -i ${./sanitizers-nongnu.patch} -d projects/compiler-rt
8687 '';
8788
8889 # hacky fix: created binaries need to be run before installation
@@ -118,9 +119,6 @@ in stdenv.mkDerivation (rec {
118119 "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
119120 "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}"
120121 "-DTARGET_TRIPLE=${stdenv.targetPlatform.config}"
121−
122− "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
123− "-DCOMPILER_RT_BUILD_XRAY=OFF"
124122 ];
125123
126124 postBuild = ''
pkgs/development/compilers/llvm/4/sanitizers-nongnu.patchnew file+368
@@ -0,0 +1,368 @@
1+From dac4d3912378069b44340204e5fc6237aa1baf94 Mon Sep 17 00:00:00 2001
2+From: Matthias Maier <tamiko@43-1.org>
3+Date: Fri, 5 May 2017 17:47:39 +0000
4+Subject: [PATCH] Musl patches
5+
6+Ported to compiler-rt-sanitizers-4.0.0. Taken from
7+
8+ https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch
9+---
10+ lib/asan/asan_linux.cc | 4 +--
11+ lib/interception/interception_linux.cc | 2 +-
12+ lib/interception/interception_linux.h | 2 +-
13+ lib/msan/msan_linux.cc | 2 +-
14+ .../sanitizer_common_interceptors_ioctl.inc | 4 +--
15+ lib/sanitizer_common/sanitizer_common_syscalls.inc | 2 +-
16+ lib/sanitizer_common/sanitizer_linux_libcdep.cc | 12 +++----
17+ lib/sanitizer_common/sanitizer_platform.h | 7 ++++
18+ .../sanitizer_platform_interceptors.h | 2 +-
19+ .../sanitizer_platform_limits_posix.cc | 39 +++++++++++++---------
20+ lib/tsan/rtl/tsan_platform_linux.cc | 2 +-
21+ 11 files changed, 46 insertions(+), 32 deletions(-)
22+
23+diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
24+index c051573dd..e295f6004 100644
25+--- a/lib/asan/asan_linux.cc
26++++ b/lib/asan/asan_linux.cc
27+@@ -39,7 +39,7 @@
28+ #include <sys/link_elf.h>
29+ #endif
30+
31+-#if SANITIZER_ANDROID || SANITIZER_FREEBSD
32++#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_NONGNU
33+ #include <ucontext.h>
34+ extern "C" void* _DYNAMIC;
35+ #else
36+@@ -80,7 +80,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) {
37+ UNIMPLEMENTED();
38+ }
39+
40+-#if SANITIZER_ANDROID
41++#if SANITIZER_ANDROID || SANITIZER_NONGNU
42+ // FIXME: should we do anything for Android?
43+ void AsanCheckDynamicRTPrereqs() {}
44+ void AsanCheckIncompatibleRT() {}
45+diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
46+index 6e908ac01..8f23d9adc 100644
47+--- a/lib/interception/interception_linux.cc
48++++ b/lib/interception/interception_linux.cc
49+@@ -24,7 +24,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
50+ return real == wrapper;
51+ }
52+
53+-#if !defined(__ANDROID__) // android does not have dlvsym
54++#if !defined(__ANDROID__) && !SANITIZER_NONGNU // android does not have dlvsym
55+ void *GetFuncAddrVer(const char *func_name, const char *ver) {
56+ return dlvsym(RTLD_NEXT, func_name, ver);
57+ }
58+diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h
59+index 27a66c882..3b559a303 100644
60+--- a/lib/interception/interception_linux.h
61++++ b/lib/interception/interception_linux.h
62+@@ -34,7 +34,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver);
63+ (::__interception::uptr) & (func), \
64+ (::__interception::uptr) & WRAP(func))
65+
66+-#if !defined(__ANDROID__) // android does not have dlvsym
67++#if !defined(__ANDROID__) && !SANITIZER_NONGNU // android does not have dlvsym
68+ #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
69+ (::__interception::real_##func = (func##_f)( \
70+ unsigned long)::__interception::GetFuncAddrVer(#func, symver))
71+diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc
72+index 0a687f620..0852d97d7 100644
73+--- a/lib/msan/msan_linux.cc
74++++ b/lib/msan/msan_linux.cc
75+@@ -13,7 +13,7 @@
76+ //===----------------------------------------------------------------------===//
77+
78+ #include "sanitizer_common/sanitizer_platform.h"
79+-#if SANITIZER_FREEBSD || SANITIZER_LINUX
80++#if SANITIZER_FREEBSD || SANITIZER_LINUX && !SANITIZER_NONGNU
81+
82+ #include "msan.h"
83+ #include "msan_thread.h"
84+diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
85+index 4ed9afedf..64f584e93 100644
86+--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
87++++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
88+@@ -100,7 +100,7 @@ static void ioctl_table_fill() {
89+ _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz);
90+ #endif
91+
92+-#if SANITIZER_LINUX
93++#if SANITIZER_LINUX && !SANITIZER_NONGNU
94+ // Conflicting request ids.
95+ // _(CDROMAUDIOBUFSIZ, NONE, 0);
96+ // _(SNDCTL_TMR_CONTINUE, NONE, 0);
97+@@ -361,7 +361,7 @@ static void ioctl_table_fill() {
98+ _(VT_WAITACTIVE, NONE, 0);
99+ #endif
100+
101+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
102++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
103+ // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE
104+ _(CYGETDEFTHRESH, WRITE, sizeof(int));
105+ _(CYGETDEFTIMEOUT, WRITE, sizeof(int));
106+diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc
107+index 469c8eb7e..24f87867d 100644
108+--- a/lib/sanitizer_common/sanitizer_common_syscalls.inc
109++++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc
110+@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) {
111+ }
112+ }
113+
114+-#if !SANITIZER_ANDROID
115++#if !SANITIZER_ANDROID && !SANITIZER_NONGNU
116+ PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim,
117+ void *old_rlim) {
118+ if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz);
119+diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
120+index f99f0b594..3a773a94e 100644
121+--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc
122++++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
123+@@ -152,7 +152,7 @@ bool SanitizerGetThreadName(char *name, int max_len) {
124+ #endif
125+ }
126+
127+-#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
128++#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU
129+ static uptr g_tls_size;
130+
131+ #ifdef __i386__
132+@@ -180,11 +180,11 @@ void InitTlsSize() {
133+ }
134+ #else
135+ void InitTlsSize() { }
136+-#endif // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
137++#endif // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU
138+
139+ #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \
140+ || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__)) \
141+- && SANITIZER_LINUX && !SANITIZER_ANDROID
142++ && SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
143+ // sizeof(struct pthread) from glibc.
144+ static atomic_uintptr_t kThreadDescriptorSize;
145+
146+@@ -338,7 +338,7 @@ uptr ThreadSelf() {
147+
148+ #if !SANITIZER_GO
149+ static void GetTls(uptr *addr, uptr *size) {
150+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
151++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
152+ # if defined(__x86_64__) || defined(__i386__) || defined(__s390__)
153+ *addr = ThreadSelf();
154+ *size = GetTlsSize();
155+@@ -364,7 +364,7 @@ static void GetTls(uptr *addr, uptr *size) {
156+ *addr = (uptr) dtv[2];
157+ *size = (*addr == 0) ? 0 : ((uptr) segbase[0] - (uptr) dtv[2]);
158+ }
159+-#elif SANITIZER_ANDROID
160++#elif SANITIZER_ANDROID || SANITIZER_NONGNU
161+ *addr = 0;
162+ *size = 0;
163+ #else
164+@@ -375,7 +375,7 @@ static void GetTls(uptr *addr, uptr *size) {
165+
166+ #if !SANITIZER_GO
167+ uptr GetTlsSize() {
168+-#if SANITIZER_FREEBSD || SANITIZER_ANDROID
169++#if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NONGNU
170+ uptr addr, size;
171+ GetTls(&addr, &size);
172+ return size;
173+diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h
174+index d9a8e8df1..fe01c5744 100644
175+--- a/lib/sanitizer_common/sanitizer_platform.h
176++++ b/lib/sanitizer_common/sanitizer_platform.h
177+@@ -162,6 +162,13 @@
178+ # define SANITIZER_PPC64V2 0
179+ #endif
180+
181++
182++#if defined(__linux__) && !defined(__GLIBC__)
183++# define SANITIZER_NONGNU 1
184++#else
185++# define SANITIZER_NONGNU 0
186++#endif
187++
188+ // By default we allow to use SizeClassAllocator64 on 64-bit platform.
189+ // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64
190+ // does not work well and we need to fallback to SizeClassAllocator32.
191+diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h
192+index 62875d11a..212e6e882 100644
193+--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h
194++++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h
195+@@ -23,7 +23,7 @@
196+ # define SI_NOT_WINDOWS 0
197+ #endif
198+
199+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
200++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
201+ # define SI_LINUX_NOT_ANDROID 1
202+ #else
203+ # define SI_LINUX_NOT_ANDROID 0
204+diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
205+index 683f019d7..fd4880962 100644
206+--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
207++++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
208+@@ -14,6 +14,8 @@
209+
210+ #include "sanitizer_platform.h"
211+
212++#define _LINUX_SYSINFO_H
213++
214+ #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
215+ // Tests in this file assume that off_t-dependent data structures match the
216+ // libc ABI. For example, struct dirent here is what readdir() function (as
217+@@ -139,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t;
218+
219+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
220+ #include <glob.h>
221+-#include <obstack.h>
222++# if !SANITIZER_NONGNU
223++# include <obstack.h>
224++# endif
225+ #include <mqueue.h>
226+-#include <net/if_ppp.h>
227+-#include <netax25/ax25.h>
228+-#include <netipx/ipx.h>
229+-#include <netrom/netrom.h>
230++#include <linux/if_ppp.h>
231++#include <linux/ax25.h>
232++#include <linux/ipx.h>
233++#include <linux/netrom.h>
234+ #if HAVE_RPC_XDR_H
235+ # include <rpc/xdr.h>
236+ #elif HAVE_TIRPC_RPC_XDR_H
237+@@ -160,7 +164,8 @@ typedef struct user_fpregs elf_fpregset_t;
238+ # include <sys/procfs.h>
239+ #endif
240+ #include <sys/user.h>
241+-#include <sys/ustat.h>
242++// #include <sys/ustat.h>
243++#include <sys/statfs.h>
244+ #include <linux/cyclades.h>
245+ #include <linux/if_eql.h>
246+ #include <linux/if_plip.h>
247+@@ -252,7 +257,7 @@ namespace __sanitizer {
248+ unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
249+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
250+
251+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
252++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
253+ unsigned struct_ustat_sz = sizeof(struct ustat);
254+ unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
255+ unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
256+@@ -310,7 +315,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr));
257+ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
258+ #endif
259+
260+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
261++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
262+ int glob_nomatch = GLOB_NOMATCH;
263+ int glob_altdirfunc = GLOB_ALTDIRFUNC;
264+ #endif
265+@@ -404,7 +409,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
266+ unsigned struct_termios_sz = sizeof(struct termios);
267+ unsigned struct_winsize_sz = sizeof(struct winsize);
268+
269+-#if SANITIZER_LINUX
270++#if SANITIZER_LINUX && !SANITIZER_NONGNU
271+ unsigned struct_arpreq_sz = sizeof(struct arpreq);
272+ unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf);
273+ unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession);
274+@@ -454,7 +459,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
275+ unsigned struct_vt_mode_sz = sizeof(struct vt_mode);
276+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
277+
278+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
279++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
280+ unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
281+ unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
282+ #if EV_VERSION > (0x010000)
283+@@ -822,7 +827,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
284+ unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE;
285+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
286+
287+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
288++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
289+ unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
290+ unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
291+ unsigned IOCTL_CYGETMON = CYGETMON;
292+@@ -985,7 +990,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
293+ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
294+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
295+
296+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
297++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
298+ CHECK_TYPE_SIZE(glob_t);
299+ CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
300+ CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
301+@@ -1019,6 +1024,7 @@ CHECK_TYPE_SIZE(iovec);
302+ CHECK_SIZE_AND_OFFSET(iovec, iov_base);
303+ CHECK_SIZE_AND_OFFSET(iovec, iov_len);
304+
305++#if !SANITIZER_NONGNU
306+ CHECK_TYPE_SIZE(msghdr);
307+ CHECK_SIZE_AND_OFFSET(msghdr, msg_name);
308+ CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen);
309+@@ -1032,6 +1038,7 @@ CHECK_TYPE_SIZE(cmsghdr);
310+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len);
311+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level);
312+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
313++#endif
314+
315+ COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent));
316+ CHECK_SIZE_AND_OFFSET(dirent, d_ino);
317+@@ -1134,7 +1141,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno);
318+
319+ CHECK_TYPE_SIZE(ether_addr);
320+
321+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
322++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
323+ CHECK_TYPE_SIZE(ipc_perm);
324+ # if SANITIZER_FREEBSD
325+ CHECK_SIZE_AND_OFFSET(ipc_perm, key);
326+@@ -1195,7 +1202,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
327+ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data);
328+ #endif
329+
330+-#if SANITIZER_LINUX
331++#if SANITIZER_LINUX && !SANITIZER_NONGNU
332+ COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo));
333+ #endif
334+
335+@@ -1245,7 +1252,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE);
336+ COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE);
337+ #endif
338+
339+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
340++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
341+ COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE));
342+ CHECK_SIZE_AND_OFFSET(FILE, _flags);
343+ CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr);
344+@@ -1264,7 +1271,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain);
345+ CHECK_SIZE_AND_OFFSET(FILE, _fileno);
346+ #endif
347+
348+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
349++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
350+ COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk));
351+ CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit);
352+ CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev);
353+diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc
354+index 3313288a7..103c7b6b9 100644
355+--- a/lib/tsan/rtl/tsan_platform_linux.cc
356++++ b/lib/tsan/rtl/tsan_platform_linux.cc
357+@@ -287,7 +287,7 @@ void InitializePlatform() {
358+ // This is required to properly "close" the fds, because we do not see internal
359+ // closes within glibc. The code is a pure hack.
360+ int ExtractResolvFDs(void *state, int *fds, int nfd) {
361+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
362++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
363+ int cnt = 0;
364+ __res_state *statp = (__res_state*)state;
365+ for (int i = 0; i < MAXNS && cnt < nfd; i++) {
366+--
367+2.16.2
368+
pkgs/development/compilers/llvm/5/llvm.nix+1−3
@@ -79,6 +79,7 @@ in stdenv.mkDerivation (rec {
7979 substituteInPlace unittests/Support/CMakeLists.txt \
8080 --replace "add_subdirectory(DynamicLibrary)" ""
8181 rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
82+ patch -p1 -i ${./sanitizers-nongnu.patch} -d projects/compiler-rt
8283 '';
8384
8485 # hacky fix: created binaries need to be run before installation
@@ -114,9 +115,6 @@ in stdenv.mkDerivation (rec {
114115 "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
115116 "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}"
116117 "-DTARGET_TRIPLE=${stdenv.targetPlatform.config}"
117−
118− "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
119− "-DCOMPILER_RT_BUILD_XRAY=OFF"
120118 ];
121119
122120 postBuild = ''
pkgs/development/compilers/llvm/5/sanitizers-nongnu.patchnew file+370
@@ -0,0 +1,370 @@
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+
pkgs/development/compilers/llvm/6/llvm.nix+1−3
@@ -77,6 +77,7 @@ in stdenv.mkDerivation (rec {
7777 substituteInPlace unittests/Support/CMakeLists.txt \
7878 --replace "add_subdirectory(DynamicLibrary)" ""
7979 rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
80+ patch -p1 -i ${./sanitizers-nongnu.patch} -d projects/compiler-rt
8081 '';
8182
8283 # hacky fix: created binaries need to be run before installation
@@ -112,9 +113,6 @@ in stdenv.mkDerivation (rec {
112113 "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
113114 "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}"
114115 "-DTARGET_TRIPLE=${stdenv.targetPlatform.config}"
115−
116− "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
117− "-DCOMPILER_RT_BUILD_XRAY=OFF"
118116 ];
119117
120118 postBuild = ''
pkgs/development/compilers/llvm/6/sanitizers-nongnu.patchnew file+377
@@ -0,0 +1,377 @@
1+From 8c74f8274369f527f2ada3772f4a0b406cb481ec 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 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+ .../sanitizer_common_interceptors_ioctl.inc | 4 +--
19+ lib/sanitizer_common/sanitizer_common_syscalls.inc | 2 +-
20+ lib/sanitizer_common/sanitizer_linux_libcdep.cc | 10 +++---
21+ lib/sanitizer_common/sanitizer_platform.h | 6 ++++
22+ .../sanitizer_platform_interceptors.h | 4 +--
23+ .../sanitizer_platform_limits_posix.cc | 40 +++++++++++++---------
24+ lib/tsan/rtl/tsan_platform_linux.cc | 2 +-
25+ 11 files changed, 46 insertions(+), 33 deletions(-)
26+
27+diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
28+index 625f32d40..73cf77aca 100644
29+--- a/lib/asan/asan_linux.cc
30++++ b/lib/asan/asan_linux.cc
31+@@ -46,7 +46,7 @@
32+ #include <link.h>
33+ #endif
34+
35+-#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS
36++#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU
37+ #include <ucontext.h>
38+ extern "C" void* _DYNAMIC;
39+ #elif SANITIZER_NETBSD
40+@@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) {
41+ UNIMPLEMENTED();
42+ }
43+
44+-#if SANITIZER_ANDROID
45++#if SANITIZER_ANDROID || SANITIZER_NONGNU
46+ // FIXME: should we do anything for Android?
47+ void AsanCheckDynamicRTPrereqs() {}
48+ void AsanCheckIncompatibleRT() {}
49+diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
50+index c991550a4..2b706418b 100644
51+--- a/lib/interception/interception_linux.cc
52++++ b/lib/interception/interception_linux.cc
53+@@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
54+ }
55+
56+ // Android and Solaris do not have dlvsym
57+-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS
58++#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_NONGNU
59+ void *GetFuncAddrVer(const char *func_name, const char *ver) {
60+ return dlvsym(RTLD_NEXT, func_name, ver);
61+ }
62+diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h
63+index 98fe51b85..c13302b98 100644
64+--- a/lib/interception/interception_linux.h
65++++ b/lib/interception/interception_linux.h
66+@@ -35,8 +35,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver);
67+ (::__interception::uptr) & (func), \
68+ (::__interception::uptr) & WRAP(func))
69+
70+-// Android and Solaris do not have dlvsym
71+-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS
72++#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_NONGNU
73+ #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
74+ (::__interception::real_##func = (func##_f)( \
75+ unsigned long)::__interception::GetFuncAddrVer(#func, symver))
76+diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc
77+index 4e6321fcb..4d50feb82 100644
78+--- a/lib/msan/msan_linux.cc
79++++ b/lib/msan/msan_linux.cc
80+@@ -13,7 +13,7 @@
81+ //===----------------------------------------------------------------------===//
82+
83+ #include "sanitizer_common/sanitizer_platform.h"
84+-#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
85++#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD
86+
87+ #include "msan.h"
88+ #include "msan_thread.h"
89+diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
90+index 24e7548a5..20259b1d6 100644
91+--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
92++++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
93+@@ -102,7 +102,7 @@ static void ioctl_table_fill() {
94+ _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz);
95+ #endif
96+
97+-#if SANITIZER_LINUX
98++#if SANITIZER_LINUX && !SANITIZER_NONGNU
99+ // Conflicting request ids.
100+ // _(CDROMAUDIOBUFSIZ, NONE, 0);
101+ // _(SNDCTL_TMR_CONTINUE, NONE, 0);
102+@@ -363,7 +363,7 @@ static void ioctl_table_fill() {
103+ _(VT_WAITACTIVE, NONE, 0);
104+ #endif
105+
106+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
107++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
108+ // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE
109+ _(CYGETDEFTHRESH, WRITE, sizeof(int));
110+ _(CYGETDEFTIMEOUT, WRITE, sizeof(int));
111+diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc
112+index 469c8eb7e..24f87867d 100644
113+--- a/lib/sanitizer_common/sanitizer_common_syscalls.inc
114++++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc
115+@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) {
116+ }
117+ }
118+
119+-#if !SANITIZER_ANDROID
120++#if !SANITIZER_ANDROID && !SANITIZER_NONGNU
121+ PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim,
122+ void *old_rlim) {
123+ if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz);
124+diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
125+index 56fdfc870..a932d5db1 100644
126+--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc
127++++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
128+@@ -174,7 +174,7 @@ bool SanitizerGetThreadName(char *name, int max_len) {
129+ }
130+
131+ #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \
132+- !SANITIZER_NETBSD && !SANITIZER_SOLARIS
133++ !SANITIZER_NETBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU
134+ static uptr g_tls_size;
135+
136+ #ifdef __i386__
137+@@ -207,7 +207,7 @@ void InitTlsSize() { }
138+
139+ #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \
140+ || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) \
141+- || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID
142++ || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
143+ // sizeof(struct pthread) from glibc.
144+ static atomic_uintptr_t kThreadDescriptorSize;
145+
146+@@ -391,7 +391,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) {
147+
148+ #if !SANITIZER_GO
149+ static void GetTls(uptr *addr, uptr *size) {
150+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
151++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
152+ # if defined(__x86_64__) || defined(__i386__) || defined(__s390__)
153+ *addr = ThreadSelf();
154+ *size = GetTlsSize();
155+@@ -432,7 +432,7 @@ static void GetTls(uptr *addr, uptr *size) {
156+ *addr = (uptr)tcb->tcb_dtv[1];
157+ }
158+ }
159+-#elif SANITIZER_ANDROID
160++#elif SANITIZER_ANDROID || SANITIZER_NONGNU
161+ *addr = 0;
162+ *size = 0;
163+ #elif SANITIZER_SOLARIS
164+@@ -448,7 +448,7 @@ static void GetTls(uptr *addr, uptr *size) {
165+ #if !SANITIZER_GO
166+ uptr GetTlsSize() {
167+ #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \
168+- SANITIZER_SOLARIS
169++ SANITIZER_SOLARIS || SANITIZER_NONGNU
170+ uptr addr, size;
171+ GetTls(&addr, &size);
172+ return size;
173+diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h
174+index 334903c26..fc2afac2c 100644
175+--- a/lib/sanitizer_common/sanitizer_platform.h
176++++ b/lib/sanitizer_common/sanitizer_platform.h
177+@@ -195,6 +195,12 @@
178+ # define SANITIZER_SOLARIS32 0
179+ #endif
180+
181++#if defined(__linux__) && !defined(__GLIBC__)
182++# define SANITIZER_NONGNU 1
183++#else
184++# define SANITIZER_NONGNU 0
185++#endif
186++
187+ // By default we allow to use SizeClassAllocator64 on 64-bit platform.
188+ // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64
189+ // does not work well and we need to fallback to SizeClassAllocator32.
190+diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h
191+index b99ac4480..628d226a1 100644
192+--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h
193++++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h
194+@@ -38,7 +38,7 @@
195+ # include "sanitizer_platform_limits_solaris.h"
196+ #endif
197+
198+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
199++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
200+ # define SI_LINUX_NOT_ANDROID 1
201+ #else
202+ # define SI_LINUX_NOT_ANDROID 0
203+@@ -291,7 +291,7 @@
204+ (SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID)
205+ #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID)
206+ #define SANITIZER_INTERCEPT_SHMCTL \
207+- (SI_NETBSD || SI_SOLARIS || ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \
208++ (SI_NETBSD || SI_SOLARIS || ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \
209+ SANITIZER_WORDSIZE == 64)) // NOLINT
210+ #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID
211+ #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX
212+diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
213+index f12e8206a..8880197b0 100644
214+--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
215++++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
216+@@ -14,6 +14,9 @@
217+
218+ #include "sanitizer_platform.h"
219+
220++// Workaround musl <--> linux conflicting definition of 'struct sysinfo'
221++#define _LINUX_SYSINFO_H
222++
223+ #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
224+ // Tests in this file assume that off_t-dependent data structures match the
225+ // libc ABI. For example, struct dirent here is what readdir() function (as
226+@@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t;
227+
228+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
229+ #include <glob.h>
230+-#include <obstack.h>
231++# if !SANITIZER_NONGNU
232++# include <obstack.h>
233++# endif
234+ #include <mqueue.h>
235+-#include <net/if_ppp.h>
236+-#include <netax25/ax25.h>
237+-#include <netipx/ipx.h>
238+-#include <netrom/netrom.h>
239++#include <linux/if_ppp.h>
240++#include <linux/ax25.h>
241++#include <linux/ipx.h>
242++#include <linux/netrom.h>
243+ #if HAVE_RPC_XDR_H
244+ # include <rpc/xdr.h>
245+ #elif HAVE_TIRPC_RPC_XDR_H
246+@@ -159,7 +164,8 @@ typedef struct user_fpregs elf_fpregset_t;
247+ # include <sys/procfs.h>
248+ #endif
249+ #include <sys/user.h>
250+-#include <sys/ustat.h>
251++// #include <sys/ustat.h>
252++#include <sys/statfs.h>
253+ #include <linux/cyclades.h>
254+ #include <linux/if_eql.h>
255+ #include <linux/if_plip.h>
256+@@ -252,7 +258,7 @@ namespace __sanitizer {
257+ unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
258+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
259+
260+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
261++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
262+ unsigned struct_ustat_sz = sizeof(struct ustat);
263+ unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
264+ unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
265+@@ -311,7 +317,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr));
266+ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
267+ #endif
268+
269+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
270++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
271+ int glob_nomatch = GLOB_NOMATCH;
272+ int glob_altdirfunc = GLOB_ALTDIRFUNC;
273+ #endif
274+@@ -405,7 +411,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
275+ unsigned struct_termios_sz = sizeof(struct termios);
276+ unsigned struct_winsize_sz = sizeof(struct winsize);
277+
278+-#if SANITIZER_LINUX
279++#if SANITIZER_LINUX && !SANITIZER_NONGNU
280+ unsigned struct_arpreq_sz = sizeof(struct arpreq);
281+ unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf);
282+ unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession);
283+@@ -455,7 +461,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
284+ unsigned struct_vt_mode_sz = sizeof(struct vt_mode);
285+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
286+
287+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
288++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
289+ unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
290+ unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
291+ #if EV_VERSION > (0x010000)
292+@@ -823,7 +829,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
293+ unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE;
294+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
295+
296+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
297++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
298+ unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
299+ unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
300+ unsigned IOCTL_CYGETMON = CYGETMON;
301+@@ -978,7 +984,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
302+ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
303+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
304+
305+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
306++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
307+ CHECK_TYPE_SIZE(glob_t);
308+ CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
309+ CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
310+@@ -1012,6 +1018,7 @@ CHECK_TYPE_SIZE(iovec);
311+ CHECK_SIZE_AND_OFFSET(iovec, iov_base);
312+ CHECK_SIZE_AND_OFFSET(iovec, iov_len);
313+
314++#if !SANITIZER_NONGNU
315+ CHECK_TYPE_SIZE(msghdr);
316+ CHECK_SIZE_AND_OFFSET(msghdr, msg_name);
317+ CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen);
318+@@ -1025,6 +1032,7 @@ CHECK_TYPE_SIZE(cmsghdr);
319+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len);
320+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level);
321+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
322++#endif
323+
324+ COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent));
325+ CHECK_SIZE_AND_OFFSET(dirent, d_ino);
326+@@ -1127,7 +1135,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno);
327+
328+ CHECK_TYPE_SIZE(ether_addr);
329+
330+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
331++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
332+ CHECK_TYPE_SIZE(ipc_perm);
333+ # if SANITIZER_FREEBSD
334+ CHECK_SIZE_AND_OFFSET(ipc_perm, key);
335+@@ -1188,7 +1196,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
336+ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data);
337+ #endif
338+
339+-#if SANITIZER_LINUX
340++#if SANITIZER_LINUX && !SANITIZER_NONGNU
341+ COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo));
342+ #endif
343+
344+@@ -1238,7 +1246,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE);
345+ COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE);
346+ #endif
347+
348+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
349++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
350+ COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE));
351+ CHECK_SIZE_AND_OFFSET(FILE, _flags);
352+ CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr);
353+@@ -1257,7 +1265,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain);
354+ CHECK_SIZE_AND_OFFSET(FILE, _fileno);
355+ #endif
356+
357+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
358++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
359+ COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk));
360+ CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit);
361+ CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev);
362+diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc
363+index e14d5f575..389a3bc88 100644
364+--- a/lib/tsan/rtl/tsan_platform_linux.cc
365++++ b/lib/tsan/rtl/tsan_platform_linux.cc
366+@@ -285,7 +285,7 @@ void InitializePlatform() {
367+ // This is required to properly "close" the fds, because we do not see internal
368+ // closes within glibc. The code is a pure hack.
369+ int ExtractResolvFDs(void *state, int *fds, int nfd) {
370+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
371++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
372+ int cnt = 0;
373+ struct __res_state *statp = (struct __res_state*)state;
374+ for (int i = 0; i < MAXNS && cnt < nfd; i++) {
375+--
376+2.16.2
377+