Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ASAN for CoreCLR #54580

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
08dbc29
First pass to enable linking in ASAN for coreclr builds.
jkoritzinsky Jun 22, 2021
b3e5339
Remove /RTC1 from the linker flags as well.
jkoritzinsky Jun 22, 2021
5f2a39e
Get native code building (barring the VS support lib)
jkoritzinsky Jun 22, 2021
33a7348
Fix a few issues with ASAN and set up the asan options file correctly.
jkoritzinsky Jun 23, 2021
11820a9
Provide explicit no-sanitizer variants of standalone jits so running …
jkoritzinsky Jun 24, 2021
fbc456e
Define DISABLE_ASAN no-op fallback
jkoritzinsky Jun 24, 2021
bf287df
Dont link to object libraries.
jkoritzinsky Jun 24, 2021
34e3b69
Fix fallbacks
jkoritzinsky Jun 24, 2021
50c57b8
Fix Windows build.
jkoritzinsky Jun 24, 2021
3978425
Remove TODO
jkoritzinsky Jun 24, 2021
7f7289a
ASan is only supported on x86 or x64 of the platforms CoreCLR supports.
jkoritzinsky Jun 25, 2021
6d70047
Use the same MSVC runtime option Coreclr-build wide, remove extraneou…
jkoritzinsky Jun 25, 2021
aef3ade
Remove dac override of CRT flavor. It was causing issues getting VCAs…
jkoritzinsky Jun 25, 2021
212e6ce
Hack together something horrible to correctly fetch the shadow ranges…
jkoritzinsky Jun 26, 2021
e2addc9
Hook up ASAN support lib on Linux using weak symbols instead of dynam…
jkoritzinsky Jul 12, 2021
211f5cd
Add sanitizers to the single file host.
jkoritzinsky Jul 12, 2021
d41d8ab
Try a few fixes to get the Linux build working again.
jkoritzinsky Jul 13, 2021
56da0be
Disable LeakSanitizer for now to get cleaner test logs.
jkoritzinsky Jul 13, 2021
40dfadf
Add nosanitizer gcinfo build for arm64/arm32 clrjit.
jkoritzinsky Oct 11, 2021
0ea4f85
Only check if an AV is an asan shadow AV in debug since ASAN is debug…
jkoritzinsky Oct 11, 2021
df52f72
Disable ASAN in some methods that poke around in parent frames at ret…
jkoritzinsky Oct 20, 2021
3f8b19d
Let ASAN know when we won't return so it can do some cleanup on the s…
jkoritzinsky Nov 1, 2021
f4ca4f9
Add some ASAN suppressions for x86 and clean up some build script cha…
jkoritzinsky Oct 29, 2021
f499ba9
Use a special type alias to handle differences in how uptr is defined…
jkoritzinsky Oct 29, 2021
d8576aa
Change how StressLogAnalyzer builds temporarily to avoid issues with …
jkoritzinsky Mar 18, 2022
ba7837e
Change install for now for consistency with add_executable.
jkoritzinsky Mar 18, 2022
48e7dfb
Fix typo
jkoritzinsky Mar 21, 2022
2f60793
Fix build from rebase
jkoritzinsky Mar 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ if (MSVC)
add_linker_flag(/NODEFAULTLIB:libucrt.lib RELEASE)
add_linker_flag(/DEFAULTLIB:ucrt.lib RELEASE)

# /RTC1 is added by default by CMake, so remove it.
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "/RTC1" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
string(REPLACE "/RTC1" "" CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
string(REPLACE "/RTC1" "" CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")

elseif (CLR_CMAKE_HOST_UNIX)
# Set the values to display when interactively configuring CMAKE_BUILD_TYPE
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "DEBUG;CHECKED;RELEASE;RELWITHDEBINFO")
Expand All @@ -118,20 +124,11 @@ elseif (CLR_CMAKE_HOST_UNIX)
# set the CLANG sanitizer flags for debug build
if(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
# obtain settings from running enablesanitizers.sh
string(FIND "$ENV{DEBUG_SANITIZERS}" "asan" __ASAN_POS)
string(FIND "$ENV{DEBUG_SANITIZERS}" "ubsan" __UBSAN_POS)
if ((${__ASAN_POS} GREATER -1) OR (${__UBSAN_POS} GREATER -1))
if (${__UBSAN_POS} GREATER -1)
list(APPEND CLR_SANITIZE_CXX_OPTIONS -fsanitize-blacklist=${CMAKE_CURRENT_SOURCE_DIR}/sanitizerblacklist.txt)
set (CLR_CXX_SANITIZERS "")
set (CLR_LINK_SANITIZERS "")
if (${__ASAN_POS} GREATER -1)
list(APPEND CLR_CXX_SANITIZERS address)
list(APPEND CLR_LINK_SANITIZERS address)
set(CLR_SANITIZE_CXX_FLAGS "${CLR_SANITIZE_CXX_FLAGS}address,")
set(CLR_SANITIZE_LINK_FLAGS "${CLR_SANITIZE_LINK_FLAGS}address,")
add_definitions(-DHAS_ASAN)
message("Address Sanitizer (asan) enabled")
endif ()
if (${__UBSAN_POS} GREATER -1)
# all sanitizier flags are enabled except alignment (due to heavy use of __unaligned modifier)
list(APPEND CLR_CXX_SANITIZERS
Expand Down Expand Up @@ -673,7 +670,7 @@ if (MSVC)
# For Release builds, we shall dynamically link into uCRT [ucrtbase.dll] (which is pushed down as a Windows Update on downlevel OS) but
# wont do the same for debug/checked builds since ucrtbased.dll is not redistributable and Debug/Checked builds are not
# production-time scenarios.
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<AND:$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>,$<NOT:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>>:Debug>)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:Debug>)

add_compile_options($<$<COMPILE_LANGUAGE:ASM_MASM>:/ZH:SHA_256>)

Expand Down
81 changes: 51 additions & 30 deletions eng/native/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -586,42 +586,63 @@ function(add_linker_flag Flag)
endfunction()

function(link_natvis_sources_for_target targetName linkKind)
if (NOT CLR_CMAKE_HOST_WIN32)
return()
if (NOT CLR_CMAKE_HOST_WIN32)
return()
endif()
foreach(source ${ARGN})
if (NOT IS_ABSOLUTE "${source}")
convert_to_absolute_path(source ${source})
endif()
foreach(source ${ARGN})
if (NOT IS_ABSOLUTE "${source}")
convert_to_absolute_path(source ${source})
endif()
get_filename_component(extension "${source}" EXT)
if ("${extension}" STREQUAL ".natvis")
message("Embedding natvis ${source}")
# Since natvis embedding is only supported on Windows
# we can use target_link_options since our minimum version is high enough
target_link_options(${targetName} "${linkKind}" "-NATVIS:${source}")
endif()
endforeach()
get_filename_component(extension "${source}" EXT)
if ("${extension}" STREQUAL ".natvis")
# Since natvis embedding is only supported on Windows
# we can use target_link_options since our minimum version is high enough
target_link_options(${targetName} "${linkKind}" "-NATVIS:${source}")
endif()
endforeach()
endfunction()

function(add_executable_clr targetName)
if(NOT WIN32)
add_executable(${ARGV} ${VERSION_FILE_PATH})
disable_pax_mprotect(${ARGV})
function(add_sanitizers targetName)
if (CLR_CMAKE_ENABLE_ASAN)
get_target_property(kind "${targetName}" TYPE)
if ("${kind}" STREQUAL "SHARED_LIBRARY" OR "${kind}" STREQUAL "EXECUTABLE")
target_sources(${targetName} PRIVATE "$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>:${CLR_SRC_NATIVE_DIR}/minipal/asansupport.cpp>")
if ("${kind}" STREQUAL "EXECUTABLE")
target_compile_definitions(${targetName} PRIVATE ASAN_SUPPORT_EXPOSE_SHADOW)
endif()
endif()
if (MSVC)
target_compile_options("${targetName}" PRIVATE $<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>>:-fsanitize=address>)
else()
add_executable(${ARGV})
endif(NOT WIN32)
if(NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS)
strip_symbols(${ARGV0} symbolFile)
target_compile_options("${targetName}" PRIVATE $<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>>:-fsanitize=address>)
if (NOT "${kind}" STREQUAL "OBJECT_LIBRARY")
target_link_libraries("${targetName}" PRIVATE $<$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>:-fsanitize=address>)
endif()
endif()
endif()
endfunction()

function(add_executable_clr targetName)
if(NOT WIN32)
add_executable(${ARGV} ${VERSION_FILE_PATH})
disable_pax_mprotect(${ARGV})
else()
add_executable(${ARGV})
endif(NOT WIN32)
add_sanitizers(${targetName})
if(NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS)
strip_symbols(${ARGV0} symbolFile)
endif()
endfunction()

function(add_library_clr targetName kind)
if(NOT WIN32 AND "${kind}" STREQUAL "SHARED")
add_library(${ARGV} ${VERSION_FILE_PATH})
else()
add_library(${ARGV})
endif()
if("${kind}" STREQUAL "SHARED" AND NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS)
strip_symbols(${ARGV0} symbolFile)
endif()
if(NOT WIN32 AND "${kind}" STREQUAL "SHARED")
add_library(${ARGV} ${VERSION_FILE_PATH})
else()
add_library(${ARGV})
endif()
add_sanitizers(${targetName})
if("${kind}" STREQUAL "SHARED" AND NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS)
strip_symbols(${ARGV0} symbolFile)
endif()
endfunction()
5 changes: 0 additions & 5 deletions eng/native/ijw/IJW.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ if (CLR_CMAKE_HOST_WIN32)
# IJW requires the CRT as a dll, not linked in
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:Debug>DLL)

# CMake enables /RTC1 and /EHsc by default, but they're not compatible with /clr, so remove them
if(CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1")
string(REPLACE "/RTC1" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
endif()

remove_ijw_incompatible_options("${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)

set(CLR_SDK_REF_PACK_OUTPUT "")
Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ if(MSVC)
set(CMAKE_CXX_STANDARD_LIBRARIES "") # do not link against standard win32 libs i.e. kernel32, uuid, user32, etc.
endif (MSVC)

# Set up build flags for AddressSanitizer
set (CLR_CMAKE_ENABLE_ASAN OFF)
# ASan is only supported on x86 and x64 today.
if (CLR_CMAKE_HOST_ARCH_AMD64 OR CLR_CMAKE_HOST_ARCH_I386)
set(CLR_CMAKE_ENABLE_ASAN ON)
endif()

# Set commonly used directory names
set(CLR_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(VM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vm)
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/debug/createdump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if(CLR_CMAKE_HOST_WIN32)
)

target_link_libraries(createdump
PRIVATE
kernel32.lib
${STATIC_MT_CRT_LIB}
advapi32.lib
Expand Down Expand Up @@ -82,6 +83,7 @@ else()
endif(CLR_CMAKE_HOST_OSX)

target_link_libraries(createdump
PRIVATE
corguids
dbgutil
# share the PAL in the dac module
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/debug/dbgutil/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)

if(CLR_CMAKE_HOST_WIN32)
#use static crt
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
endif(CLR_CMAKE_HOST_WIN32)

if(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX)
include_directories(${CLR_DIR}/inc/llvm)
endif(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX)
Expand Down
3 changes: 0 additions & 3 deletions src/coreclr/debug/di/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ set(CORDBDI_HEADERS


if(CLR_CMAKE_HOST_WIN32)
#use static crt
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)

if (CLR_CMAKE_TARGET_ARCH_AMD64 OR ((CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_ARM)
AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD))
set(CORDBDI_SOURCES_ASM_FILE ${ARCH_SOURCES_DIR}/floatconversion.asm)
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/debug/shim/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if(CLR_CMAKE_HOST_WIN32)
#use static crt
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
add_definitions(-DHOST_WINDOWS)
endif(CLR_CMAKE_HOST_WIN32)

Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/dlls/clretwrc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include_directories(${CMAKE_CURRENT_BINARY_DIR})

set(CLR_CMAKE_ENABLE_ASAN OFF)

if(CLR_CMAKE_HOST_WIN32)
# remove /ltcg from resource-only libraries
string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/dlls/dbgshim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ set(DBGSHIM_SOURCES
)

if(CLR_CMAKE_HOST_WIN32)
# Use static crt
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
add_definitions(-DFX_VER_INTERNALNAME_STR=dbgshim.dll)
endif(CLR_CMAKE_HOST_WIN32)

Expand Down Expand Up @@ -81,7 +79,7 @@ else()
)
endif(CLR_CMAKE_HOST_WIN32)

target_link_libraries(dbgshim ${DBGSHIM_LIBRARIES})
target_link_libraries(dbgshim PRIVATE ${DBGSHIM_LIBRARIES})

# add the install targets
install_clr(TARGETS dbgshim DESTINATIONS . sharedFramework COMPONENT runtime)
4 changes: 2 additions & 2 deletions src/coreclr/dlls/mscordbi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ if(CLR_CMAKE_HOST_WIN32)
${STATIC_MT_VCRT_LIB}
)

target_link_libraries(mscordbi ${COREDBI_LIBRARIES})
target_link_libraries(mscordbi PRIVATE ${COREDBI_LIBRARIES})

elseif(CLR_CMAKE_HOST_UNIX)

Expand All @@ -100,7 +100,7 @@ elseif(CLR_CMAKE_HOST_UNIX)
# COREDBI_LIBRARIES is mentioned twice because ld is one pass linker and will not find symbols
# if they are defined after they are used. Having all libs twice makes sure that ld will actually
# find all symbols.
target_link_libraries(mscordbi ${COREDBI_LIBRARIES} ${COREDBI_LIBRARIES})
target_link_libraries(mscordbi PRIVATE ${COREDBI_LIBRARIES} ${COREDBI_LIBRARIES})

add_dependencies(mscordbi mscordaccore)

Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/dlls/mscorrc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include_directories("../../pal/prebuilt/corerror")

set(CLR_CMAKE_ENABLE_ASAN OFF)

add_definitions(-DFX_VER_INTERNALNAME_STR=mscorrc.dll)

if(CLR_CMAKE_HOST_WIN32)
Expand Down
24 changes: 5 additions & 19 deletions src/coreclr/enablesanitizers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ if [ $# -eq 0 ]; then
else
echo " cd $(dirname $0);. enablesanitizers.sh [options]; cd -"
fi
echo "Usage: [asan] [ubsan] [lsan] [all] [off] [clangx.y]"
echo " asan: optional argument to enable Address Sanitizer."
echo "Usage: [ubsan] [lsan] [all] [off] [clangx.y]"
echo " ubsan: optional argument to enable Undefined Behavior Sanitizer."
echo " lsan - optional argument to enable memory Leak Sanitizer."
echo " all - optional argument to enable asan, ubsan and lsan."
Expand All @@ -21,7 +20,6 @@ else
__ClangMajorVersion=3
__ClangMinorVersion=6

__EnableASan=0
__EnableUBSan=0
__EnableLSan=0
__TurnOff=0
Expand All @@ -32,18 +30,13 @@ else
do
lowerI="$(echo $i | tr "[:upper:]" "[:lower:]")"
case $lowerI in
asan)
__EnableASan=1
;;
ubsan)
__EnableUBSan=1
;;
lsan)
__EnableASan=1
__EnableLSan=1
;;
all)
__EnableASan=1
__EnableUBSan=1
__EnableLSan=1
;;
Expand Down Expand Up @@ -83,22 +76,16 @@ else
unset DEBUG_SANITIZERS
echo "Setting DEBUG_SANITIZERS="
else
# for now, specify alloc_dealloc_mismatch=0 as there are too many error reports that are not an issue.
# Also specify use_sigaltstack=0 as coreclr uses own alternate stack for signal handlers
ASAN_OPTIONS="symbolize=1 alloc_dealloc_mismatch=0 use_sigaltstack=0"
# when Clang 3.8 available, add: suppressions=$(readlink -f sanitizersuppressions.txt)
UBSAN_OPTIONS="print_stacktrace=1"

if [[ "$__EnableASan" == 1 ]]; then
__Options="$__Options asan"
fi
if [[ "$__EnableUBSan" == 1 ]]; then
if [ $__EnableUBSan == 1 ]; then
__Options="$__Options ubsan"
fi
if [[ "$__EnableLSan" == 1 ]]; then
ASAN_OPTIONS="$ASAN_OPTIONS detect_leaks=1"
if [ $__EnableLSan == 1 ]; then
LSAN_OPTIONS="detect_leaks=1"
else
ASAN_OPTIONS="$ASAN_OPTIONS detect_leaks=0"
LSAN_OPTIONS="detect_leaks=0"
fi

# passed to build.sh
Expand Down Expand Up @@ -128,7 +115,6 @@ else

unset __ClangMajorVersion
unset __ClangMinorVersion
unset __EnableASan
unset __EnableUBSan
unset __EnableLSan
unset __TurnOff
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ convert_to_absolute_path(GC_SOURCES ${GC_SOURCES})

add_library_clr(clrgc SHARED ${GC_SOURCES})
add_dependencies(clrgc eventing_headers)
target_link_libraries(clrgc ${GC_LINK_LIBRARIES})
target_link_libraries(clrgc PRIVATE ${GC_LINK_LIBRARIES})
install_clr(TARGETS clrgc DESTINATIONS . COMPONENT runtime)

if(CLR_CMAKE_HOST_UNIX)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/sample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ add_executable_clr(gcsample
)

if(CLR_CMAKE_TARGET_WIN32)
target_link_libraries(gcsample ${GC_LINK_LIBRARIES})
target_link_libraries(gcsample PRIVATE ${GC_LINK_LIBRARIES})
endif()
20 changes: 20 additions & 0 deletions src/coreclr/gcinfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,23 @@ create_gcinfo_lib(TARGET gcinfo_win_x86 OS win ARCH x86)
if (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
create_gcinfo_lib(TARGET gcinfo_unix_x86 OS unix ARCH x86)
endif (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)

set(CLR_CMAKE_ENABLE_ASAN OFF)

# For clrjit we need to build an exact targetted gcinfo instead of the universal one
if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_ARM)
create_gcinfo_lib(TARGET gcinfo_${TARGET_OS_NAME}_${ARCH_TARGET_NAME}_nosanitizer OS ${TARGET_OS_NAME} ARCH ${ARCH_TARGET_NAME})
endif()

if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
create_gcinfo_lib(TARGET gcinfo_universal_arm64_nosanitizer OS universal ARCH arm64)
create_gcinfo_lib(TARGET gcinfo_unix_x64_nosanitizer OS unix ARCH x64)
create_gcinfo_lib(TARGET gcinfo_win_x64_nosanitizer OS win ARCH x64)
endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)

create_gcinfo_lib(TARGET gcinfo_universal_arm_nosanitizer OS universal ARCH arm)
create_gcinfo_lib(TARGET gcinfo_win_x86_nosanitizer OS win ARCH x86)

if (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
create_gcinfo_lib(TARGET gcinfo_unix_x86_nosanitizer OS unix ARCH x86)
endif (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
7 changes: 4 additions & 3 deletions src/coreclr/hosts/corerun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ add_executable_clr(corerun

if(CLR_CMAKE_HOST_WIN32)
target_link_libraries(corerun
PRIVATE
advapi32.lib
oleaut32.lib
uuid.lib
Expand All @@ -27,13 +28,13 @@ if(CLR_CMAKE_HOST_WIN32)
${STATIC_MT_VCRT_LIB}
)
else(CLR_CMAKE_HOST_WIN32)
target_link_libraries(corerun ${CMAKE_DL_LIBS})
target_link_libraries(corerun PRIVATE ${CMAKE_DL_LIBS})
# Required to expose symbols for global symbol discovery
target_link_libraries(corerun -rdynamic)
target_link_libraries(corerun PRIVATE -rdynamic)

# Android implements pthread natively
if(NOT CLR_CMAKE_TARGET_ANDROID)
target_link_libraries(corerun pthread)
target_link_libraries(corerun PRIVATE pthread)
endif()
endif(CLR_CMAKE_HOST_WIN32)

Expand Down
Loading