@@ -0,0 +1,412 @@
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+