In Windows, when the sanitizer is implemented as a static library and is included in the main executable, we use auxiliary static library dll_thunk that will be linked to the dlls that have instrumentation, so they can refer to the runtime in the main executable. It uses interception to get a pointer the function in the main executable and override its function with that pointer.
To ensure that the main executable exports all the sanitizers' interface, all object files from the static library should be linked to the main executable, so we need to add the flag -wholearchive to clang driver, when including the static version of asan.
If we don't include -wholearchive , the linker could omit some object files when they don't resolve any symbol for the main executable.
But instrumented dlls will try to access to all the interface exposed by the main executable. If we omit part of it, the initialization in dll_thunk will fail.