diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc index 5f7d70c6da0d..7bb98a9023a2 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc @@ -48,6 +48,7 @@ #include #if SANITIZER_FREEBSD +#include // for getenv #include #include extern "C" { @@ -314,6 +315,7 @@ u64 NanoTime() { return (u64)tv.tv_sec * 1000*1000*1000 + tv.tv_usec * 1000; } +#if SANITIZER_LINUX // Like getenv, but reads env directly from /proc and does not use libc. // This function should be called first inside __asan_init. const char *GetEnv(const char *name) { @@ -341,6 +343,11 @@ const char *GetEnv(const char *name) { } return 0; // Not found. } +#else +const char *GetEnv(const char *name) { + return getenv(name); +} +#endif extern "C" { SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end;