Disable AddressSanitizer JIT instrumentation support on Windows

When compiling with Clang on Windows, __has_feature(address_sanitizer)
is true for asan enabled builds. This caused us to try to include
<dlfcn.h> and use dlsym(), which is UNIX specific, for looking up
symbols in the asan runtime for use by the LLVM JIT instrumentation.

While it should be feasible to do the equivalent on Windows by using
GetProcAddress(), for now just disable asan instrumentation of JIT-
compiled code on Windows to fix the asan Clang build.

Instrumentation of static code (C++) is unaffected.

Bug: b/240465596
Change-Id: Ibeee6dcdc233c9d43dd0dfd30ac6c8c12ec3711d
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/67308
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Reactor/LLVMJIT.cpp b/src/Reactor/LLVMJIT.cpp
index ca0a5c8..06ec887 100644
--- a/src/Reactor/LLVMJIT.cpp
+++ b/src/Reactor/LLVMJIT.cpp
@@ -63,8 +63,13 @@
     __pragma(warning(pop))
 #endif
 
-#if __has_feature(memory_sanitizer) || __has_feature(address_sanitizer)
-#	include <dlfcn.h>  // dlsym()
+#if defined(__unix__) || defined(__APPLE__) || defined(__Fuchsia__)
+#	define ADDRESS_SANITIZER_INSTRUMENTATION_SUPPORTED true
+#	if __has_feature(memory_sanitizer) || __has_feature(address_sanitizer)
+#		include <dlfcn.h>  // dlsym()
+#	endif
+#else
+#	define ADDRESS_SANITIZER_INSTRUMENTATION_SUPPORTED false
 #endif
 
 #ifndef REACTOR_ASM_EMIT_DIR
@@ -636,7 +641,7 @@
 				continue;
 			}
 
-#if __has_feature(memory_sanitizer) || __has_feature(address_sanitizer)
+#if __has_feature(memory_sanitizer) || (__has_feature(address_sanitizer) && ADDRESS_SANITIZER_INSTRUMENTATION_SUPPORTED)
 			// Sanitizers use a dynamically linked runtime. Instrumented routines reference some
 			// symbols from this library. Look them up dynamically in the default namespace.
 			// Note this approach should not be used for other symbols, since they might not be
@@ -933,7 +938,7 @@
 		pm.addPass(llvm::createModuleToFunctionPassAdaptor(llvm::MemorySanitizerPass(msanOpts)));
 	}
 
-	if(__has_feature(address_sanitizer))
+	if(__has_feature(address_sanitizer) && ADDRESS_SANITIZER_INSTRUMENTATION_SUPPORTED)
 	{
 		pm.addPass(llvm::ModuleAddressSanitizerPass(llvm::AddressSanitizerOptions{}));
 	}
@@ -964,7 +969,7 @@
 		passManager.add(llvm::createMemorySanitizerLegacyPassPass(msanOpts));
 	}
 
-	if(__has_feature(address_sanitizer))
+	if(__has_feature(address_sanitizer) && ADDRESS_SANITIZER_INSTRUMENTATION_SUPPORTED)
 	{
 		passManager.add(llvm::createAddressSanitizerFunctionPass());
 	}