+
+ # We need to correctly distinguish between gcc's and clang's ASan DSOs.
+ if ldd $BUILD_DIR/systemd | grep -q libasan.so; then
+ ASAN_COMPILER=gcc
+ elif ldd $BUILD_DIR/systemd | grep -q libclang_rt.asan; then
+ ASAN_COMPILER=clang
+
+ # As clang's ASan DSO is usually in a non-standard path, let's check if
+ # the environment is set accordingly. If not, warn the user and exit.
+ # We're not setting the LD_LIBRARY_PATH automagically here, because
+ # user should encounter (and fix) the same issue when running the unit
+ # tests (meson test)
+ if ldd "$BUILD_DIR/systemd" | grep -q "libclang_rt.asan.*not found"; then
+ _asan_rt_name="$(ldd $BUILD_DIR/systemd | awk '/libclang_rt.asan/ {print $1; exit}')"
+ _asan_rt_path="$(find /usr/lib* /usr/local/lib* -type f -name "$_asan_rt_name" 2>/dev/null | sed 1q)"
+ echo >&2 "clang's ASan DSO ($_asan_rt_name) is not present in the runtime library path"
+ echo >&2 "Consider setting LD_LIBRARY_PATH=${_asan_rt_path%/*}"
+ exit 1
+ fi
+ else
+ echo >&2 "systemd is not linked against the ASan DSO"
+ echo >&2 "gcc does this by default, for clang compile with -shared-libasan"
+ exit 1
+ fi