When compiler-rt is configured for a standalone build the
config.compiler_rt_libdir path isn't correct because the Clang used
for testing won't use the ASan runtime from this path.
During testing it seems that this bug only actually matters on Darwin for
the init_for_dlopen.cpp test case. The test fails because
the %shared_libasan expands to a path that doesn't exist. It doesn't
exist in this particular scenario because the build hasn't been run.
Even if the build were run %shared_libasan would still point to the
wrong path.
To fix this we query clang during lit setup to find out where the
clang being used for testing will get its ASan runtime from instead
of using config.compiler_rt_libdir.
Although this change could be made for other platforms we only make
it for Darwin for now to avoid accidently breaking testing on other
platforms.
This change should have no effect for in tree builds (the common case)
because config.compiler_rt_libdir and the output for `clang
-print-file-name=lib` agree.
rdar://77182297O
how come this import is inside the function?