[compiler-rt] [asan][windows] When compiling with clang-cl or MSVC pass /Zl (that's a little L) (PR #85874)

Charlie Barto via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 19 15:54:50 PDT 2024


https://github.com/barcharcraz created https://github.com/llvm/llvm-project/pull/85874

/Zl is the equivalent of -nodefaultlibs. The idea here is to make sure that the asan runtime doesn't have any defaultlibs directives, which makes it easier to mix an asan runtime built with the dynamic CRT with an application built with the static CRT (or vise-versa).

This is part of the overall effort to remove the static asan runtime on windows entirely: https://github.com/llvm/llvm-project/pull/81677

>From c134a1d97342f22d9633ed53f6939c325c689d98 Mon Sep 17 00:00:00 2001
From: Charlie Barto <chbarto at microsoft.com>
Date: Mon, 12 Feb 2024 17:55:10 -0800
Subject: [PATCH] When compiling with clang-cl or MSVC pass /Zl (that's a
 little L)

/Zl is the equivalent of -nodefaultlibs.

Co-authored-by: Amy Wishnousky <amyw at microsoft.com>
---
 compiler-rt/lib/asan/CMakeLists.txt             | 3 +++
 compiler-rt/lib/sanitizer_common/CMakeLists.txt | 2 ++
 compiler-rt/lib/ubsan/CMakeLists.txt            | 1 +
 3 files changed, 6 insertions(+)

diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt
index f83ae82d42935a..601750f72175d6 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -85,6 +85,9 @@ SET(ASAN_HEADERS
 include_directories(..)
 
 set(ASAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
+
+append_list_if(MSVC /Zl ASAN_CFLAGS)
+
 set(ASAN_COMMON_DEFINITIONS ${COMPILER_RT_ASAN_SHADOW_SCALE_DEFINITION})
 
 append_rtti_flag(OFF ASAN_CFLAGS)
diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
index f762524c333acf..f2b4ac72ae1573 100644
--- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
@@ -218,6 +218,8 @@ include_directories(..)
 set(SANITIZER_COMMON_DEFINITIONS
   HAVE_RPC_XDR_H=${HAVE_RPC_XDR_H})
 
+# note: L not I, this is nodefaultlibs for msvc
+append_list_if(MSVC /Zl SANITIZER_COMMON_CFLAGS)
 set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 
 # Too many existing bugs, needs cleanup.
diff --git a/compiler-rt/lib/ubsan/CMakeLists.txt b/compiler-rt/lib/ubsan/CMakeLists.txt
index 3f1e12ed9ac66f..db0b33f1276ef2 100644
--- a/compiler-rt/lib/ubsan/CMakeLists.txt
+++ b/compiler-rt/lib/ubsan/CMakeLists.txt
@@ -41,6 +41,7 @@ set(UBSAN_HEADERS
 include_directories(..)
 
 set(UBSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
+append_list_if(MSVC /Zl UBSAN_CFLAGS)
 append_rtti_flag(OFF UBSAN_CFLAGS)
 append_list_if(SANITIZER_CAN_USE_CXXABI -DUBSAN_CAN_USE_CXXABI UBSAN_CFLAGS)
 



More information about the llvm-commits mailing list