[asan] use .preinit_array only on linux

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146379 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index fdea1b5..f16bdf5 100644
--- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -567,7 +567,6 @@
 
 // .preinit_array is something that hapens before all other inits.
 // On systems where .preinit_array is honored, we will call __asan_init early.
-// On other systems this will make no effect.
 void AddressSanitizer::appendToPreinitArray(Module &M, Function *F) {
   IRBuilder<> IRB(M.getContext());
   GlobalVariable *Var =
@@ -647,7 +646,9 @@
   }
 
   appendToGlobalCtors(M, AsanCtorFunction, 1 /*high priority*/);
-  appendToPreinitArray(M, AsanInitFunction);
+
+  if (M.getTargetTriple().find("linux") != std::string::npos)
+    appendToPreinitArray(M, AsanInitFunction);
 
   return Res;
 }