git.iko.soy/typeable/nixpkgs
on master help sign in
llvm6: patch to enable sanitizers w/musl
commit60bf299e6affada1aec05e6bcbbb44652e417a5d authorWill Dietz <w@wdtz.org> dateWed 14 Mar 2018, 12:48 (9 years ago) parenta8824ab
2 files changed+377−5
pkgs/development/compilers/llvm/6/llvm.nix−5 pkgs/development/compilers/llvm/6/sanitizers-nongnu.patch+377
pkgs/development/compilers/llvm/6/llvm.nix−5
@@ -78,11 +78,6 @@ in stdenv.mkDerivation (rec {
7878 --replace "add_subdirectory(DynamicLibrary)" ""
7979 rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
8080 patch -p1 -i ${./sanitizers-nongnu.patch} -d projects/compiler-rt
81− sed -i projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc \
82− -e '1i#define _LINUX_SYSINFO_H'
83− substituteInPlace projects/compiler-rt/lib/interception/interception_linux.h \
84− --replace '!defined(__ANDROID__)' \
85− '!defined(__ANDROID__) && !SANITIZER_NONGNU'
8681 '';
8782
8883 # hacky fix: created binaries need to be run before installation
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+