# Licensed under the MIT license. See LICENSE file in the project root for full license information.
# Verify minimum required version
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.6.2)
if(CMAKE_VERSION VERSION_EQUAL 3.0 OR CMAKE_VERSION VERSION_GREATER 3.0)
cmake_policy(SET CMP0042 NEW)
# Set the project name
project(diagnostics)
-# Include cmake functions
-include(functions.cmake)
+# include shared compiler configs
+include(eng/native/configurepaths.cmake)
+include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake)
+
+# override some global configs
+if (MSVC)
+ add_compile_options(/wd4960 /wd4961 /wd4603 /wd4627 /wd4838 /wd4456 /wd4457 /wd4458 /wd4459 /wd4091 /we4640)
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/EHsc>)
+ add_compile_options($<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/MT>)
+ add_compile_options($<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:/MTd>)
+else (MSVC)
+ add_compile_options(-Wno-unused-parameter)
+ add_compile_options(-Wno-unused-variable)
+ add_compile_options(-Wno-implicit-fallthrough)
+ add_compile_options(-fvisibility=default)
+endif (MSVC)
+
+# Register the default component
+set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME diagnostics)
+add_component(diagnostics)
if (WIN32)
message(STATUS "VS_PLATFORM_TOOLSET is ${CMAKE_VS_PLATFORM_TOOLSET}")
set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
-# Where the version source file for xplat is generated
-set(VERSION_FILE_PATH "${CMAKE_BINARY_DIR}/version.cpp")
+if (NOT WIN32)
+ # Drop the static scope for SOS, so it's available outside the
+ # compilation unit for external linkage; see extern declaration
+ # in SOS sources.
+ file(READ "${VERSION_FILE_PATH}" VERSION_FILE_CONTENTS)
+ string(REPLACE "static char" "char" VERSION_LINE_WITHOUT_STATIC "${VERSION_FILE_CONTENTS}")
+ file(WRITE "${VERSION_FILE_PATH}" "${VERSION_LINE_WITHOUT_STATIC}")
+endif (NOT WIN32)
# Where _version.h for Windows is generated
if (WIN32)
-include_directories("${CMAKE_BINARY_DIR}")
+include_directories(${CLR_ARTIFACTS_OBJ_DIR})
endif (WIN32)
set(CORECLR_SET_RPATH ON)
OPTION(CLR_CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF)
OPTION(CLR_CMAKE_WARNINGS_ARE_ERRORS "Warnings are errors" ON)
-# Ensure other tools are present
-if (WIN32)
- if(CLR_CMAKE_HOST_ARCH STREQUAL arm)
-
- # Confirm that Windows SDK is present
- if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION OR CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION STREQUAL "" )
- message(FATAL_ERROR "Windows SDK is required for the Arm32 build.")
- else()
- message("Using Windows SDK version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
- endif()
-
- # Explicitly specify the assembler to be used for Arm32 compile
- if($ENV{__VSVersion} STREQUAL "vs2015")
- file(TO_CMAKE_PATH "$ENV{VCINSTALLDIR}\\bin\\x86_arm\\armasm.exe" CMAKE_ASM_COMPILER)
- else()
- file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm\\armasm.exe" CMAKE_ASM_COMPILER)
- endif()
-
- set(CMAKE_ASM_MASM_COMPILER ${CMAKE_ASM_COMPILER})
- message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}")
-
- # Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly
- # use ml[64].exe as the assembler.
- enable_language(ASM)
- else()
- enable_language(ASM_MASM)
- endif()
-
- # Ensure that MC is present
- find_program(MC mc)
- if (MC STREQUAL "MC-NOTFOUND")
- message(FATAL_ERROR "MC not found")
- endif()
-
- if (CLR_CMAKE_HOST_ARCH STREQUAL arm64)
- # CMAKE_CXX_COMPILER will default to the compiler installed with
- # Visual studio. Overwrite it to the compiler on the path.
- # TODO, remove when cmake generator supports Arm64 as a target.
- find_program(PATH_CXX_COMPILER cl)
- set(CMAKE_CXX_COMPILER ${PATH_CXX_COMPILER})
- message("Overwriting the CMAKE_CXX_COMPILER.")
- message(CMAKE_CXX_COMPILER found:${CMAKE_CXX_COMPILER})
- endif()
-
-else (WIN32)
- enable_language(ASM)
-
- # Ensure that awk is present
- find_program(AWK awk)
- if (AWK STREQUAL "AWK-NOTFOUND")
- message(FATAL_ERROR "AWK not found")
- endif()
-
- # Try to locate the paxctl tool. Failure to find it is not fatal,
- # but the generated executables won't work on a system where PAX is set
- # to prevent applications to create executable memory mappings.
- find_program(PAXCTL paxctl)
-
- if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
-
- # Ensure that dsymutil and strip are present
- find_program(DSYMUTIL dsymutil)
- if (DSYMUTIL STREQUAL "DSYMUTIL-NOTFOUND")
- message(FATAL_ERROR "dsymutil not found")
- endif()
-
- find_program(STRIP strip)
- if (STRIP STREQUAL "STRIP-NOTFOUND")
- message(FATAL_ERROR "strip not found")
- endif()
-
- else (CMAKE_SYSTEM_NAME STREQUAL Darwin)
-
- # Ensure that objcopy is present
- if (CLR_UNIX_CROSS_BUILD AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
- if (CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l OR CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm OR CMAKE_SYSTEM_PROCESSOR STREQUAL mips64)
- find_program(OBJCOPY ${TOOLCHAIN}-objcopy)
- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
- find_program(OBJCOPY objcopy)
- else()
- clr_unknown_arch()
- endif()
- else()
- find_program(OBJCOPY objcopy)
- endif()
-
- if (OBJCOPY STREQUAL "OBJCOPY-NOTFOUND")
- message(FATAL_ERROR "objcopy not found")
- endif()
-
- endif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
-endif(WIN32)
-
-#----------------------------------------
-# Detect and set platform variable names
-# - for non-windows build platform & architecture is detected using inbuilt CMAKE variables and cross target component configure
-# - for windows we use the passed in parameter to CMAKE to determine build arch
-#----------------------------------------
-if(CMAKE_SYSTEM_NAME STREQUAL Linux)
- set(CLR_CMAKE_PLATFORM_UNIX 1)
- if(CLR_CROSS_COMPONENTS_BUILD)
- # CMAKE_HOST_SYSTEM_PROCESSOR returns the value of `uname -p` on host.
- if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL amd64)
- if(CLR_CMAKE_TARGET_ARCH STREQUAL "arm")
- set(CLR_CMAKE_PLATFORM_UNIX_X86 1)
- else()
- set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
- endif()
- elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL i686)
- set(CLR_CMAKE_PLATFORM_UNIX_X86 1)
- else()
- clr_unknown_arch()
- endif()
- else()
- # CMAKE_SYSTEM_PROCESSOR returns the value of `uname -p` on target.
- # For the AMD/Intel 64bit architecture two different strings are common.
- # Linux and Darwin identify it as "x86_64" while FreeBSD and netbsd uses the
- # "amd64" string. Accept either of the two here.
- if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
- set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
- set(CLR_CMAKE_PLATFORM_UNIX_ARM 1)
- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
- set(CLR_CMAKE_PLATFORM_UNIX_ARM 1)
- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
- set(CLR_CMAKE_PLATFORM_UNIX_ARM64 1)
- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL mips64)
- set(CLR_CMAKE_PLATFORM_UNIX_MIPS64 1)
- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
- set(CLR_CMAKE_PLATFORM_UNIX_X86 1)
- else()
- clr_unknown_arch()
- endif()
- endif()
- set(CLR_CMAKE_PLATFORM_LINUX 1)
-
- # Detect Linux ID
- if(DEFINED CLR_CMAKE_LINUX_ID)
- if(CLR_CMAKE_LINUX_ID STREQUAL ubuntu)
- set(CLR_CMAKE_TARGET_UBUNTU_LINUX 1)
- elseif(CLR_CMAKE_LINUX_ID STREQUAL tizen)
- set(CLR_CMAKE_TARGET_TIZEN_LINUX 1)
- elseif(CLR_CMAKE_LINUX_ID STREQUAL alpine)
- set(CLR_CMAKE_PLATFORM_ALPINE_LINUX 1)
- endif()
- if(CLR_CMAKE_LINUX_ID STREQUAL ubuntu)
- set(CLR_CMAKE_PLATFORM_UBUNTU_LINUX 1)
- endif()
- endif(DEFINED CLR_CMAKE_LINUX_ID)
-endif(CMAKE_SYSTEM_NAME STREQUAL Linux)
-
-if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
- set(CLR_CMAKE_PLATFORM_UNIX 1)
- if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
- set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
- elseif(CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
- set(CLR_CMAKE_PLATFORM_UNIX_ARM64 1)
- else()
- message(FATAL_ERROR "CMAKE_OSX_ARCHITECTURES:'${CMAKE_OSX_ARCHITECTURES}'")
- clr_unknown_arch()
- endif()
- set(CLR_CMAKE_PLATFORM_DARWIN 1)
- if(CMAKE_VERSION VERSION_LESS "3.4.0")
- set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> -o <OBJECT> -c <SOURCE>")
- else()
- set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> <INCLUDES> -o <OBJECT> -c <SOURCE>")
- endif(CMAKE_VERSION VERSION_LESS "3.4.0")
-endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
-
-if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
- set(CLR_CMAKE_PLATFORM_UNIX 1)
- set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
- set(CLR_CMAKE_PLATFORM_FREEBSD 1)
-endif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
-
-if(CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
- set(CLR_CMAKE_PLATFORM_UNIX 1)
- set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
- set(CLR_CMAKE_PLATFORM_OPENBSD 1)
-endif(CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
-
-if(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
- set(CLR_CMAKE_PLATFORM_UNIX 1)
- set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
- set(CLR_CMAKE_PLATFORM_NETBSD 1)
-endif(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
-
-if(CMAKE_SYSTEM_NAME STREQUAL SunOS)
- set(CLR_CMAKE_PLATFORM_UNIX 1)
- EXECUTE_PROCESS(
- COMMAND isainfo -n
- OUTPUT_VARIABLE SUNOS_NATIVE_INSTRUCTION_SET
- )
- if(SUNOS_NATIVE_INSTRUCTION_SET MATCHES "amd64")
- set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
- set(CMAKE_SYSTEM_PROCESSOR "amd64")
- else()
- clr_unknown_arch()
- endif()
- set(CLR_CMAKE_PLATFORM_SUNOS 1)
-endif(CMAKE_SYSTEM_NAME STREQUAL SunOS)
-
-#--------------------------------------------
-# This repo builds two set of binaries
-# 1. binaries which execute on target arch machine
-# - for such binaries host architecture & target architecture are same
-# - eg. coreclr.dll
-# 2. binaries which execute on host machine but target another architecture
-# - host architecture is different from target architecture
-# - eg. crossgen.exe - runs on x64 machine and generates nis targeting arm64
-# - for complete list of such binaries refer to file crosscomponents.cmake
-#-------------------------------------------------------------
-# Set HOST architecture variables
-if(CLR_CMAKE_PLATFORM_UNIX_ARM)
- set(CLR_CMAKE_PLATFORM_ARCH_ARM 1)
- set(CLR_CMAKE_HOST_ARCH "arm")
-elseif(CLR_CMAKE_PLATFORM_UNIX_ARM64)
- set(CLR_CMAKE_PLATFORM_ARCH_ARM64 1)
- set(CLR_CMAKE_HOST_ARCH "arm64")
-elseif(CLR_CMAKE_PLATFORM_UNIX_AMD64)
- set(CLR_CMAKE_PLATFORM_ARCH_AMD64 1)
- set(CLR_CMAKE_HOST_ARCH "x64")
-elseif(CLR_CMAKE_PLATFORM_UNIX_X86)
- set(CLR_CMAKE_PLATFORM_ARCH_I386 1)
- set(CLR_CMAKE_HOST_ARCH "x86")
-elseif(CLR_CMAKE_PLATFORM_UNIX_MIPS64)
- set(CLR_CMAKE_PLATFORM_ARCH_MIPS64 1)
- set(CLR_CMAKE_HOST_ARCH "mips64")
-elseif(WIN32)
- # CLR_CMAKE_HOST_ARCH is passed in as param to cmake
- if (CLR_CMAKE_HOST_ARCH STREQUAL x64)
- set(CLR_CMAKE_PLATFORM_ARCH_AMD64 1)
- elseif(CLR_CMAKE_HOST_ARCH STREQUAL x86)
- set(CLR_CMAKE_PLATFORM_ARCH_I386 1)
- elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm)
- set(CLR_CMAKE_PLATFORM_ARCH_ARM 1)
- elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm64)
- set(CLR_CMAKE_PLATFORM_ARCH_ARM64 1)
- else()
- clr_unknown_arch()
- endif()
-endif()
-
-# Set TARGET architecture variables
-# Target arch will be a cmake param (optional) for both windows as well as non-windows build
-# if target arch is not specified then host & target are same
-if(NOT DEFINED CLR_CMAKE_TARGET_ARCH OR CLR_CMAKE_TARGET_ARCH STREQUAL "" )
- set(CLR_CMAKE_TARGET_ARCH ${CLR_CMAKE_HOST_ARCH})
-endif()
-
-# Set target architecture variables
-if (CLR_CMAKE_TARGET_ARCH STREQUAL x64)
- set(CLR_CMAKE_TARGET_ARCH_AMD64 1)
- elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86)
- set(CLR_CMAKE_TARGET_ARCH_I386 1)
- elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm64)
- set(CLR_CMAKE_TARGET_ARCH_ARM64 1)
- elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm)
- set(CLR_CMAKE_TARGET_ARCH_ARM 1)
- elseif(CLR_CMAKE_TARGET_ARCH STREQUAL mips64)
- set(CLR_CMAKE_TARGET_ARCH_MIPS64 1)
- else()
- clr_unknown_arch()
-endif()
-
-# check if host & target arch combination are valid
-if(NOT(CLR_CMAKE_TARGET_ARCH STREQUAL CLR_CMAKE_HOST_ARCH))
- if(NOT((CLR_CMAKE_PLATFORM_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_ARM64) OR (CLR_CMAKE_PLATFORM_ARCH_I386 AND CLR_CMAKE_TARGET_ARCH_ARM)))
- message(FATAL_ERROR "Invalid host and target arch combination")
- endif()
-endif()
-
-#-----------------------------------------------------
-# Initialize Cmake compiler flags and other variables
-#-----------------------------------------------------
-
-if (CMAKE_CONFIGURATION_TYPES) # multi-configuration generator?
- set(CMAKE_CONFIGURATION_TYPES "Debug;Checked;Release;RelWithDebInfo" CACHE STRING "" FORCE)
-endif (CMAKE_CONFIGURATION_TYPES)
-
-set(CMAKE_C_FLAGS_CHECKED ${CLR_C_FLAGS_CHECKED_INIT} CACHE STRING "Flags used by the compiler during checked builds.")
-set(CMAKE_CXX_FLAGS_CHECKED ${CLR_CXX_FLAGS_CHECKED_INIT} CACHE STRING "Flags used by the compiler during checked builds.")
-set(CMAKE_EXE_LINKER_FLAGS_CHECKED "")
-set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "")
-
-set(CMAKE_CXX_STANDARD_LIBRARIES "") # do not link against standard win32 libs i.e. kernel32, uuid, user32, etc.
-
-if (WIN32)
- # For multi-configuration toolset (as Visual Studio)
- # set the different configuration defines.
- foreach (Config DEBUG CHECKED RELEASE RELWITHDEBINFO)
- foreach (Definition IN LISTS CLR_DEFINES_${Config}_INIT)
- set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:${Config}>:${Definition}>)
- endforeach (Definition)
- endforeach (Config)
-
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /GUARD:CF")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /GUARD:CF")
-
- # Linker flags
- #
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO") #Do not create Side-by-Side Assembly Manifest
-
- if (CLR_CMAKE_PLATFORM_ARCH_ARM)
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,6.02") #windows subsystem - arm minimum is 6.02
- elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,6.03") #windows subsystem - arm64 minimum is 6.03
- else ()
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,6.01") #windows subsystem
- endif ()
-
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE") # can handle addresses larger than 2 gigabytes
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NXCOMPAT") #Compatible with Data Execution Prevention
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DYNAMICBASE") #Use address space layout randomization
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /PDBCOMPRESS") #shrink pdb size
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG")
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /IGNORE:4197,4013,4254,4070,4221")
-
- set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4221")
-
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /PDBCOMPRESS")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1572864")
-
- # Temporarily disable incremental link due to incremental linking CFG bug crashing crossgen.
- # See https://github.com/dotnet/coreclr/issues/12592
- # This has been fixed in VS 2017 Update 5 but we're keeping this around until everyone is off
- # the versions that have the bug. The bug manifests itself as a bad crash.
- set(NO_INCREMENTAL_LINKER_FLAGS "/INCREMENTAL:NO")
-
- # Debug build specific flags
- set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/NOVCFEATURE ${NO_INCREMENTAL_LINKER_FLAGS}")
- set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${NO_INCREMENTAL_LINKER_FLAGS}")
-
- # Checked build specific flags
- set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "${CMAKE_SHARED_LINKER_FLAGS_CHECKED} /OPT:REF /OPT:NOICF /NOVCFEATURE ${NO_INCREMENTAL_LINKER_FLAGS}")
- set(CMAKE_STATIC_LINKER_FLAGS_CHECKED "${CMAKE_STATIC_LINKER_FLAGS_CHECKED}")
- set(CMAKE_EXE_LINKER_FLAGS_CHECKED "${CMAKE_EXE_LINKER_FLAGS_CHECKED} /OPT:REF /OPT:NOICF ${NO_INCREMENTAL_LINKER_FLAGS}")
-
- # Release build specific flags
- set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS}")
- set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")
- set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS}")
-
- # ReleaseWithDebugInfo build specific flags
- set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS}")
- set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
- set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS}")
-
- # Temporary until cmake has VS generators for arm64
- if(CLR_CMAKE_PLATFORM_ARCH_ARM64)
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /machine:arm64")
- set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /machine:arm64")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /machine:arm64")
- endif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
-
- # Force uCRT to be dynamically linked for Release build
- set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
- set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
- set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
- set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
-
-elseif (CLR_CMAKE_PLATFORM_UNIX)
- # Set the values to display when interactively configuring CMAKE_BUILD_TYPE
- set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "DEBUG;CHECKED;RELEASE;RELWITHDEBINFO")
-
- # Use uppercase CMAKE_BUILD_TYPE for the string comparisons below
- string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_CMAKE_BUILD_TYPE)
-
- # For single-configuration toolset
- # set the different configuration defines.
- if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
- # First DEBUG
- set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS ${CLR_DEFINES_DEBUG_INIT})
- elseif (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
- # Then CHECKED
- set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS ${CLR_DEFINES_CHECKED_INIT})
- elseif (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE)
- # Then RELEASE
- set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS ${CLR_DEFINES_RELEASE_INIT})
- elseif (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
- # And then RELWITHDEBINFO
- set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${CLR_DEFINES_RELWITHDEBINFO_INIT})
- else ()
- message(FATAL_ERROR "Unknown build type! Set CMAKE_BUILD_TYPE to DEBUG, CHECKED, RELEASE, or RELWITHDEBINFO!")
- endif ()
-
- # 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))
- set(CLR_SANITIZE_CXX_FLAGS "${CLR_SANITIZE_CXX_FLAGS} -fsanitize-blacklist=${CMAKE_CURRENT_SOURCE_DIR}/sanitizerblacklist.txt -fsanitize=")
- set(CLR_SANITIZE_LINK_FLAGS "${CLR_SANITIZE_LINK_FLAGS} -fsanitize=")
- if (${__ASAN_POS} GREATER -1)
- 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)
- set(CLR_SANITIZE_CXX_FLAGS "${CLR_SANITIZE_CXX_FLAGS}bool,bounds,enum,float-cast-overflow,float-divide-by-zero,function,integer,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,unreachable,vla-bound,vptr")
- set(CLR_SANITIZE_LINK_FLAGS "${CLR_SANITIZE_LINK_FLAGS}undefined")
- message("Undefined Behavior Sanitizer (ubsan) enabled")
- endif ()
-
- # -fdata-sections -ffunction-sections: each function has own section instead of one per .o file (needed for --gc-sections)
- # -fPIC: enable Position Independent Code normally just for shared libraries but required when linking with address sanitizer
- # -O1: optimization level used instead of -O0 to avoid compile error "invalid operand for inline asm constraint"
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CLR_SANITIZE_CXX_FLAGS} -fdata-sections -ffunction-sections -fPIC -O1")
- set(CMAKE_CXX_FLAGS_CHECKED "${CMAKE_CXX_FLAGS_CHECKED} ${CLR_SANITIZE_CXX_FLAGS} -fdata-sections -ffunction-sections -fPIC -O1")
-
- set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${CLR_SANITIZE_LINK_FLAGS}")
- set(CMAKE_EXE_LINKER_FLAGS_CHECKED "${CMAKE_EXE_LINKER_FLAGS_CHECKED} ${CLR_SANITIZE_LINK_FLAGS}")
-
- # -Wl and --gc-sections: drop unused sections\functions (similar to Windows /Gy function-level-linking)
- set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${CLR_SANITIZE_LINK_FLAGS} -Wl,--gc-sections")
- set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "${CMAKE_SHARED_LINKER_FLAGS_CHECKED} ${CLR_SANITIZE_LINK_FLAGS} -Wl,--gc-sections")
- endif ()
- endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
-endif(WIN32)
-
-# CLR_ADDITIONAL_LINKER_FLAGS - used for passing additional arguments to linker
-# CLR_ADDITIONAL_COMPILER_OPTIONS - used for passing additional arguments to compiler
-
-if(CLR_CMAKE_PLATFORM_UNIX)
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CLR_ADDITIONAL_LINKER_FLAGS}")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CLR_ADDITIONAL_LINKER_FLAGS}" )
- add_compile_options(${CLR_ADDITIONAL_COMPILER_OPTIONS})
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
-if(CLR_CMAKE_PLATFORM_LINUX)
- set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack")
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=sha1")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1")
-endif(CLR_CMAKE_PLATFORM_LINUX)
-
#------------------------------------
# Definitions (for platform)
#-----------------------------------
-if (CLR_CMAKE_PLATFORM_ARCH_AMD64)
+if (CLR_CMAKE_HOST_ARCH_AMD64)
add_definitions(-D_AMD64_)
add_definitions(-D_WIN64)
add_definitions(-DAMD64)
add_definitions(-DBIT64=1)
-elseif (CLR_CMAKE_PLATFORM_ARCH_I386)
+elseif (CLR_CMAKE_HOST_ARCH_I386)
add_definitions(-D_X86_)
-elseif (CLR_CMAKE_PLATFORM_ARCH_ARM)
+elseif (CLR_CMAKE_HOST_ARCH_ARM)
add_definitions(-D_ARM_)
add_definitions(-DARM)
-elseif (CLR_CMAKE_PLATFORM_ARCH_ARM64)
+elseif (CLR_CMAKE_HOST_ARCH_ARM64)
add_definitions(-D_ARM64_)
add_definitions(-DARM64)
add_definitions(-D_WIN64)
add_definitions(-DBIT64=1)
-elseif (CLR_CMAKE_PLATFORM_ARCH_MIPS64)
+elseif (CLR_CMAKE_HOST_ARCH_MIPS64)
add_definitions(-D_MIPS64_)
add_definitions(-DMIPS64)
add_definitions(-D_WIN64)
clr_unknown_arch()
endif ()
-if (CLR_CMAKE_PLATFORM_UNIX)
- if(CLR_CMAKE_PLATFORM_LINUX)
- if(CLR_CMAKE_PLATFORM_UNIX_AMD64)
- message("Detected Linux x86_64")
- add_definitions(-DLINUX64)
- elseif(CLR_CMAKE_PLATFORM_UNIX_ARM)
- message("Detected Linux ARM")
- add_definitions(-DLINUX32)
- elseif(CLR_CMAKE_PLATFORM_UNIX_ARM64)
- message("Detected Linux ARM64")
- add_definitions(-DLINUX64)
- elseif(CLR_CMAKE_PLATFORM_UNIX_X86)
- message("Detected Linux i686")
- add_definitions(-DLINUX32)
- elseif(CLR_CMAKE_PLATFORM_UNIX_MIPS64)
- message("Detected Linux MIPS64")
- add_definitions(-DLINUX64)
- else()
- clr_unknown_arch()
- endif()
- endif(CLR_CMAKE_PLATFORM_LINUX)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
-if (CLR_CMAKE_PLATFORM_UNIX)
- add_definitions(-DPLATFORM_UNIX=1)
-
- if(CLR_CMAKE_PLATFORM_DARWIN)
- message("Detected OSX x86_64")
- endif(CLR_CMAKE_PLATFORM_DARWIN)
-
- if(CLR_CMAKE_PLATFORM_FREEBSD)
- message("Detected FreeBSD amd64")
- endif(CLR_CMAKE_PLATFORM_FREEBSD)
-
- if(CLR_CMAKE_PLATFORM_NETBSD)
- message("Detected NetBSD amd64")
- endif(CLR_CMAKE_PLATFORM_NETBSD)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
-if (WIN32)
- # Define the CRT lib references that link into Desktop imports
- set(STATIC_MT_CRT_LIB "libcmt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
- set(STATIC_MT_VCRT_LIB "libvcruntime$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
- set(STATIC_MT_CPP_LIB "libcpmt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
-endif(WIN32)
-
-# Architecture specific files folder name
-if (CLR_CMAKE_TARGET_ARCH_AMD64)
- set(ARCH_SOURCES_DIR amd64)
-elseif (CLR_CMAKE_TARGET_ARCH_ARM64)
- set(ARCH_SOURCES_DIR arm64)
-elseif (CLR_CMAKE_TARGET_ARCH_ARM)
- set(ARCH_SOURCES_DIR arm)
-elseif (CLR_CMAKE_TARGET_ARCH_I386)
- set(ARCH_SOURCES_DIR i386)
-elseif (CLR_CMAKE_TARGET_ARCH_MIPS64)
- set(ARCH_SOURCES_DIR mips64)
-else ()
- clr_unknown_arch()
-endif ()
-
if (CLR_CMAKE_TARGET_ARCH_AMD64)
- if (CLR_CMAKE_PLATFORM_UNIX)
+ if (CLR_CMAKE_HOST_UNIX)
add_definitions(-DDBG_TARGET_AMD64_UNIX)
endif()
add_definitions(-D_TARGET_64BIT_=1)
add_definitions(-DDBG_TARGET_AMD64=1)
add_definitions(-DDBG_TARGET_WIN64=1)
elseif (CLR_CMAKE_TARGET_ARCH_ARM64)
- if (CLR_CMAKE_PLATFORM_UNIX)
+ if (CLR_CMAKE_HOST_UNIX)
add_definitions(-DDBG_TARGET_ARM64_UNIX)
endif()
add_definitions(-D_TARGET_ARM64_=1)
add_definitions(-DDBG_TARGET_WIN64=1)
add_definitions(-DFEATURE_MULTIREG_RETURN)
elseif (CLR_CMAKE_TARGET_ARCH_ARM)
- if (CLR_CMAKE_PLATFORM_UNIX)
+ if (CLR_CMAKE_HOST_UNIX)
add_definitions(-DDBG_TARGET_ARM_UNIX)
elseif (WIN32 AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
# Set this to ensure we can use Arm SDK for Desktop binary linkage when doing native (Arm32) build
add_definitions(-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1)
add_definitions(-D_ARM_WORKAROUND_)
- endif (CLR_CMAKE_PLATFORM_UNIX)
+ endif (CLR_CMAKE_HOST_UNIX)
add_definitions(-D_TARGET_ARM_=1)
add_definitions(-DDBG_TARGET_32BIT=1)
+ add_definitions(-DDBG_TARGET_32BIT=1)
add_definitions(-DDBG_TARGET_ARM=1)
elseif (CLR_CMAKE_TARGET_ARCH_I386)
add_definitions(-D_TARGET_X86_=1)
add_definitions(-DDBG_TARGET_32BIT=1)
+ add_definitions(-DDBG_TARGET_32BIT=1)
add_definitions(-DDBG_TARGET_X86=1)
elseif (CLR_CMAKE_TARGET_ARCH_MIPS64)
add_definitions(-DDBG_TARGET_MIPS64_UNIX)
add_definitions(-D_TARGET_MIPS64_=1)
add_definitions(-D_TARGET_64BIT_=1)
- add_definitions(-DDBG_TARGET_64BIT=1)
add_definitions(-DDBG_TARGET_MIPS64=1)
+ add_definitions(-DDBG_TARGET_64BIT=1)
add_definitions(-DDBG_TARGET_WIN64=1)
add_definitions(-DFEATURE_MULTIREG_RETURN)
else ()
add_definitions(-DFEATURE_CORESYSTEM)
-if(CLR_CMAKE_PLATFORM_UNIX)
+if(CLR_CMAKE_HOST_UNIX)
+ add_definitions(-DPLATFORM_UNIX=1)
add_definitions(-DFEATURE_PAL)
add_definitions(-DFEATURE_PAL_ANSI)
-endif(CLR_CMAKE_PLATFORM_UNIX)
+endif(CLR_CMAKE_HOST_UNIX)
if(WIN32)
add_definitions(-DFEATURE_COMINTEROP)
add_definitions(-DFEATURE_PERFTRACING=1)
endif(FEATURE_EVENT_TRACE)
-if(CLR_CMAKE_PLATFORM_UNIX_AMD64)
+if(CLR_CMAKE_HOST_UNIX_AMD64)
add_definitions(-DFEATURE_MULTIREG_RETURN)
-endif (CLR_CMAKE_PLATFORM_UNIX_AMD64)
+endif (CLR_CMAKE_HOST_UNIX_AMD64)
-if(CLR_CMAKE_PLATFORM_UNIX AND CLR_CMAKE_TARGET_ARCH_AMD64)
+if(CLR_CMAKE_HOST_UNIX AND CLR_CMAKE_TARGET_ARCH_AMD64)
add_definitions(-DUNIX_AMD64_ABI)
-endif(CLR_CMAKE_PLATFORM_UNIX AND CLR_CMAKE_TARGET_ARCH_AMD64)
-
-#--------------------------------------
-# Compile Options
-#--------------------------------------
-include(compileoptions.cmake)
+endif(CLR_CMAKE_HOST_UNIX AND CLR_CMAKE_TARGET_ARCH_AMD64)
#-----------------------------------------
# Native Projects
</solution>
<packageSources>
<clear />
+ <!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
+ <!-- Begin: Package sources from dotnet-aspnetcore -->
+ <!-- End: Package sources from dotnet-aspnetcore -->
+ <!-- Begin: Package sources from dotnet-runtime -->
+ <add key="darc-pub-dotnet-runtime-fd61aef" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-fd61aefc/nuget/v3/index.json" />
+ <!-- End: Package sources from dotnet-runtime -->
+ <!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
<!-- Feeds used in Maestro/Arcade publishing -->
<add key="dotnet6" value="https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet6/nuget/v3/index.json" />
<add key="dotnet6-transport" value="https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet6-transport/nuget/v3/index.json" />
.NET Core Diagnostics Repo
==========================
-This repository contains the source code for various .NET Core runtime diagnostic tools. It currently contains SOS, the managed portion of SOS, the lldb SOS plugin and various global diagnostic tools. The goals of this repo is to build SOS and the lldb SOS plugin for the portable (glibc based) Linux platform (Centos 7) and the platforms not supported by the portable (musl based) build (Centos 6, Alpine, and macOS) and to test across various indexes in a very large matrix: OSs/distros (Centos 6/7, Ubuntu, Alpine, Fedora, Debian, RHEL 7.2), architectures (x64, x86, arm, arm64), lldb versions (3.9 to 9.0) and .NET Core versions (2.1, 3.1, 5.0.x).
+This repository contains the source code for various .NET Core runtime diagnostic tools. It currently contains SOS, the managed portion of SOS, the lldb SOS plugin and various global diagnostic tools. The goals of this repo is to build SOS and the lldb SOS plugin for the portable (glibc based) Linux platform (Centos 7) and the platforms not supported by the portable (musl based) build (Centos 6, Alpine, and macOS) and to test across various indexes in a very large matrix: OSs/distros (Centos 6/7, Ubuntu, Alpine, Fedora, Debian, RHEL 7.2), architectures (x64, x86, arm, arm64), lldb versions (3.9 to 9.0) and .NET Core (all in-development and supported major versions).
Another goal to make it easier to obtain a version of lldb (currently 3.9) with scripts and documentation for platforms/distros like Centos, Alpine, Fedora, etc. that by default provide really old versions.
+++ /dev/null
-# Copyright (c) .NET Foundation and contributors. All rights reserved.
-# Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-if (CLR_CMAKE_PLATFORM_UNIX)
- # Disable frame pointer optimizations so profilers can get better call stacks
- add_compile_options(-fno-omit-frame-pointer)
-
- # The -fms-extensions enable the stuff like __if_exists, __declspec(uuid()), etc.
- add_compile_options(-fms-extensions )
- #-fms-compatibility Enable full Microsoft Visual C++ compatibility
- #-fms-extensions Accept some non-standard constructs supported by the Microsoft compiler
-
- # Make signed arithmetic overflow of addition, subtraction, and multiplication wrap around
- # using twos-complement representation (this is normally undefined according to the C++ spec).
- add_compile_options(-fwrapv)
-
- if(CLR_CMAKE_PLATFORM_DARWIN)
- # We cannot enable "stack-protector-strong" on OS X due to a bug in clang compiler (current version 7.0.2)
- add_compile_options(-fstack-protector)
- if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
- add_compile_options(-arch x86_64)
- elseif(CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
- add_compile_options(-arch arm64)
- else()
- clr_unknown_arch()
- endif()
- else()
- add_compile_options(-fstack-protector-strong)
- endif(CLR_CMAKE_PLATFORM_DARWIN)
-
- add_definitions(-DDISABLE_CONTRACTS)
- # The -ferror-limit is helpful during the porting, it makes sure the compiler doesn't stop
- # after hitting just about 20 errors.
- add_compile_options(-ferror-limit=4096)
-
- if (CLR_CMAKE_WARNINGS_ARE_ERRORS)
- # All warnings that are not explicitly disabled are reported as errors
- add_compile_options(-Werror)
- endif(CLR_CMAKE_WARNINGS_ARE_ERRORS)
-
- # Disabled warnings
- add_compile_options(-Wno-unused-private-field)
- add_compile_options(-Wno-unused-variable)
- # Explicit constructor calls are not supported by clang (this->ClassName::ClassName())
- add_compile_options(-Wno-microsoft)
- # This warning is caused by comparing 'this' to NULL
- add_compile_options(-Wno-tautological-compare)
- # There are constants of type BOOL used in a condition. But BOOL is defined as int
- # and so the compiler thinks that there is a mistake.
- add_compile_options(-Wno-constant-logical-operand)
- # We use pshpack1/2/4/8.h and poppack.h headers to set and restore packing. However
- # clang 6.0 complains when the packing change lifetime is not contained within
- # a header file.
- add_compile_options(-Wno-pragma-pack)
-
- add_compile_options(-Wno-unknown-warning-option)
-
- #These seem to indicate real issues
- add_compile_options(-Wno-invalid-offsetof)
- # The following warning indicates that an attribute __attribute__((__ms_struct__)) was applied
- # to a struct or a class that has virtual members or a base class. In that case, clang
- # may not generate the same object layout as MSVC.
- add_compile_options(-Wno-incompatible-ms-struct)
-
- # Some architectures (e.g., ARM) assume char type is unsigned while CoreCLR assumes char is signed
- # as x64 does. It has been causing issues in ARM (https://github.com/dotnet/coreclr/issues/4746)
- add_compile_options(-fsigned-char)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
-if(CLR_CMAKE_PLATFORM_UNIX_ARM)
- # Because we don't use CMAKE_C_COMPILER/CMAKE_CXX_COMPILER to use clang
- # we have to set the triple by adding a compiler argument
- add_compile_options(-mthumb)
- add_compile_options(-mfpu=vfpv3)
- add_compile_options(-march=armv7-a)
- if(ARM_SOFTFP)
- add_definitions(-DARM_SOFTFP)
- add_compile_options(-mfloat-abi=softfp)
- endif(ARM_SOFTFP)
-endif(CLR_CMAKE_PLATFORM_UNIX_ARM)
-
-if(CLR_CMAKE_PLATFORM_FREEBSD)
- add_compile_options(-Wno-macro-redefined)
- add_compile_options(-Wno-pointer-to-int-cast)
-endif(CLR_CMAKE_PLATFORM_FREEBSD)
-
-if (WIN32)
- # Compile options for targeting windows
-
- # The following options are set by the razzle build
- add_compile_options(/TP) # compile all files as C++
- add_compile_options(/d2Zi+) # make optimized builds debugging easier
- add_compile_options(/nologo) # Suppress Startup Banner
- add_compile_options(/W3) # set warning level to 3
- add_compile_options(/WX) # treat warnings as errors
- add_compile_options(/Oi) # enable intrinsics
- add_compile_options(/Oy-) # disable suppressing of the creation of frame pointers on the call stack for quicker function calls
- add_compile_options(/U_MT) # undefine the predefined _MT macro
- add_compile_options(/GF) # enable read-only string pooling
- add_compile_options(/Gm-) # disable minimal rebuild
- add_compile_options(/EHa) # enable C++ EH (w/ SEH exceptions)
- add_compile_options(/Zp8) # pack structs on 8-byte boundary
- add_compile_options(/Gy) # separate functions for linker
- add_compile_options(/Zc:wchar_t-) # C++ language conformance: wchar_t is NOT the native type, but a typedef
- add_compile_options(/Zc:forScope) # C++ language conformance: enforce Standard C++ for scoping rules
- add_compile_options(/GR-) # disable C++ RTTI
- add_compile_options(/FC) # use full pathnames in diagnostics
- add_compile_options(/MP) # Build with Multiple Processes (number of processes equal to the number of processors)
- add_compile_options(/GS) # Buffer Security Check
- add_compile_options(/Zm200) # Specify Precompiled Header Memory Allocation Limit of 150MB
- add_compile_options(/wd4960 /wd4961 /wd4603 /wd4627 /wd4838 /wd4456 /wd4457 /wd4458 /wd4459 /wd4091 /we4640)
- add_compile_options(/Zi) # enable debugging information
- add_compile_options(/ZH:SHA_256) # use SHA256 for generating hashes of compiler processed source files.
- add_compile_options(/source-charset:utf-8) # Force MSVC to compile source as UTF-8.
-
- if (CLR_CMAKE_PLATFORM_ARCH_I386)
- add_compile_options(/Gz)
- endif (CLR_CMAKE_PLATFORM_ARCH_I386)
-
- add_compile_options($<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/GL>)
- add_compile_options($<$<OR:$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>,$<CONFIG:Checked>>:/O1>)
-
- if (CLR_CMAKE_PLATFORM_ARCH_AMD64)
- # The generator expression in the following command means that the /homeparams option is added only for debug builds
- add_compile_options($<$<CONFIG:Debug>:/homeparams>) # Force parameters passed in registers to be written to the stack
- endif (CLR_CMAKE_PLATFORM_ARCH_AMD64)
-
- # enable control-flow-guard support for native components for non-Arm64 builds
- add_compile_options(/guard:cf)
-
- # Statically linked CRT (libcmt[d].lib, libvcruntime[d].lib and libucrt[d].lib) by default. This is done to avoid
- # linking in VCRUNTIME140.DLL for a simplified xcopy experience by reducing the dependency on VC REDIST.
- #
- # 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.
- add_compile_options($<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/MT>)
- add_compile_options($<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:/MTd>)
-
- set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /ZH:SHA_256")
-
-endif (WIN32)
-
-if(CLR_CMAKE_ENABLE_CODE_COVERAGE)
-
- if(CLR_CMAKE_PLATFORM_UNIX)
- string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_CMAKE_BUILD_TYPE)
- if(NOT UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
- message( WARNING "Code coverage results with an optimised (non-Debug) build may be misleading" )
- endif(NOT UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
-
- add_compile_options(-fprofile-arcs)
- add_compile_options(-ftest-coverage)
- set(CLANG_COVERAGE_LINK_FLAGS "--coverage")
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CLANG_COVERAGE_LINK_FLAGS}")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CLANG_COVERAGE_LINK_FLAGS}")
- else()
- message(FATAL_ERROR "Code coverage builds not supported on current platform")
- endif(CLR_CMAKE_PLATFORM_UNIX)
-
-endif(CLR_CMAKE_ENABLE_CODE_COVERAGE)
+++ /dev/null
-# Contains the crossgen build specific definitions. Included by the leaf crossgen cmake files.
-
-add_definitions(
- -DCROSSGEN_COMPILE
- -DCROSS_COMPILE
- -DFEATURE_NATIVE_IMAGE_GENERATION
- -DSELF_NO_HOST)
-
-remove_definitions(
- -DFEATURE_CODE_VERSIONING
- -DEnC_SUPPORTED
- -DFEATURE_EVENT_TRACE=1
- -DFEATURE_LOADER_OPTIMIZATION
- -DFEATURE_MULTICOREJIT
- -DFEATURE_PERFMAP
- -DFEATURE_REJIT
- -DFEATURE_TIERED_COMPILATION
- -DFEATURE_VERSIONING_LOG
-)
-
-if(FEATURE_READYTORUN)
- add_definitions(-DFEATURE_READYTORUN_COMPILER)
-endif(FEATURE_READYTORUN)
-
-if(CLR_CMAKE_PLATFORM_LINUX)
- add_definitions(-DFEATURE_PERFMAP)
-endif(CLR_CMAKE_PLATFORM_LINUX)
parameters:
name: Alpine3_13
osGroup: Linux
- dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.13-WithNode-20210728123842-ddfc481
+ dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.13-WithNode-20210910135845-c401c85
artifactsTargetPath: bin/Linux-musl.x64.Release
requiresCapPtraceContainer: true
strategy:
parameters:
name: MacOS_cross
osGroup: MacOS_cross
+ crossbuild: true
buildAndSkipTest: true
strategy:
matrix:
parameters:
name: Linux_cross
osGroup: Linux
- dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-14.04-cross-1735d26-20190521133857
+ dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-20210719121212-8a8d3be
crossrootfsDir: '/crossrootfs/arm'
buildAndSkipTest: true
strategy:
parameters:
name: Linux_cross64
osGroup: Linux
- dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm64-a3ae44b-20180315221921
+ dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm64-20210719121212-8a8d3be
crossrootfsDir: '/crossrootfs/arm64'
buildAndSkipTest: true
strategy:
parameters:
name: Alpine_cross64
osGroup: Linux
- dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm64-alpine-20210719121212-b2c2436
+ dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm64-alpine-20210923140502-78f7860
crossrootfsDir: '/crossrootfs/arm64'
artifactsTargetPath: bin/Linux-musl.arm64.Release
buildAndSkipTest: true
## Installing dotnet-dump
-The first step is to install the dotnet-dump CLI global tool. This requires at least the 2.1 or greater .NET Core SDK to be installed. If you see the error message `Tool 'dotnet-dump' is already installed`, you will need to uninstall the global tool (see below).
+The first step is to install the dotnet-dump CLI global tool. This requires at least the 3.1 or greater .NET Core SDK to be installed. If you see the error message `Tool 'dotnet-dump' is already installed`, you will need to uninstall the global tool (see below).
$ dotnet tool install -g dotnet-dump
You can invoke the tool using the following command: dotnet-dump
Installing SOS on Linux and MacOS
=================================
-The first step is to install the dotnet-sos CLI global tool. This requires at least the 2.1 or greater .NET Core SDK to be installed. If you see the error message `Tool 'dotnet-sos' is already installed`, you will need to uninstall the global tool (see below).
+The first step is to install the dotnet-sos CLI global tool. This requires at least the 3.1 or greater .NET Core SDK to be installed. If you see the error message `Tool 'dotnet-sos' is already installed`, you will need to uninstall the global tool (see below).
$ dotnet tool install -g dotnet-sos
You can invoke the tool using the following command: dotnet-sos
The next step is use this global tool to install SOS.
$ dotnet-sos install
- Installing SOS to /home/mikem/.dotnet/sos from /home/mikem/.dotnet/tools/.store/dotnet-sos/3.0.47001/dotnet-sos/3.0.47001/tools/netcoreapp2.1/any/linux-x64
+ Installing SOS to /home/mikem/.dotnet/sos from /home/mikem/.dotnet/tools/.store/dotnet-sos/5.0.251802/dotnet-sos/5.0.251802/tools/netcoreapp3.1/any/linux-x64
Creating installation directory...
Copying files...
Updating existing /home/mikem/.lldbinit file - LLDB will load SOS automatically at startup
The installer needs to be run again:
$ dotnet-sos install
- Installing SOS to /home/mikem/.dotnet/sos from /home/mikem/.dotnet/tools/.store/dotnet-sos/3.0.47001/dotnet-sos/3.0.47001/tools/netcoreapp2.1/any/linux-x64
+ Installing SOS to /home/mikem/.dotnet/sos from /home/mikem/.dotnet/tools/.store/dotnet-sos/5.0.251802/dotnet-sos/5.0.251802/tools/netcoreapp3.1/any/linux-x64
Installing over existing installation...
Creating installation directory...
Copying files...
Run the installer:
C:\Users\mikem>dotnet-sos install
- Installing SOS to C:\Users\mikem\.dotnet\sos from C:\Users\mikem\.dotnet\tools\.store\dotnet-sos\5.0.160202\dotnet-sos\5.0.160202\tools\netcoreapp2.1\any\win-x64
+ Installing SOS to C:\Users\mikem\.dotnet\sos from C:\Users\mikem\.dotnet\tools\.store\dotnet-sos\5.0.251802\dotnet-sos\5.0.251802\tools\netcoreapp3.1\any\win-x64
Installing over existing installation...
Creating installation directory...
Copying files...
0:000> sxe ld coreclr
0:000> g
- ModLoad: 00007ffe`e9100000 00007ffe`e9165000 C:\Program Files\dotnet\host\fxr\2.2.2\hostfxr.dll
- ModLoad: 00007ffe`e7ba0000 00007ffe`e7c32000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.6\hostpolicy.dll
- ModLoad: 00007ffe`abb60000 00007ffe`ac125000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.6\coreclr.dll
+ ModLoad: 00007ffe`e9100000 00007ffe`e9165000 C:\Program Files\dotnet\host\fxr\3.0.3\hostfxr.dll
+ ModLoad: 00007ffe`e7ba0000 00007ffe`e7c32000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.20\hostpolicy.dll
+ ModLoad: 00007ffe`abb60000 00007ffe`ac125000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.20\coreclr.dll
ntdll!ZwMapViewOfSection+0x14:
00007fff`16e2fb74 c3 ret
0:000> .chain
|**SaveModule** \<*Base address*> \<*Filename*>|Writes an image, which is loaded in memory at the specified address, to the specified file.|
|**SOSFlush**|Flushes an internal SOS cache.|
|**SOSStatus** [**-netfx**] [**-netcore**] [**-reset**]|Display internal SOS status, reset the internal cached state, or change between the desktop .NET framework or .NET Core runtimes when both are loaded in the process or dump.<br/><br/>-netfx - switch to the desktop .NET Framework runtime if loaded.<br/>-netcore - switch to the .NET Core runtime if loaded.<br/>-reset - reset all the cached internal SOS state.<br/><br/>|
-|**SetHostRuntime** [**-netcore**] [**-netfx**] [\<runtime-directory\>]|This command controls the runtime that is used to host the maanged code that runs as part of SOS in the debugger (cdb/windbg). The default is the desktop .NET Framework. The "-netcore" option allows the installed .NET Core runtime be used. The "-netfx" option allows switches back to the .NET Framework runtime.<br/><br/>Normally, SOS attempts to find an installed .NET Core runtime to run its managed code automatically but this command is available if it fails. The default is to use the same runtime (libcoreclr) being debugged. Use this command if the default runtime being debugged isn't working enough to run the SOS code or if the version is less than 2.1.0.<br/><br/>If you received the following error message when running a SOS command, use this command to set the path to 2.1.0 or greater .NET Core runtime. <br/><br/>`(lldb) clrstack`<br/>`Error: Fail to initialize CoreCLR 80004005 ClrStack failed`<br/><br/>`(lldb) sethostruntime /usr/share/dotnet/shared/Microsoft.NETCore.App/2.1.6`<br/><br/>You can use the "dotnet --info" in a command shell to find the path of an installed .NET Core runtime.|
+|**SetHostRuntime** [**-netcore**] [**-netfx**] [\<runtime-directory\>]|This command controls the runtime that is used to host the maanged code that runs as part of SOS in the debugger (cdb/windbg). The default is the desktop .NET Framework. The "-netcore" option allows the installed .NET Core runtime be used. The "-netfx" option allows switches back to the .NET Framework runtime.<br/><br/>Normally, SOS attempts to find an installed .NET Core runtime to run its managed code automatically but this command is available if it fails. The default is to use the same runtime (libcoreclr) being debugged. Use this command if the default runtime being debugged isn't working enough to run the SOS code or if the version is less than 3.1.<br/><br/>If you received the following error message when running a SOS command, use this command to set the path to 3.1 or greater .NET Core runtime. <br/><br/>`(lldb) clrstack`<br/>`Error: Fail to initialize CoreCLR 80004005 ClrStack failed`<br/><br/>`(lldb) sethostruntime /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.20`<br/><br/>You can use the "dotnet --info" in a command shell to find the path of an installed .NET Core runtime.|
|**StopOnException** [**-derived**] [**-create** | **-create2**] \<*Exception*> \<*Pseudo-register number*>|Causes the debugger to stop when the specified exception is thrown, but to continue running when other exceptions are thrown.<br /><br /> The **-derived** option catches the specified exception and every exception that derives from the specified exception.|
|**SyncBlk** [**-all** | \<*syncblk number*>]|Displays the specified `SyncBlock` structure or all `SyncBlock` structures. If you do not pass any arguments, the **SyncBlk** command displays the `SyncBlock` structure corresponding to objects that are owned by a thread.<br /><br /> A `SyncBlock` structure is a container for extra information that does not need to be created for every object. It can hold COM interop data, hash codes, and locking information for thread-safe operations.|
|**ThreadPool**|Displays information about the managed thread pool, including the number of work requests in the queue, the number of completion port threads, and the number of timers.|
|**HistObjFind** *<obj_address>*|Displays all the log entries that reference an object at the specified address.|
|**HistRoot** *\<root>*|Displays information related to both promotions and relocations of the specified root.<br /><br /> The root value can be used to track the movement of an object through the garbage collections.|
|**IP2MD** (**ip2md**) \<*Code address*>|Displays the `MethodDesc` structure at the specified address in code that has been JIT-compiled.|
-|**Name2EE** (**name2ee**) \<*module name*> \<*type or method name*><br /><br /> -or-<br /><br /> **Name2EE** \<*module name*>**!**\<*type or method name*>|Displays the `MethodTable` structure and `EEClass` structure for the specified type or method in the specified module.<br /><br /> The specified module must be loaded in the process.<br /><br /> To get the proper type name, browse the module by using the [Ildasm.exe (IL Disassembler)](../../../docs/framework/tools/ildasm-exe-il-disassembler.md). You can also pass `*` as the module name parameter to search all loaded managed modules. The *module name* parameter can also be the debugger's name for a module, such as `mscorlib` or `image00400000`.<br /><br /> This command supports the Windows debugger syntax of <`module`>`!`<`type`>. The type must be fully qualified.|
+|**Name2EE** (**name2ee**) \<*module name*> \<*type or method name*><br /><br /> -or-<br /><br /> **Name2EE** \<*module name*>**!**\<*type or method name*>|Displays the `MethodTable` structure and `EEClass` structure for the specified type or method in the specified module.<br /><br /> The specified module must be loaded in the process.<br /><br /> To get the proper type name you can browse the module by using the an IL reflection tool like Ildasm or ILSpy. You can also pass `*` as the module name parameter to search all loaded managed modules. The *module name* parameter can also be the debugger's name for a module, such as `mscorlib` or `image00400000`.<br /><br /> This command supports the Windows debugger syntax of <`module`>`!`<`type`>. The type must be fully qualified.|
|**PrintException** [**-nested**] [**-lines**] [\<*Exception object address*>]<br /><br /> -or-<br /><br /> **PE** [**-nested**] [\<*Exception object address*>]|Displays and formats fields of any object derived from the <xref:System.Exception> class at the specified address. If you do not specify an address, the **PrintException** command displays the last exception thrown on the current thread.<br /><br /> The **-nested** option displays details about nested exception objects.<br /><br /> The **-lines** option displays source information, if available.<br /><br /> You can use this command to format and view the `_stackTrace` field, which is a binary array.|
|**SyncBlk** [**-all** | \<*syncblk number*>]|Displays the specified `SyncBlock` structure or all `SyncBlock` structures. If you do not pass any arguments, the **SyncBlk** command displays the `SyncBlock` structure corresponding to objects that are owned by a thread.<br /><br /> A `SyncBlock` structure is a container for extra information that does not need to be created for every object. It can hold COM interop data, hash codes, and locking information for thread-safe operations.|
|**SOSFlush**|Flushes an internal SOS cache.|
|**SOSStatus** [**-reset**]|Displays internal SOS status or reset the internal cached state.|
-|**SetHostRuntime** [\<runtime-directory\>]|This command sets the path to the .NET Core runtime to use to host the managed code that runs as part of SOS in the debugger (lldb). The runtime needs to be at least version 2.1.0 or greater. If there are spaces in directory, it needs to be single-quoted (').<br/><br/>Normally, SOS attempts to find an installed .NET Core runtime to run its managed code automatically but this command is available if it fails. The default is to use the same runtime (libcoreclr) being debugged. Use this command if the default runtime being debugged isn't working enough to run the SOS code or if the version is less than 2.1.0.<br/><br/>If you received the following error message when running a SOS command, use this command to set the path to 2.1.0 or greater .NET Core runtime. <br/><br/>`(lldb) clrstack`<br/>`Error: Fail to initialize CoreCLR 80004005 ClrStack failed`<br/><br/>`(lldb) sethostruntime /usr/share/dotnet/shared/Microsoft.NETCore.App/2.1.6`<br/><br/>You can use the "dotnet --info" in a command shell to find the path of an installed .NET Core runtime.|
+|**SetHostRuntime** [\<runtime-directory\>]|This command sets the path to the .NET Core runtime to use to host the managed code that runs as part of SOS in the debugger (lldb). The runtime needs to be at least version 3.1 or greater. If there are spaces in directory, it needs to be single-quoted (').<br/><br/>Normally, SOS attempts to find an installed .NET Core runtime to run its managed code automatically but this command is available if it fails. The default is to use the same runtime (libcoreclr) being debugged. Use this command if the default runtime being debugged isn't working enough to run the SOS code or if the version is less than 3.1.<br/><br/>If you received the following error message when running a SOS command, use this command to set the path to 3.1 or greater .NET Core runtime. <br/><br/>`(lldb) clrstack`<br/>`Error: Fail to initialize CoreCLR 80004005 ClrStack failed`<br/><br/>`(lldb) sethostruntime /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.20`<br/><br/>You can use the "dotnet --info" in a command shell to find the path of an installed .NET Core runtime.|
|**SetSymbolServer** [**-ms**] [**-disable**] [**-log**] [**-loadsymbols**] [**-cache** \<cache-path>] [**-directory** \<search-directory>] [**-sympath** \<windows-symbol-path>] [\<symbol-server-URL>]|Enables the symbol server downloading support.<br/><br/>The **-ms** option enables downloading from the public Microsoft symbol server.<br/><br/>The **-disable** option turns on the symbol download support.<br/><br/>The **-cache** \<cache-path> option specifies a symbol cache directory. The default is $HOME/.dotnet/symbolcache if not specified.<br/><br/>The **-directory** option add a path to search for symbols. Can be more than one.<br/><br/>The **-sympath** option adds server, cache and directory paths in the Windows symbol path format.<br/><br/>The **-log** option enables symbol download logging.<br/><br/>The **-loadsymbols** option attempts to download the native .NET Core symbols for the runtime.|
|**Token2EE** \<*module name*> \<*token*>|Turns the specified metadata token in the specified module into a `MethodTable` structure or `MethodDesc` structure.<br /><br /> You can pass `*` for the module name parameter to find what that token maps to in every loaded managed module. You can also pass the debugger's name for a module, such as `mscorlib` or `image00400000`.|
|**Threads** (**clrthreads**) [**-live**] [**-special**]|Displays all managed threads in the process.<br /><br /> The **Threads** command displays the debugger shorthand ID, the CLR thread ID, and the operating system thread ID. Additionally, the **Threads** command displays a Domain column that indicates the application domain in which a thread is executing, an APT column that displays the COM apartment mode, and an Exception column that displays the last exception thrown in the thread.<br /><br /> The **-live** option displays threads associated with a live thread.<br /><br /> The **-special** option displays all special threads created by the CLR. Special threads include garbage collection threads (in concurrent and server garbage collection), debugger helper threads, finalizer threads, <xref:System.AppDomain> unload threads, and thread pool timer threads.|
Build the dotnet-dump tool (dotnet build) and run it from the following location on the same dump that we generated earlier:
```bash
-~/diagnostics/artifacts/bin/dotnet-dump/Debug/netcoreapp2.1/publish/dotnet dotnet-dump.dll analyze ~/.dotnet/tools/core_20190513_143916
+~/diagnostics/artifacts/bin/dotnet-dump/Debug/netcoreapp3.1/publish/dotnet dotnet-dump.dll analyze ~/.dotnet/tools/core_20190513_143916
```
You can now use the 'uniquestacks' command and see the following output (partial):
set __ThisScriptFull="%~f0"
set __ThisScriptDir="%~dp0"
-call "%__ThisScriptDir%"\setup-vs-tools.cmd
+call "%__ThisScriptDir%"\native\init-vs-env.cmd
if NOT '%ERRORLEVEL%' == '0' goto ExitWithError
if defined VS160COMNTOOLS (
set "__RootBinDir=%__ProjectDir%\artifacts"
set "__BinDir=%__RootBinDir%\bin\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__LogDir=%__RootBinDir%\log\%__BuildOS%.%__BuildArch%.%__BuildType%"
-set "__IntermediatesDir=%__RootBinDir%\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
+set "__ArtifactsIntermediatesDir=%__RootBinDir%\obj"
+set "__IntermediatesDir=%__ArtifactsIntermediatesDir%\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__PackagesBinDir=%__RootBinDir%\packages\%__BuildType%\Shipping"
set "__CrossComponentBinDir=%__BinDir%"
echo Generating Version Header
set __GenerateVersionLog="%__LogDir%\GenerateVersion.binlog"
- powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__ProjectDir%\eng\common\msbuild.ps1" "%__ProjectDir%\eng\CreateVersionFile.csproj" /bl:!__GenerateVersionLog! /t:GenerateVersionFiles /restore /p:FileVersionFile=%__RootBinDir%\bin\FileVersion.txt /p:GenerateVersionHeader=true /p:NativeVersionHeaderFile=%__CrossCompIntermediatesDir%\_version.h %__CommonBuildArgs%
+ powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__ProjectDir%\eng\common\msbuild.ps1" "%__ProjectDir%\eng\CreateVersionFile.csproj" /bl:!__GenerateVersionLog! /t:GenerateVersionFiles /restore /p:FileVersionFile=%__RootBinDir%\bin\FileVersion.txt /p:GenerateVersionHeader=true /p:NativeVersionHeaderFile=%__ArtifactsIntermediatesDir%\_version.h %__CommonBuildArgs%
if not !errorlevel! == 0 (
echo Generate Version Header FAILED
goto ExitWithError
set __ExtraCmakeArgs="-DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir!" "-DCLR_BUILD_TYPE=%__BuildType%" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCMAKE_SYSTEM_VERSION=10.0" "-DNUGET_PACKAGES=%NUGET_PACKAGES:\=/%"
pushd "%__CrossCompIntermediatesDir%"
- call "%__ProjectDir%\eng\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion% %__CrossArch% !__ExtraCmakeArgs!
+ call "%__ProjectDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__CrossCompIntermediatesDir%" %__VSVersion% %__CrossArch% !__ExtraCmakeArgs!
@if defined _echo @echo on
popd
if /i "%__BuildArch%" == "x86" ( set __VCBuildArch=x86 )
if /i "%__BuildArch%" == "arm" (
set __VCBuildArch=x86_arm
- :: Make CMake pick the highest installed version in the 10.0.* range
- set ___SDKVersion="-DCMAKE_SYSTEM_VERSION=10.0"
)
if /i "%__BuildArch%" == "arm64" (
set __VCBuildArch=x86_arm64
- :: Make CMake pick the highest installed version in the 10.0.* range
- set ___SDKVersion="-DCMAKE_SYSTEM_VERSION=10.0"
)
echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch!
echo Generating Version Header
set __GenerateVersionLog="%__LogDir%\GenerateVersion.binlog"
- powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__ProjectDir%\eng\common\msbuild.ps1" "%__ProjectDir%\eng\CreateVersionFile.csproj" /bl:!__GenerateVersionLog! /t:GenerateVersionFiles /restore /p:FileVersionFile=%__RootBinDir%\bin\FileVersion.txt /p:GenerateVersionHeader=true /p:NativeVersionHeaderFile=%__IntermediatesDir%\_version.h %__CommonBuildArgs%
+ powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__ProjectDir%\eng\common\msbuild.ps1" "%__ProjectDir%\eng\CreateVersionFile.csproj" /bl:!__GenerateVersionLog! /t:GenerateVersionFiles /restore /p:FileVersionFile=%__RootBinDir%\bin\FileVersion.txt /p:GenerateVersionHeader=true /p:NativeVersionHeaderFile=%__ArtifactsIntermediatesDir%\_version.h %__CommonBuildArgs%
if not !errorlevel! == 0 (
echo Generate Version Header FAILED
goto ExitWithError
set "__ManagedBinaryDir=%__RootBinDir%\bin"
set "__ManagedBinaryDir=!__ManagedBinaryDir:\=/!"
- set __ExtraCmakeArgs=!___SDKVersion! "-DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir!" "-DCLR_BUILD_TYPE=%__BuildType%" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DNUGET_PACKAGES=%NUGET_PACKAGES:\=/%"
+ set __ExtraCmakeArgs="-DCMAKE_SYSTEM_VERSION=10.0" "-DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir!" "-DCLR_BUILD_TYPE=%__BuildType%" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DNUGET_PACKAGES=%NUGET_PACKAGES:\=/%"
pushd "%__IntermediatesDir%"
- call "%__ProjectDir%\eng\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs!
+ call "%__ProjectDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs!
@if defined _echo @echo on
popd
</NativeVersionLines>
</PropertyGroup>
- <WriteLinesToFile File="$(NativeVersionHeaderFile)" Lines="$(NativeVersionLines.Replace(';', '%3B'))" Overwrite="true" />
+ <WriteLinesToFile File="$(NativeVersionHeaderFile)"
+ Lines="$(NativeVersionLines.Replace(';', '%3B'))"
+ Overwrite="true"
+ WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(NativeVersionHeaderFile)" />
</NativeVersionLines>
</PropertyGroup>
- <WriteLinesToFile File="$(NativeVersionSourceFile)" Lines="$(NativeVersionLines.Replace(';', '%3B'))" Overwrite="true" />
+ <WriteLinesToFile File="$(NativeVersionSourceFile)"
+ Lines="$(NativeVersionLines.Replace(';', '%3B'))"
+ Overwrite="true"
+ WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(NativeVersionSourceFile)" />
<Dependencies>
<ProductDependencies>
- <Dependency Name="Microsoft.SymbolStore" Version="1.0.250401">
+ <Dependency Name="Microsoft.SymbolStore" Version="1.0.256501">
<Uri>https://github.com/dotnet/symstore</Uri>
- <Sha>cb24099215a83975c360792edf35102ff0d10702</Sha>
+ <Sha>28f890492dbe55374670e0b5b4606873eb6f0a1d</Sha>
</Dependency>
- <Dependency Name="Microsoft.Diagnostics.Runtime" Version="2.0.251201">
+ <Dependency Name="Microsoft.Diagnostics.Runtime" Version="2.0.256601">
<Uri>https://github.com/microsoft/clrmd</Uri>
- <Sha>58ede2ab2a191fb1aefc840ccb99b8e43f7bb316</Sha>
+ <Sha>9e6dbb14ad2d9db38554486b84c28f999073c99e</Sha>
</Dependency>
- <Dependency Name="Microsoft.Diagnostics.Runtime.Utilities" Version="2.0.251201">
+ <Dependency Name="Microsoft.Diagnostics.Runtime.Utilities" Version="2.0.256601">
<Uri>https://github.com/microsoft/clrmd</Uri>
- <Sha>58ede2ab2a191fb1aefc840ccb99b8e43f7bb316</Sha>
+ <Sha>9e6dbb14ad2d9db38554486b84c28f999073c99e</Sha>
</Dependency>
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="5.0.0-alpha.1.20473.1">
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
- <Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="7.0.0-beta.21518.1">
+ <Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="7.0.0-beta.21559.3">
<Uri>https://github.com/dotnet/arcade</Uri>
- <Sha>c5a300999a6ab2792108190118280da36fb1991e</Sha>
+ <Sha>fecf65bedcee9036b8ba9d8d7feef5413f294914</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
- <Dependency Name="Microsoft.DotNet.RemoteExecutor" Version="7.0.0-beta.21518.1">
+ <Dependency Name="Microsoft.DotNet.RemoteExecutor" Version="7.0.0-beta.21559.3">
<Uri>https://github.com/dotnet/arcade</Uri>
- <Sha>c5a300999a6ab2792108190118280da36fb1991e</Sha>
+ <Sha>fecf65bedcee9036b8ba9d8d7feef5413f294914</Sha>
</Dependency>
- <Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="6.0.100-rtm.21518.6">
+ <Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="6.0.101-servicing.21562.12">
<Uri>https://github.com/dotnet/installer</Uri>
- <Sha>4cba5995022e769f2f9688ce44d8fc204559e4d9</Sha>
+ <Sha>457210a04c1900ee630e2a7b852f680a952eb71d</Sha>
</Dependency>
- <Dependency Name="Microsoft.AspNetCore.App.Ref.Internal" Version="6.0.0-rtm.21518.3">
+ <Dependency Name="Microsoft.AspNetCore.App.Ref.Internal" Version="6.0.0-rtm.21526.8">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
- <Sha>afb4990d708390efcdec701e33e5d66c37603d9a</Sha>
+ <Sha>ae1a6cbe225b99c0bf38b7e31bf60cb653b73a52</Sha>
</Dependency>
- <Dependency Name="Microsoft.AspNetCore.App.Ref" Version="6.0.0-rtm.21518.3">
+ <Dependency Name="Microsoft.AspNetCore.App.Ref" Version="6.0.0">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
- <Sha>afb4990d708390efcdec701e33e5d66c37603d9a</Sha>
+ <Sha>ae1a6cbe225b99c0bf38b7e31bf60cb653b73a52</Sha>
</Dependency>
- <Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="6.0.0-rtm.21517.2">
+ <Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="6.0.1">
<Uri>https://github.com/dotnet/runtime</Uri>
- <Sha>92ff02435693486da161626246f016b4f1e7b8e8</Sha>
+ <Sha>fd61aefcf12382a9ddd24295f660b95606201d57</Sha>
</Dependency>
- <Dependency Name="VS.Redist.Common.NetCore.SharedFramework.x64.6.0" Version="6.0.0-rtm.21517.2">
+ <Dependency Name="VS.Redist.Common.NetCore.SharedFramework.x64.6.0" Version="6.0.1-servicing.21566.4">
<Uri>https://github.com/dotnet/runtime</Uri>
- <Sha>92ff02435693486da161626246f016b4f1e7b8e8</Sha>
+ <Sha>fd61aefcf12382a9ddd24295f660b95606201d57</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
<PropertyGroup>
<RepositoryUrl>https://github.com/dotnet/diagnostics</RepositoryUrl>
<PreReleaseVersionLabel></PreReleaseVersionLabel>
- <VersionPrefix>5.0.0</VersionPrefix>
+ <VersionPrefix>6.0.0</VersionPrefix>
<DotNetUseShippingVersions>true</DotNetUseShippingVersions>
<AutoGenerateAssemblyVersion>true</AutoGenerateAssemblyVersion>
+ <!--
+ Our nightly tools are stable versioned but go to a non-stable feed.
+ Arcade usually disallows this, but we use such a versioning scheme by design.
+ The nightly bits are versioned in a stable manner to allow `dotnet tool` to perform
+ easy updates. If we have issues, we just respin builds as we are a leaf build node
+ and we don't participate in prodcon.
+ -->
+ <SkipPackagePublishingVersionChecks>true</SkipPackagePublishingVersionChecks>
</PropertyGroup>
<PropertyGroup>
<!-- Latest symstore version updated by darc -->
- <MicrosoftSymbolStoreVersion>1.0.250401</MicrosoftSymbolStoreVersion>
+ <MicrosoftSymbolStoreVersion>1.0.256501</MicrosoftSymbolStoreVersion>
<!-- Runtime versions to test -->
<MicrosoftNETCoreApp31Version>3.1.18</MicrosoftNETCoreApp31Version>
<MicrosoftAspNetCoreApp31Version>$(MicrosoftNETCoreApp31Version)</MicrosoftAspNetCoreApp31Version>
<MicrosoftNETCoreApp50Version>5.0.9</MicrosoftNETCoreApp50Version>
<MicrosoftAspNetCoreApp50Version>$(MicrosoftNETCoreApp50Version)</MicrosoftAspNetCoreApp50Version>
<!-- Latest shared runtime version updated by darc -->
- <VSRedistCommonNetCoreSharedFrameworkx6460Version>6.0.0-rtm.21517.2</VSRedistCommonNetCoreSharedFrameworkx6460Version>
- <MicrosoftNETCoreAppRuntimewinx64Version>6.0.0-rtm.21517.2</MicrosoftNETCoreAppRuntimewinx64Version>
+ <VSRedistCommonNetCoreSharedFrameworkx6460Version>6.0.1-servicing.21566.4</VSRedistCommonNetCoreSharedFrameworkx6460Version>
+ <MicrosoftNETCoreAppRuntimewinx64Version>6.0.1</MicrosoftNETCoreAppRuntimewinx64Version>
<!-- Latest shared aspnetcore version updated by darc -->
- <MicrosoftAspNetCoreAppRefInternalVersion>6.0.0-rtm.21518.3</MicrosoftAspNetCoreAppRefInternalVersion>
- <MicrosoftAspNetCoreAppRefVersion>6.0.0-rtm.21518.3</MicrosoftAspNetCoreAppRefVersion>
+ <MicrosoftAspNetCoreAppRefInternalVersion>6.0.0-rtm.21526.8</MicrosoftAspNetCoreAppRefInternalVersion>
+ <MicrosoftAspNetCoreAppRefVersion>6.0.0</MicrosoftAspNetCoreAppRefVersion>
<!-- dotnet/installer: Testing version of the SDK. Needed for the signed & entitled host. -->
- <MicrosoftDotnetSdkInternalVersion>6.0.100-rtm.21518.6</MicrosoftDotnetSdkInternalVersion>
+ <MicrosoftDotnetSdkInternalVersion>6.0.101-servicing.21562.12</MicrosoftDotnetSdkInternalVersion>
</PropertyGroup>
<PropertyGroup>
<!-- Opt-in/out repo features -->
<MicrosoftWin32PrimitivesVersion>4.3.0</MicrosoftWin32PrimitivesVersion>
<!-- Other libs -->
<MicrosoftBclAsyncInterfacesVersion>1.1.0</MicrosoftBclAsyncInterfacesVersion>
- <MicrosoftDiagnosticsRuntimeVersion>2.0.251201</MicrosoftDiagnosticsRuntimeVersion>
- <MicrosoftDiagnosticsRuntimeUtilitiesVersion>2.0.251201</MicrosoftDiagnosticsRuntimeUtilitiesVersion>
+ <MicrosoftDiagnosticsRuntimeVersion>2.0.256601</MicrosoftDiagnosticsRuntimeVersion>
+ <MicrosoftDiagnosticsRuntimeUtilitiesVersion>2.0.256601</MicrosoftDiagnosticsRuntimeUtilitiesVersion>
<MicrosoftDiaSymReaderNativePackageVersion>16.9.0-beta1.21055.5</MicrosoftDiaSymReaderNativePackageVersion>
<MicrosoftDiagnosticsTracingTraceEventVersion>2.0.64</MicrosoftDiagnosticsTracingTraceEventVersion>
<MicrosoftExtensionsLoggingVersion>2.1.1</MicrosoftExtensionsLoggingVersion>
<SystemTextEncodingsWebVersion>4.7.2</SystemTextEncodingsWebVersion>
<SystemTextJsonVersion>4.7.1</SystemTextJsonVersion>
<XUnitAbstractionsVersion>2.0.3</XUnitAbstractionsVersion>
- <MicrosoftDotNetRemoteExecutorVersion>7.0.0-beta.21518.1</MicrosoftDotNetRemoteExecutorVersion>
+ <MicrosoftDotNetRemoteExecutorVersion>7.0.0-beta.21559.3</MicrosoftDotNetRemoteExecutorVersion>
<cdbsosversion>10.0.18362</cdbsosversion>
<NewtonSoftJsonVersion>12.0.2</NewtonSoftJsonVersion>
</PropertyGroup>
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
# Obtain the location of the bash script to figure out where the root of the repo is.
-source="${BASH_SOURCE[0]}"
-
-# Resolve $source until the file is no longer a symlink
-while [[ -h "$source" ]]; do
- scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
- source="$(readlink "$source")"
- # if $source was a relative symlink, we need to resolve it relative to the path where the
- # symlink file was located
- [[ $source != /* ]] && source="$scriptroot/$source"
-done
-__ProjectRoot="$( cd -P "$( dirname "$source" )/.." && pwd )"
-
-__BuildOS=Linux
-__HostOS=Linux
+__RepoRootDir="$(cd "$(dirname "$0")"/..; pwd -P)"
+
__BuildArch=x64
-__HostArch=x64
__BuildType=Debug
-__PortableBuild=1
-__ExtraCmakeArgs=""
-__ClangMajorVersion=0
-__ClangMinorVersion=0
-__NumProc=1
-__ManagedBuild=true
-__NativeBuild=true
-__CrossBuild=false
-__Test=false
-__PrivateBuildPath=""
-__CI=false
-__Verbosity=minimal
+__CMakeArgs=
+__CommonMSBuildArgs=
+__Compiler=clang
+__CompilerMajorVersion=
+__CompilerMinorVersion=
+__CrossBuild=0
+__DotnetRuntimeDownloadVersion="default"
+__DotnetRuntimeVersion="default"
+__ExtraCmakeArgs=
+__HostArch=x64
+__HostOS=Linux
+__IsMSBuildOnNETCoreSupported=0
+__ManagedBuild=1
__ManagedBuildArgs=
-__TestArgs=
+__NativeBuild=1
+__NumProc=1
+__PortableBuild=1
+__PrivateBuildPath=
+__RootBinDir="$__RepoRootDir"/artifacts
+__RuntimeSourceFeed=
+__RuntimeSourceFeedKey=
+__SkipConfigure=0
+__SkipGenerateVersion=0
+__TargetOS=Linux
+__Test=0
__UnprocessedBuildArgs=
-__DotnetRuntimeVersion='default'
-__DotnetRuntimeDownloadVersion='default'
-__RuntimeSourceFeed=''
-__RuntimeSourceFeedKey=''
-
-usage()
-{
- echo "Usage: $0 [options]"
- echo "--skipmanaged- Skip building managed components"
- echo "--skipnative - Skip building native components"
- echo "--test - run xunit tests"
- echo "--privatebuildpath - path to local private runtime build to test"
- echo "--architecture <x64|x86|arm|armel|arm64>"
- echo "--configuration <debug|release>"
- echo "--rootfs <ROOTFS_DIR>"
- echo "--stripsymbols - strip symbols into .dbg files"
- echo "--clangx.y - optional argument to build using clang version x.y"
- echo "--ci - CI lab build"
- echo "--verbosity <q[uiet]|m[inimal]|n[ormal]|d[etailed]|diag[nostic]>"
- echo "--help - this help message"
- exit 1
-}
-to_lowercase() {
- #eval $invocation
+usage_list+=("-skipmanaged: do not build managed components.")
+usage_list+=("-skipnative: do not build native components.")
+usage_list+=("-privatebuildpath: path to local private runtime build to test.")
+usage_list+=("-test: run xunit tests")
- echo "$1" | tr '[:upper:]' '[:lower:]'
- return 0
-}
+handle_arguments() {
-# Argument types supported by this script:
-#
-# Build architecture - valid values are: x64, x86, arm, armel, arm64
-# Build Type - valid values are: debug, release
-#
-# Set the default arguments for build
-
-OSName=$(uname -s)
-if [ "$OSName" = "Darwin" ]; then
- # On OSX universal binaries make uname -m unreliable. The uname -m response changes
- # based on what hardware is being emulated.
- # Use sysctl instead
- if [ "$(sysctl -q -n hw.optional.arm64)" = "1" ]; then
- CPUName=arm64
- elif [ "$(sysctl -q -n hw.optional.x86_64)" = "1" ]; then
- CPUName=x86_64
- else
- CPUName=$(uname -m)
- fi
-else
- # Use uname to determine what the CPU is.
- CPUName=$(uname -p)
- # Some Linux platforms report unknown for platform, but the arch for machine.
- if [ "$CPUName" == "unknown" ]; then
- CPUName=$(uname -m)
- fi
-fi
-
-case $CPUName in
- i686|i386)
- echo "Unsupported CPU $CPUName detected, build might not succeed!"
- __BuildArch=x86
- __HostArch=x86
- ;;
-
- x86_64|amd64)
- __BuildArch=x64
- __HostArch=x64
- ;;
-
- armv7l)
- echo "Unsupported CPU $CPUName detected, build might not succeed!"
- __BuildArch=arm
- __HostArch=arm
- ;;
-
- aarch64|arm64)
- __BuildArch=arm64
- __HostArch=arm64
- ;;
-
- *)
- echo "Unknown CPU $CPUName detected, configuring as if for x64"
- __BuildArch=x64
- __HostArch=x64
- ;;
-esac
-
-# Use uname to determine what the OS is.
-OSName=$(uname -s)
-case $OSName in
- Linux)
- __BuildOS=Linux
- __HostOS=Linux
- ;;
-
- Darwin)
- __BuildOS=OSX
- __HostOS=OSX
- ;;
-
- FreeBSD)
- __BuildOS=FreeBSD
- __HostOS=FreeBSD
- ;;
-
- OpenBSD)
- __BuildOS=OpenBSD
- __HostOS=OpenBSD
- ;;
-
- NetBSD)
- __BuildOS=NetBSD
- __HostOS=NetBSD
- ;;
-
- SunOS)
- __BuildOS=SunOS
- __HostOS=SunOS
- ;;
-
- *)
- echo "Unsupported OS $OSName detected, configuring as if for Linux"
- __BuildOS=Linux
- __HostOS=Linux
- ;;
-esac
-
-while :; do
- if [ $# -le 0 ]; then
- break
- fi
- # support both "--" and "-" options
- opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')"
- case $opt in
- -\?|-h|-help)
- usage
- exit 1
- ;;
-
- -skipmanaged)
- __ManagedBuild=false
+ lowerI="$(echo "$1" | tr "[:upper:]" "[:lower:]")"
+ case "$lowerI" in
+ architecture|-architecture|-a)
+ __BuildArch="$(echo "$2" | tr "[:upper:]" "[:lower:]")"
+ __ShiftArgs=1
;;
- -skipnative)
- __NativeBuild=false
+ -binarylog|-bl|-clean|-integrationtest|-pack|-performancetest|-pipelineslog|-pl|-preparemachine|-publish|-r|-rebuild|-restore|-sign)
+ __ManagedBuildArgs="$__ManagedBuildArgs $1"
;;
- -build|-b)
- __ManagedBuild=true
- ;;
+ configuration|-configuration|-c)
+ _type="$(echo "$2" | tr "[:upper:]" "[:lower:]")"
+ if [[ "$_type" == "release" ]]; then
+ __BuildType=Release
+ elif [[ "$_type" = "checked" ]]; then
+ __BuildType=Checked
+ fi
- -test|-t)
- __Test=true
+ __ShiftArgs=1
;;
- -privatebuildpath)
- __PrivateBuildPath="$2"
- shift
+ -clean|-binarylog|-bl|-pipelineslog|-pl|-restore|-r|-rebuild|-pack|-integrationtest|-performancetest|-sign|-publish|-preparemachine)
+ __ManagedBuildArgs="$__ManagedBuildArgs $1"
;;
-dotnetruntimeversion)
__DotnetRuntimeVersion="$2"
- shift
+ __ShiftArgs=1
;;
-dotnetruntimedownloadversion)
__DotnetRuntimeDownloadVersion="$2"
- shift
+ __ShiftArgs=1
+ ;;
+
+ privatebuildpath|-privatebuildpath)
+ __PrivateBuildPath="$1"
;;
-runtimesourcefeed)
__RuntimeSourceFeed="$2"
- shift
+ __ShiftArgs=1
;;
-runtimesourcefeedkey)
__RuntimeSourceFeedKey="$2"
- shift
- ;;
-
- -ci)
- __CI=true
- __ManagedBuildArgs="$__ManagedBuildArgs $1"
- __TestArgs="$__TestArgs $1"
- ;;
-
- -projects)
- __ManagedBuildArgs="$__ManagedBuildArgs $1 $2"
- __TestArgs="$__TestArgs $1 $2"
- shift
- ;;
+ __ShiftArgs=1
+ ;;
- -verbosity)
- __Verbosity=$2
- shift
+ skipmanaged|-skipmanaged)
+ __ManagedBuild=0
;;
- -configuration|-c)
- __BuildType="$(to_lowercase "$2")"
- shift
+ skipnative|-skipnative)
+ __NativeBuild=0
;;
- -architecture|-a|-platform)
- __BuildArch="$(to_lowercase "$2")"
- shift
- ;;
-
- -rootfs)
- export ROOTFS_DIR="$2"
- shift
- ;;
-
- -portablebuild=false)
- __PortableBuild=0
- ;;
-
- -stripsymbols)
- __ExtraCmakeArgs="$__ExtraCmakeArgs -DSTRIP_SYMBOLS=true"
- ;;
-
- -clang*)
- __Compiler=clang
- # clangx.y or clang-x.y
- version="$(echo "$1" | tr -d '[:alpha:]-=')"
- parts=(${version//./ })
- __ClangMajorVersion="${parts[0]}"
- __ClangMinorVersion="${parts[1]}"
- if [[ -z "$__ClangMinorVersion" && "$__ClangMajorVersion" -le 6 ]]; then
- __ClangMinorVersion=0;
- fi
- ;;
-
- -clean|-binarylog|-bl|-pipelineslog|-pl|-restore|-r|-rebuild|-pack|-integrationtest|-performancetest|-sign|-publish|-preparemachine)
- __ManagedBuildArgs="$__ManagedBuildArgs $1"
+ test|-test)
+ __Test=1
;;
-warnaserror|-nodereuse)
__ManagedBuildArgs="$__ManagedBuildArgs $1 $2"
+ __ShiftArgs=1
;;
*)
__UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
;;
esac
+}
- shift
-done
+source "$__RepoRootDir"/eng/native/build-commons.sh
-if [ "$__BuildType" == "release" ]; then
- __BuildType=Release
-fi
-if [ "$__BuildType" == "debug" ]; then
- __BuildType=Debug
-fi
+__LogsDir="$__RootBinDir/log/$__BuildType"
+__ConfigTriplet="$__TargetOS.$__BuildArch.$__BuildType"
+__BinDir="$__RootBinDir/bin/$__ConfigTriplet"
+__ArtifactsIntermediatesDir="$__RootBinDir/obj"
+__IntermediatesDir="$__ArtifactsIntermediatesDir/$__ConfigTriplet"
-# Needs to be set for generate version source file/msbuild
-if [[ -z $NUGET_PACKAGES ]]; then
- if [[ $__CI == true ]]; then
- export NUGET_PACKAGES="$__ProjectRoot/.packages"
- else
- export NUGET_PACKAGES="$HOME/.nuget/packages"
- fi
-fi
+# Specify path to be set for CMAKE_INSTALL_PREFIX.
+# This is where all built libraries will copied to.
+__CMakeBinDir="$__BinDir"
+export __CMakeBinDir
-echo $NUGET_PACKAGES
+mkdir -p "$__IntermediatesDir"
+mkdir -p "$__LogsDir"
+mkdir -p "$__CMakeBinDir"
-__RootBinDir=$__ProjectRoot/artifacts
-__BinDir=$__RootBinDir/bin/$__BuildOS.$__BuildArch.$__BuildType
-__LogDir=$__RootBinDir/log/$__BuildOS.$__BuildArch.$__BuildType
-__IntermediatesDir=$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType
__ExtraCmakeArgs="$__ExtraCmakeArgs -DCLR_MANAGED_BINARY_DIR=$__RootBinDir/bin -DCLR_BUILD_TYPE=$__BuildType"
-__DotNetCli=$__ProjectRoot/.dotnet/dotnet
# Specify path to be set for CMAKE_INSTALL_PREFIX.
# This is where all built native libraries will copied to.
__PortableBuild=0
fi
-# Configure environment if we are doing a cross compile.
-if [ "${__BuildArch}" != "${__HostArch}" ]; then
- __CrossBuild=true
- export CROSSCOMPILE=1
- if [ "${__BuildOS}" != "OSX" ]; then
- if ! [[ -n "$ROOTFS_DIR" ]]; then
- echo "ERROR: ROOTFS_DIR not set for cross build"
- exit 1
- fi
- echo "ROOTFS_DIR: $ROOTFS_DIR"
- fi
-fi
-
-mkdir -p "$__IntermediatesDir"
-mkdir -p "$__LogDir"
-mkdir -p "$__CMakeBinDir"
-
-build_native()
-{
- platformArch="$1"
- intermediatesForBuild="$2"
- extraCmakeArguments="$3"
-
- # All set to commence the build
- echo "Commencing $__DistroRid build for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
-
- generator=""
- buildFile="Makefile"
- buildTool="make"
- scriptDir="$__ProjectRoot/eng"
-
- pushd "$intermediatesForBuild"
- echo "Invoking \"$scriptDir/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion \"$__ClangMinorVersion\" $platformArch "$scriptDir" $__BuildType $generator $extraCmakeArguments"
- "$scriptDir/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion "$__ClangMinorVersion" $platformArch "$scriptDir" $__BuildType $generator "$extraCmakeArguments"
- popd
-
- if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
- echo "Failed to generate build project!"
- exit 1
- fi
-
- # Check that the makefiles were created.
- pushd "$intermediatesForBuild"
-
- echo "Executing $buildTool install -j $__NumProc"
-
- $buildTool install -j $__NumProc | tee $__LogDir/make.log
- if [ $? != 0 ]; then
- echo "Failed to build."
- exit 1
- fi
-
- popd
-}
-
-initTargetDistroRid()
-{
- source "$__ProjectRoot/eng/init-distro-rid.sh"
-
- local passedRootfsDir=""
-
- # Only pass ROOTFS_DIR if cross is specified and the current platform is not OSX that doesn't use rootfs
- if [ $__CrossBuild == true -a "$__HostOS" != "OSX" ]; then
- passedRootfsDir=${ROOTFS_DIR}
- fi
-
- initDistroRidGlobal ${__BuildOS} ${__BuildArch} ${__PortableBuild} ${passedRootfsDir}
-}
-
#
# Managed build
#
-if [ $__ManagedBuild == true ]; then
+if [[ "$__ManagedBuild" == 1 ]]; then
echo "Commencing managed build for $__BuildType in $__RootBinDir/bin"
- "$__ProjectRoot/eng/common/build.sh" --build --configuration "$__BuildType" --verbosity "$__Verbosity" $__ManagedBuildArgs $__UnprocessedBuildArgs
- if [ $? != 0 ]; then
+ "$__RepoRootDir/eng/common/build.sh" --build --configuration "$__BuildType" $__CommonMSBuildArgs $__ManagedBuildArgs $__UnprocessedBuildArgs
+ if [ "$?" != 0 ]; then
exit 1
fi
fi
echo "RID: $__DistroRid"
-# Set default clang version
-if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
- if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
- __ClangMajorVersion=5
- __ClangMinorVersion=0
- elif [[ "$__BuildArch" == "arm64" && "$__DistroRid" == "linux-musl-arm64" ]]; then
- __ClangMajorVersion=9
- __ClangMinorVersion=
- else
- __ClangMajorVersion=3
- __ClangMinorVersion=9
- fi
-fi
-
#
# Setup LLDB paths for native build
#
if [ "$__HostOS" == "OSX" ]; then
- export LLDB_H=$__ProjectRoot/src/SOS/lldbplugin/swift-4.0
+ export LLDB_H="$__RepoRootDir"/src/SOS/lldbplugin/swift-4.0
export LLDB_LIB=$(xcode-select -p)/../SharedFrameworks/LLDB.framework/LLDB
export LLDB_PATH=$(xcode-select -p)/usr/bin/lldb
#
# Build native components
#
-
-if [ ! -e $__DotNetCli ]; then
- echo "dotnet cli not installed $__DotNetCli"
- exit 1
-fi
-
-if [ $__NativeBuild == true ]; then
+if [[ "$__NativeBuild" == 1 ]]; then
echo "Generating Version Source File"
- __GenerateVersionLog="$__LogDir/GenerateVersion.binlog"
+ __GenerateVersionLog="$__LogsDir/GenerateVersion.binlog"
- "$__ProjectRoot/eng/common/msbuild.sh" \
- $__ProjectRoot/eng/CreateVersionFile.csproj \
- /v:$__Verbosity \
+ "$__RepoRootDir/eng/common/msbuild.sh" \
+ $__RepoRootDir/eng/CreateVersionFile.csproj \
/bl:$__GenerateVersionLog \
/t:GenerateVersionFiles \
/restore \
/p:GenerateVersionSourceFile=true \
- /p:NativeVersionSourceFile="$__IntermediatesDir/version.cpp" \
+ /p:NativeVersionSourceFile="$__ArtifactsIntermediatesDir/_version.c" \
/p:Configuration="$__BuildType" \
/p:Platform="$__BuildArch" \
$__UnprocessedBuildArgs
exit 1
fi
- build_native "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs"
+ build_native "$__TargetOS" "$__BuildArch" "$__RepoRootDir" "$__IntermediatesDir" "install" "$__ExtraCmakeArgs" "diagnostic component" | tee "$__LogsDir"/make.log
fi
#
# Copy the native SOS binaries to where these tools expect for testing
#
-if [[ $__NativeBuild == true || $__Test == true ]]; then
+if [[ "$__NativeBuild" == 1 || "$__Test" == 1 ]]; then
__dotnet_sos=$__RootBinDir/bin/dotnet-sos/$__BuildType/netcoreapp3.1/publish/$__DistroRid
__dotnet_dump=$__RootBinDir/bin/dotnet-dump/$__BuildType/netcoreapp3.1/publish/$__DistroRid
# Run xunit tests
#
-if [ $__Test == true ]; then
- if [ $__CrossBuild != true ]; then
- if [ "$LLDB_PATH" == "" ]; then
+if [[ "$__Test" == 1 ]]; then
+ if [[ "$__CrossBuild" == 0 ]]; then
+ if [[ -z "$LLDB_PATH" ]]; then
export LLDB_PATH="$(which lldb-3.9.1 2> /dev/null)"
- if [ "$LLDB_PATH" == "" ]; then
+ if [[ -z "$LLDB_PATH" ]]; then
export LLDB_PATH="$(which lldb-3.9 2> /dev/null)"
- if [ "$LLDB_PATH" == "" ]; then
+ if [[ -z "$LLDB_PATH" ]]; then
export LLDB_PATH="$(which lldb-4.0 2> /dev/null)"
- if [ "$LLDB_PATH" == "" ]; then
+ if [[ -z "$LLDB_PATH" ]]; then
export LLDB_PATH="$(which lldb-5.0 2> /dev/null)"
- if [ "$LLDB_PATH" == "" ]; then
+ if [[ -z "$LLDB_PATH" ]]; then
export LLDB_PATH="$(which lldb 2> /dev/null)"
fi
fi
fi
fi
- if [ "$GDB_PATH" == "" ]; then
+ if [[ -z "$GDB_PATH" ]]; then
export GDB_PATH="$(which gdb 2> /dev/null)"
fi
echo "lldb: '$LLDB_PATH' gdb: '$GDB_PATH'"
- "$__ProjectRoot/eng/common/build.sh" \
+ "$__RepoRootDir/eng/common/build.sh" \
--test \
--configuration "$__BuildType" \
- --verbosity "$__Verbosity" \
- /bl:$__LogDir/Test.binlog \
+ /bl:"$__LogsDir"/Test.binlog \
/p:BuildArch="$__BuildArch" \
/p:PrivateBuildPath="$__PrivateBuildPath" \
/p:DotnetRuntimeVersion="$__DotnetRuntimeVersion" \
/p:DotnetRuntimeDownloadVersion="$__DotnetRuntimeDownloadVersion" \
/p:RuntimeSourceFeed="$__RuntimeSourceFeed" \
/p:RuntimeSourceFeedKey="$__RuntimeSourceFeedKey" \
- $__TestArgs
+ $__CommonMSBuildArgs
if [ $? != 0 ]; then
exit 1
dockerImage: ''
# Optional: ROOTFS_DIR to use
crossrootfsDir: ''
+ crossbuild: false
# Optional: test only job if true
testOnly: false
buildAndSkipTest: false
- _HelixSource: pr/dotnet/arcade/$(Build.SourceBranch)
# This is only required for cross builds.
- - ${{ if eq(parameters.crossrootfsDir, '') }}:
- - _RootFs: ''
- - ${{ if ne(parameters.crossrootfsDir, '') }}:
- - _RootFs: --rootfs ${{ parameters.crossrootfsDir }}
+ - ${{ if and(eq(parameters.crossbuild, false), eq(parameters.crossrootfsDir, '')) }}:
+ - _Cross: ''
+ - ${{ if or(eq(parameters.crossbuild, true), ne(parameters.crossrootfsDir, '')) }}:
+ - _Cross: -cross
steps:
- ${{ if eq(parameters.osGroup, 'Linux') }}:
- script: $(_dockerEnv) $(_buildScript)
-configuration $(_BuildConfig)
-architecture $(_BuildArch)
+ $(_Cross)
$(_TestArgs)
- $(_RootFs)
/p:OfficialBuildId=$(BUILD.BUILDNUMBER)
$(_InternalInstallArgs)
displayName: Build / Test
condition: succeeded()
+ env:
+ ROOTFS_DIR: ${{ parameters.crossrootfsDir }}
- ${{ if ne(variables['System.TeamProject'], 'public') }}:
- task: CopyFiles@2
source scl_source enable python27 devtoolset-2
fi
fi
+
+ # We are using old (2019) centos image in the CI with old cmake (2.8).
+ # Upgrading to 2021 centos image was failing SOS tests which rely on
+ # lldb REPL and ptrace etc. e.g. from test attachment logs:
+ #
+ # 00:00.136: error: process launch failed: 'A' packet returned an error: 8
+ # 00:00.136:
+ # 00:00.136: <END_COMMAND_ERROR>
+ #System.Exception: 'process launch -s' FAILED
+ #
+ # so we will keep using old image for now and install newer cmake as a workaround instead..
+ # FIXME: delete this comment and the next `if` block once centos image is upgraded.
+ if [ "$ID" = "centos" ]; then
+ # upgrade cmake
+ requiredversion=3.6.2
+ cmakeversion="$(cmake --version | head -1)"
+ currentversion="${cmakeversion##* }"
+ if ! printf '%s\n' "$requiredversion" "$currentversion" | sort --version-sort --check 2>/dev/null; then
+ echo "Old cmake version found: $currentversion, minimal requirement is $requiredversion. Upgrading to 3.15.5 .."
+ curl -sSL -o /tmp/cmake-install.sh https://github.com/Kitware/CMake/releases/download/v3.15.5/cmake-3.15.5-Linux-$(uname -m).sh
+ mkdir "$HOME/.cmake"
+ bash /tmp/cmake-install.sh --skip-license --exclude-subdir --prefix="$HOME/.cmake"
+ PATH="$HOME/.cmake/bin:$PATH"
+ export PATH
+ cmakeversion="$(cmake --version | head -1)"
+ newversion="${cmakeversion##* }"
+ echo "New cmake version is: $newversion"
+ fi
+ fi
fi
-"$scriptroot/build.sh" --restore --prepareMachine --ci --stripsymbols $@
+"$scriptroot/build.sh" -restore -prepareMachine -ci $@
if [[ $? != 0 ]]; then
exit 1
fi
+++ /dev/null
-SET (CMAKE_C_FLAGS_INIT "-Wall -std=c11")
-SET (CMAKE_C_FLAGS_DEBUG_INIT "-g -O0")
-SET (CLR_C_FLAGS_CHECKED_INIT "-g -O1")
-# Refer to the below instruction to support __thread with -O2/-O3 on Linux/ARM
-# https://github.com/dotnet/runtime/blob/main/docs/workflow/building/coreclr/linux-instructions.md
-SET (CMAKE_C_FLAGS_RELEASE_INIT "-g -O1")
-SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -O1")
-
-SET (CMAKE_CXX_FLAGS_INIT "-Wall -Wno-null-conversion -std=c++11")
-SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g -O0")
-SET (CLR_CXX_FLAGS_CHECKED_INIT "-g -O1")
-SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-g -O1")
-SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g -O1")
-
-SET (CLR_DEFINES_DEBUG_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
-SET (CLR_DEFINES_CHECKED_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
-SET (CLR_DEFINES_RELEASE_INIT NDEBUG URTBLDENV_FRIENDLY=Retail)
-SET (CLR_DEFINES_RELWITHDEBINFO_INIT NDEBUG URTBLDENV_FRIENDLY=Retail)
-
-SET (CMAKE_INSTALL_PREFIX $ENV{__CMakeBinDir})
+++ /dev/null
-SET (CMAKE_C_FLAGS_INIT "-Wall -std=c11")
-SET (CMAKE_C_FLAGS_DEBUG_INIT "-g -O0")
-SET (CLR_C_FLAGS_CHECKED_INIT "-g -O2")
-# Refer to the below instruction to support __thread with -O2/-O3 on Linux/ARM
-# https://github.com/dotnet/runtime/blob/main/docs/workflow/building/coreclr/linux-instructions.md
-SET (CMAKE_C_FLAGS_RELEASE_INIT "-g -O3")
-SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -O2")
-
-SET (CMAKE_CXX_FLAGS_INIT "-Wall -Wno-null-conversion -std=c++11")
-SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g -O0")
-SET (CLR_CXX_FLAGS_CHECKED_INIT "-g -O2")
-SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-g -O3")
-SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g -O2")
-
-SET (CLR_DEFINES_DEBUG_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
-SET (CLR_DEFINES_CHECKED_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
-SET (CLR_DEFINES_RELEASE_INIT NDEBUG URTBLDENV_FRIENDLY=Retail)
-SET (CLR_DEFINES_RELWITHDEBINFO_INIT NDEBUG URTBLDENV_FRIENDLY=Retail)
-
-SET (CMAKE_INSTALL_PREFIX $ENV{__CMakeBinDir})
[switch] $ci,
[switch] $prepareMachine,
[switch] $excludePrereleaseVS,
+ [string] $msbuildEngine = $null,
[Parameter(ValueFromRemainingArguments=$true)][String[]]$extraArgs
)
# Wait time between check for system load
$SecondsBetweenLoadChecks = 10
+if (!$InputPath -or !(Test-Path $InputPath)){
+ Write-Host "No files to validate."
+ ExitWithExitCode 0
+}
+
$ValidatePackage = {
param(
[string] $PackagePath # Full path to a Symbols.NuGet package
[Parameter(Mandatory = $true)][string] $DotnetSymbolVersion, # Version of dotnet symbol to use
[Parameter(Mandatory = $false)][switch] $CheckForWindowsPdbs, # If we should check for the existence of windows pdbs in addition to portable PDBs
[Parameter(Mandatory = $false)][switch] $ContinueOnError, # If we should keep checking symbols after an error
- [Parameter(Mandatory = $false)][switch] $Clean # Clean extracted symbols directory after checking symbols
+ [Parameter(Mandatory = $false)][switch] $Clean, # Clean extracted symbols directory after checking symbols
+ [Parameter(Mandatory = $false)][string] $SymbolExclusionFile # Exclude the symbols in the file from publishing to symbol server
)
+. $PSScriptRoot\..\tools.ps1
# Maximum number of jobs to run in parallel
$MaxParallelJobs = 16
$WindowsPdbVerificationParam = "--windows-pdbs"
}
+$ExclusionSet = New-Object System.Collections.Generic.HashSet[string];
+
+if (!$InputPath -or !(Test-Path $InputPath)){
+ Write-Host "No symbols to validate."
+ ExitWithExitCode 0
+}
+
+#Check if the path exists
+if ($SymbolExclusionFile -and (Test-Path $SymbolExclusionFile)){
+ [string[]]$Exclusions = Get-Content "$SymbolExclusionFile"
+ $Exclusions | foreach { if($_ -and $_.Trim()){$ExclusionSet.Add($_)} }
+}
+else{
+ Write-Host "Symbol Exclusion file does not exists. No symbols to exclude."
+}
+
$CountMissingSymbols = {
param(
[string] $PackagePath, # Path to a NuGet package
[string] $WindowsPdbVerificationParam # If we should check for the existence of windows pdbs in addition to portable PDBs
)
- . $using:PSScriptRoot\..\tools.ps1
-
Add-Type -AssemblyName System.IO.Compression.FileSystem
Write-Host "Validating $PackagePath "
# Save the output and get diagnostic output
$output = & $dotnetSymbolExe --symbols --modules $WindowsPdbVerificationParam $TargetServerParam $FullPath -o $SymbolsPath --diagnostics | Out-String
- if (Test-Path $PdbPath) {
- return 'PDB'
+ if ((Test-Path $PdbPath) -and (Test-path $SymbolPath)) {
+ return 'Module and PDB for Module'
}
- elseif (Test-Path $NGenPdb) {
- return 'NGen PDB'
+ elseif ((Test-Path $NGenPdb) -and (Test-Path $PdbPath) -and (Test-Path $SymbolPath)) {
+ return 'Dll, PDB and NGen PDB'
}
- elseif (Test-Path $SODbg) {
- return 'DBG for SO'
+ elseif ((Test-Path $SODbg) -and (Test-Path $SymbolPath)) {
+ return 'So and DBG for SO'
}
- elseif (Test-Path $DylibDwarf) {
- return 'Dwarf for Dylib'
+ elseif ((Test-Path $DylibDwarf) -and (Test-Path $SymbolPath)) {
+ return 'Dylib and Dwarf for Dylib'
}
elseif (Test-Path $SymbolPath) {
return 'Module'
return $null
}
- $FileGuid = New-Guid
- $ExpandedSymbolsPath = Join-Path -Path $SymbolsPath -ChildPath $FileGuid
-
- $SymbolsOnMSDL = & $FirstMatchingSymbolDescriptionOrDefault `
- -FullPath $FileName `
- -TargetServerParam '--microsoft-symbol-server' `
- -SymbolsPath "$ExpandedSymbolsPath-msdl" `
- -WindowsPdbVerificationParam $WindowsPdbVerificationParam
- $SymbolsOnSymWeb = & $FirstMatchingSymbolDescriptionOrDefault `
- -FullPath $FileName `
- -TargetServerParam '--internal-server' `
- -SymbolsPath "$ExpandedSymbolsPath-symweb" `
- -WindowsPdbVerificationParam $WindowsPdbVerificationParam
-
- Write-Host -NoNewLine "`t Checking file " $FileName "... "
-
- if ($SymbolsOnMSDL -ne $null -and $SymbolsOnSymWeb -ne $null) {
- Write-Host "Symbols found on MSDL ($SymbolsOnMSDL) and SymWeb ($SymbolsOnSymWeb)"
+ $FileRelativePath = $FileName.Replace("$ExtractPath\", "")
+ if (($($using:ExclusionSet) -ne $null) -and ($($using:ExclusionSet).Contains($FileRelativePath) -or ($($using:ExclusionSet).Contains($FileRelativePath.Replace("\", "/"))))){
+ Write-Host "Skipping $FileName from symbol validation"
}
- else {
- $MissingSymbols++
- if ($SymbolsOnMSDL -eq $null -and $SymbolsOnSymWeb -eq $null) {
- Write-Host 'No symbols found on MSDL or SymWeb!'
+ else {
+ $FileGuid = New-Guid
+ $ExpandedSymbolsPath = Join-Path -Path $SymbolsPath -ChildPath $FileGuid
+
+ $SymbolsOnMSDL = & $FirstMatchingSymbolDescriptionOrDefault `
+ -FullPath $FileName `
+ -TargetServerParam '--microsoft-symbol-server' `
+ -SymbolsPath "$ExpandedSymbolsPath-msdl" `
+ -WindowsPdbVerificationParam $WindowsPdbVerificationParam
+ $SymbolsOnSymWeb = & $FirstMatchingSymbolDescriptionOrDefault `
+ -FullPath $FileName `
+ -TargetServerParam '--internal-server' `
+ -SymbolsPath "$ExpandedSymbolsPath-symweb" `
+ -WindowsPdbVerificationParam $WindowsPdbVerificationParam
+
+ Write-Host -NoNewLine "`t Checking file " $FileName "... "
+
+ if ($SymbolsOnMSDL -ne $null -and $SymbolsOnSymWeb -ne $null) {
+ Write-Host "Symbols found on MSDL ($SymbolsOnMSDL) and SymWeb ($SymbolsOnSymWeb)"
}
else {
- if ($SymbolsOnMSDL -eq $null) {
- Write-Host 'No symbols found on MSDL!'
+ $MissingSymbols++
+
+ if ($SymbolsOnMSDL -eq $null -and $SymbolsOnSymWeb -eq $null) {
+ Write-Host 'No symbols found on MSDL or SymWeb!'
}
else {
- Write-Host 'No symbols found on SymWeb!'
+ if ($SymbolsOnMSDL -eq $null) {
+ Write-Host 'No symbols found on MSDL!'
+ }
+ else {
+ Write-Host 'No symbols found on SymWeb!'
+ }
}
}
}
# For some tools, add default and automatic args.
if ($tool.Name -eq 'credscan') {
if ($targetDirectory) {
- $tool.Args += "TargetDirectory < $TargetDirectory"
+ $tool.Args += "`"TargetDirectory < $TargetDirectory`""
}
- $tool.Args += "OutputType < pre"
+ $tool.Args += "`"OutputType < pre`""
$tool.Args += $CrScanAdditionalRunConfigParams
} elseif ($tool.Name -eq 'policheck') {
if ($targetDirectory) {
- $tool.Args += "Target < $TargetDirectory"
+ $tool.Args += "`"Target < $TargetDirectory`""
}
$tool.Args += $PoliCheckAdditionalRunConfigParams
}
- name: GuardianPackagesConfigFile
value: $(Build.SourcesDirectory)\eng\common\sdl\packages.config
pool:
- # To extract archives (.tar.gz, .zip), we need access to "tar", added in Windows 10/2019.
- ${{ if eq(parameters.extractArchiveArtifacts, 'false') }}:
- name: Hosted VS2017
- ${{ if ne(parameters.extractArchiveArtifacts, 'false') }}:
- vmImage: windows-2019
+ vmImage: windows-2019
steps:
- checkout: self
clean: true
# Optional: A defined YAML pool - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#pool
pool:
- vmImage: vs2017-win2016
+ vmImage: 'windows-2019'
CeapexPat: $(dn-bot-ceapex-package-r) # PAT for the loc AzDO instance https://dev.azure.com/ceapex
GithubPat: $(BotAccount-dotnet-bot-repo-PAT)
SourcesDirectory: $(Build.SourcesDirectory)
CreatePr: true
AutoCompletePr: false
+ ReusePr: true
UseLfLineEndings: true
UseCheckedInLocProjectJson: false
LanguageSet: VS_Main_Languages
${{ if eq(parameters.CreatePr, true) }}:
isAutoCompletePrSelected: ${{ parameters.AutoCompletePr }}
isUseLfLineEndingsSelected: ${{ parameters.UseLfLineEndings }}
+ ${{ if eq(parameters.RepoType, 'gitHub') }}:
+ isShouldReusePrSelected: ${{ parameters.ReusePr }}
packageSourceAuth: patAuth
patVariable: ${{ parameters.CeapexPat }}
${{ if eq(parameters.RepoType, 'gitHub') }}:
# container and pool.
platform: {}
- # The default VM host AzDO pool. This should be capable of running Docker containers: almost all
- # source-build builds run in Docker, including the default managed platform.
- defaultContainerHostPool:
- vmImage: ubuntu-20.04
-
jobs:
- job: ${{ parameters.jobNamePrefix }}_${{ parameters.platform.name }}
displayName: Source-Build (${{ parameters.platform.name }})
container: ${{ parameters.platform.container }}
${{ if eq(parameters.platform.pool, '') }}:
- pool: ${{ parameters.defaultContainerHostPool }}
+ # The default VM host AzDO pool. This should be capable of running Docker containers: almost all
+ # source-build builds run in Docker, including the default managed platform.
+ pool:
+ ${{ if eq(variables['System.TeamProject'], 'public') }}:
+ name: NetCore1ESPool-Public
+ demands: ImageOverride -equals Build.Ubuntu.1804.Amd64.Open
+ ${{ if eq(variables['System.TeamProject'], 'internal') }}:
+ name: NetCore1ESPool-Internal
+ demands: ImageOverride -equals Build.Ubuntu.1804.Amd64
${{ if ne(parameters.platform.pool, '') }}:
pool: ${{ parameters.platform.pool }}
sourceIndexBuildCommand: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "eng/common/build.ps1 -restore -build -binarylog -ci"
preSteps: []
binlogPath: artifacts/log/Debug/Build.binlog
- pool:
- vmImage: vs2017-win2016
condition: ''
dependsOn: ''
- ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- group: source-dot-net stage1 variables
- pool: ${{ parameters.pool }}
+ pool:
+ ${{ if eq(variables['System.TeamProject'], 'public') }}:
+ name: NetCore1ESPool-Public
+ demands: ImageOverride -equals Build.Server.Amd64.VS2019.Open
+ ${{ if eq(variables['System.TeamProject'], 'internal') }}:
+ name: NetCore1ESPool-Internal
+ demands: ImageOverride -equals Build.Server.Amd64.VS2019
steps:
- ${{ each preStep in parameters.preSteps }}:
- ${{ preStep }}
- ${{ if eq(parameters.enableSourceBuild, true) }}:
- Source_Build_Complete
pool:
- vmImage: vs2017-win2016
+ vmImage: 'windows-2019'
runAsPublic: ${{ parameters.runAsPublic }}
publishUsingPipelines: ${{ parameters.enablePublishUsingPipelines }}
enablePublishBuildArtifacts: ${{ parameters.enablePublishBuildArtifacts }}
dependsOn:
- Asset_Registry_Publish
pool:
- vmImage: vs2017-win2016
+ vmImage: 'windows-2019'
+++ /dev/null
-set(CROSS_ROOTFS $ENV{ROOTFS_DIR})
-
-set(TARGET_ARCH_NAME $ENV{TARGET_BUILD_ARCH})
-set(CMAKE_SYSTEM_NAME Linux)
-set(CMAKE_SYSTEM_VERSION 1)
-
-if(TARGET_ARCH_NAME STREQUAL "armel")
- set(CMAKE_SYSTEM_PROCESSOR armv7l)
- set(TOOLCHAIN "arm-linux-gnueabi")
- if("$ENV{__DistroRid}" MATCHES "tizen.*")
- set(TIZEN_TOOLCHAIN "armv7l-tizen-linux-gnueabi/6.2.1")
- endif()
-elseif(TARGET_ARCH_NAME STREQUAL "arm")
- set(CMAKE_SYSTEM_PROCESSOR armv7l)
- if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf)
- set(TOOLCHAIN "armv6-alpine-linux-musleabihf")
- else()
- set(TOOLCHAIN "arm-linux-gnueabihf")
- endif()
-elseif(TARGET_ARCH_NAME STREQUAL "arm64")
- set(CMAKE_SYSTEM_PROCESSOR aarch64)
- if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl)
- set(TOOLCHAIN "aarch64-alpine-linux-musl")
- else()
- set(TOOLCHAIN "aarch64-linux-gnu")
- endif()
-elseif(TARGET_ARCH_NAME STREQUAL "x86")
- set(CMAKE_SYSTEM_PROCESSOR i686)
- set(TOOLCHAIN "i686-linux-gnu")
-elseif(TARGET_ARCH_NAME STREQUAL "mips64")
- set(CMAKE_SYSTEM_PROCESSOR mips64)
- set(TOOLCHAIN "mips64el-linux-gnuabi64")
-else()
- message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, arm64, mips64 and x86 are supported!")
-endif()
-
-if(DEFINED ENV{TOOLCHAIN})
- set(TOOLCHAIN $ENV{TOOLCHAIN})
-endif()
-
-# This gets called with CLR_CMAKE_COMPILER set on the first invocation
-# but the cmake variable is not getting populated into other calls.
-# Use environment variable to keep CLR_CMAKE_COMPILER around.
-if (NOT DEFINED CLR_CMAKE_COMPILER)
- set(CLR_CMAKE_COMPILER $ENV{CLR_CMAKE_COMPILER})
-else()
- set(ENV{CLR_CMAKE_COMPILER} ${CLR_CMAKE_COMPILER})
-endif()
-
-# Specify include paths
-if(TARGET_ARCH_NAME STREQUAL "armel")
- if(DEFINED TIZEN_TOOLCHAIN)
- include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}/include/c++/)
- include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}/include/c++/armv7l-tizen-linux-gnueabi)
- endif()
-endif()
-
-# add_compile_param - adds only new options without duplicates.
-# arg0 - list with result options, arg1 - list with new options.
-# arg2 - optional argument, quick summary string for optional using CACHE FORCE mode.
-macro(add_compile_param)
- if(NOT ${ARGC} MATCHES "^(2|3)$")
- message(FATAL_ERROR "Wrong using add_compile_param! Two or three parameters must be given! See add_compile_param description.")
- endif()
- foreach(OPTION ${ARGV1})
- if(NOT ${ARGV0} MATCHES "${OPTION}($| )")
- set(${ARGV0} "${${ARGV0}} ${OPTION}")
- if(${ARGC} EQUAL "3") # CACHE FORCE mode
- set(${ARGV0} "${${ARGV0}}" CACHE STRING "${ARGV2}" FORCE)
- endif()
- endif()
- endforeach()
-endmacro()
-
-# Specify link flags
-add_compile_param(CROSS_LINK_FLAGS "--sysroot=${CROSS_ROOTFS}")
-if (CLR_CMAKE_COMPILER STREQUAL "Clang")
- add_compile_param(CROSS_LINK_FLAGS "--gcc-toolchain=${CROSS_ROOTFS}/usr")
- add_compile_param(CROSS_LINK_FLAGS "--target=${TOOLCHAIN}")
-endif()
-
-if(TARGET_ARCH_NAME STREQUAL "armel")
- if(DEFINED TIZEN_TOOLCHAIN) # For Tizen only
- add_compile_param(CROSS_LINK_FLAGS "-B${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
- add_compile_param(CROSS_LINK_FLAGS "-L${CROSS_ROOTFS}/lib")
- add_compile_param(CROSS_LINK_FLAGS "-L${CROSS_ROOTFS}/usr/lib")
- add_compile_param(CROSS_LINK_FLAGS "-L${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
- endif()
-elseif(TARGET_ARCH_NAME STREQUAL "x86")
- add_compile_param(CROSS_LINK_FLAGS "-m32")
-endif()
-
-add_compile_param(CMAKE_EXE_LINKER_FLAGS "${CROSS_LINK_FLAGS}" "TOOLCHAIN_EXE_LINKER_FLAGS")
-add_compile_param(CMAKE_SHARED_LINKER_FLAGS "${CROSS_LINK_FLAGS}" "TOOLCHAIN_EXE_LINKER_FLAGS")
-add_compile_param(CMAKE_MODULE_LINKER_FLAGS "${CROSS_LINK_FLAGS}" "TOOLCHAIN_EXE_LINKER_FLAGS")
-
-# Specify compile options
-add_compile_options("--sysroot=${CROSS_ROOTFS}")
-if (CLR_CMAKE_COMPILER STREQUAL "Clang")
- add_compile_options("--target=${TOOLCHAIN}")
- add_compile_options("--gcc-toolchain=${CROSS_ROOTFS}/usr")
-endif()
-
-if(TARGET_ARCH_NAME MATCHES "^(arm|armel|arm64)$")
- set(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN})
- set(CMAKE_CXX_COMPILER_TARGET ${TOOLCHAIN})
- set(CMAKE_ASM_COMPILER_TARGET ${TOOLCHAIN})
-endif()
-
-if(TARGET_ARCH_NAME MATCHES "^(arm|armel)$")
- add_compile_options(-mthumb)
- add_compile_options(-mfpu=vfpv3)
- if(TARGET_ARCH_NAME STREQUAL "armel")
- add_compile_options(-mfloat-abi=softfp)
- if(DEFINED TIZEN_TOOLCHAIN)
- add_compile_options(-Wno-deprecated-declarations) # compile-time option
- add_compile_options(-D__extern_always_inline=inline) # compile-time option
- endif()
- endif()
-elseif(TARGET_ARCH_NAME STREQUAL "x86")
- add_compile_options(-m32)
- add_compile_options(-Wno-error=unused-command-line-argument)
-endif()
-
-# Set LLDB include and library paths
-if(TARGET_ARCH_NAME MATCHES "^(arm|armel|x86)$")
- if(TARGET_ARCH_NAME STREQUAL "x86")
- set(LLVM_CROSS_DIR "$ENV{LLVM_CROSS_HOME}")
- else() # arm/armel case
- set(LLVM_CROSS_DIR "$ENV{LLVM_ARM_HOME}")
- endif()
- if(LLVM_CROSS_DIR)
- set(WITH_LLDB_LIBS "${LLVM_CROSS_DIR}/lib/" CACHE STRING "")
- set(WITH_LLDB_INCLUDES "${LLVM_CROSS_DIR}/include" CACHE STRING "")
- set(LLDB_H "${WITH_LLDB_INCLUDES}" CACHE STRING "")
- set(LLDB "${LLVM_CROSS_DIR}/lib/liblldb.so" CACHE STRING "")
- else()
- if(TARGET_ARCH_NAME STREQUAL "x86")
- set(WITH_LLDB_LIBS "${CROSS_ROOTFS}/usr/lib/i386-linux-gnu" CACHE STRING "")
- set(CHECK_LLVM_DIR "${CROSS_ROOTFS}/usr/lib/llvm-3.8/include")
- if(EXISTS "${CHECK_LLVM_DIR}" AND IS_DIRECTORY "${CHECK_LLVM_DIR}")
- set(WITH_LLDB_INCLUDES "${CHECK_LLVM_DIR}")
- else()
- set(WITH_LLDB_INCLUDES "${CROSS_ROOTFS}/usr/lib/llvm-3.6/include")
- endif()
- else() # arm/armel case
- set(WITH_LLDB_LIBS "${CROSS_ROOTFS}/usr/lib/${TOOLCHAIN}" CACHE STRING "")
- set(WITH_LLDB_INCLUDES "${CROSS_ROOTFS}/usr/lib/llvm-3.6/include" CACHE STRING "")
- endif()
- endif()
-endif()
-
-set(CMAKE_FIND_ROOT_PATH "${CROSS_ROOTFS}")
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
+++ /dev/null
-set(CROSS_ROOTFS $ENV{ROOTFS_DIR})
-set(TARGET_ARCH_NAME $ENV{TARGET_BUILD_ARCH})
-
-macro(set_cache_value)
- set(${ARGV0} ${ARGV1} CACHE STRING "Result from TRY_RUN" FORCE)
- set(${ARGV0}__TRYRUN_OUTPUT "dummy output" CACHE STRING "Output from TRY_RUN" FORCE)
-endmacro()
-
-if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv7-alpine-linux-musleabihf OR
- EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR
- EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl)
-
- SET(ALPINE_LINUX 1)
-elseif(EXISTS /System/Library/CoreServices)
- set(DARWIN 1)
-endif()
-
-if(DARWIN)
- if(TARGET_ARCH_NAME MATCHES "^(arm64|x64)$")
- set_cache_value(FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL_EXITCODE 1)
- set_cache_value(GETPWUID_R_SETS_ERRNO_EXITCODE 1)
- set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 1)
- set_cache_value(HAVE_BROKEN_FIFO_KEVENT_EXITCODE 1)
- set_cache_value(HAVE_BROKEN_FIFO_SELECT_EXITCODE 1)
- set_cache_value(HAVE_CLOCK_MONOTONIC_COARSE_EXITCODE 1)
- set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0)
- set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0)
- set_cache_value(HAVE_CLOCK_GETTIME_NSEC_NP_EXITCODE 0)
- set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0)
- set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0)
- set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 0)
- set_cache_value(HAVE_COMPATIBLE_EXP_EXITCODE 1)
- set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 0)
- set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 1)
- set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0)
- set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0)
- set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0)
- set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 1)
- set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 0)
- set_cache_value(HAVE_MMAP_DEV_ZERO_EXITCODE 1)
- set_cache_value(HAVE_PROCFS_CTL_EXITCODE 1)
- set_cache_value(HAVE_PROCFS_MAPS_EXITCODE 1)
- set_cache_value(HAVE_PROCFS_STATUS_EXITCODE 1)
- set_cache_value(HAVE_PROCFS_STAT_EXITCODE 1)
- set_cache_value(HAVE_SCHED_GETCPU_EXITCODE 1)
- set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0)
- set_cache_value(HAVE_VALID_NEGATIVE_INF_POW_EXITCODE 0)
- set_cache_value(HAVE_VALID_POSITIVE_INF_POW_EXITCODE 0)
- set_cache_value(HAVE_WORKING_CLOCK_GETTIME_EXITCODE 0)
- set_cache_value(HAVE_WORKING_GETTIMEOFDAY_EXITCODE 0)
- set_cache_value(MMAP_ANON_IGNORES_PROTECTION_EXITCODE 1)
- set_cache_value(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS_EXITCODE 1)
- set_cache_value(PTHREAD_CREATE_MODIFIES_ERRNO_EXITCODE 1)
- set_cache_value(REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 1)
- set_cache_value(SEM_INIT_MODIFIES_ERRNO_EXITCODE 1)
- set_cache_value(SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 1)
- set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 0)
- set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 1)
- else()
- message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm64 or x64 is supported for OSX cross build!")
- endif()
-elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|mips64|x86)$")
- set_cache_value(FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL_EXITCODE 1)
- set_cache_value(GETPWUID_R_SETS_ERRNO_EXITCODE 0)
- set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 0)
- set_cache_value(HAVE_CLOCK_MONOTONIC_COARSE_EXITCODE 0)
- set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0)
- set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0)
- set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0)
- set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0)
- set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 0)
- set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 1)
- set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 1)
- set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0)
- set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0)
- set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0)
- set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 0)
- set_cache_value(HAVE_MMAP_DEV_ZERO_EXITCODE 0)
- set_cache_value(HAVE_PROCFS_CTL_EXITCODE 1)
- set_cache_value(HAVE_PROCFS_MAPS_EXITCODE 0)
- set_cache_value(HAVE_PROCFS_STATUS_EXITCODE 0)
- set_cache_value(HAVE_PROCFS_STAT_EXITCODE 0)
- set_cache_value(HAVE_SCHED_GETCPU_EXITCODE 0)
- set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0)
- set_cache_value(HAVE_VALID_NEGATIVE_INF_POW_EXITCODE 0)
- set_cache_value(HAVE_VALID_POSITIVE_INF_POW_EXITCODE 0)
- set_cache_value(HAVE_WORKING_CLOCK_GETTIME_EXITCODE 0)
- set_cache_value(HAVE_WORKING_GETTIMEOFDAY_EXITCODE 0)
- set_cache_value(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS_EXITCODE 1)
- set_cache_value(PTHREAD_CREATE_MODIFIES_ERRNO_EXITCODE 1)
- set_cache_value(REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 1)
- set_cache_value(SEM_INIT_MODIFIES_ERRNO_EXITCODE 1)
-
-
- if(ALPINE_LINUX)
- set_cache_value(SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 0)
- set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 1)
- set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 1)
- else()
- set_cache_value(SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 1)
- set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 0)
- set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 0)
- endif()
-
-else()
- message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, arm64, mips64 and x86 are supported!")
-endif()
-
-if(TARGET_ARCH_NAME STREQUAL "x86")
- set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0)
-endif()
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <!-- This project exists purely to work around Arcade
+ behavior. Arcade knows how to restore tasks needed for
+ publishing to blob feeds, but it requires a project file that
+ imports nuget restore targets to be specified for this to
+ work. See details in
+ https://github.com/dotnet/arcade/commit/f657be5cb7cd4920334dd9162173b131211a1e17#r31728598.
+ -->
+
+ <PropertyGroup>
+ <TargetFramework>net6.0</TargetFramework>
+ </PropertyGroup>
+
+ <Import Project="versioning.targets" />
+
+</Project>
+++ /dev/null
-#!/usr/bin/env bash
-#
-# This file invokes cmake and generates the build system for Clang.
-#
-
-if [ $# -lt 5 ]
-then
- echo "Usage..."
- echo "gen-buildsys-clang.sh <path to top level CMakeLists.txt> <ClangMajorVersion> <ClangMinorVersion> <Architecture> <ScriptDirectory> [build flavor] [coverage] [ninja] [scan-build] [cmakeargs]"
- echo "Specify the path to the top level CMake file - <ProjectK>/src/NDP"
- echo "Specify the clang version to use, split into major and minor version"
- echo "Specify the target architecture."
- echo "Specify the script directory."
- echo "Optionally specify the build configuration (flavor.) Defaults to DEBUG."
- echo "Optionally specify 'coverage' to enable code coverage build."
- echo "Optionally specify 'scan-build' to enable build with clang static analyzer."
- echo "Target ninja instead of make. ninja must be on the PATH."
- echo "Pass additional arguments to CMake call."
- exit 1
-fi
-
-# Set up the environment to be used for building with clang.
-if command -v "clang-$2.$3" > /dev/null
- then
- desired_llvm_version="-$2.$3"
-elif command -v "clang$2$3" > /dev/null
- then
- desired_llvm_version="$2$3"
-elif command -v "clang-$2$3" > /dev/null
- then
- desired_llvm_version="-$2$3"
-elif command -v "clang-$2" > /dev/null
- then
- desired_llvm_version="-$2"
-elif command -v "clang$2" > /dev/null
- then
- desired_llvm_version="$2"
-elif command -v clang > /dev/null
- then
- desired_llvm_version=
-else
- echo "Unable to find Clang Compiler"
- exit 1
-fi
-
-export CC="$(command -v clang$desired_llvm_version)"
-export CXX="$(command -v clang++$desired_llvm_version)"
-
-build_arch="$4"
-script_dir="$5"
-buildtype=DEBUG
-code_coverage=OFF
-build_tests=OFF
-scan_build=OFF
-generator="Unix Makefiles"
-__UnprocessedCMakeArgs=""
-
-for i in "${@:6}"; do
- upperI="$(echo $i | awk '{print toupper($0)}')"
- case $upperI in
- # Possible build types are DEBUG, CHECKED, RELEASE, RELWITHDEBINFO, MINSIZEREL.
- DEBUG | CHECKED | RELEASE | RELWITHDEBINFO | MINSIZEREL)
- buildtype=$upperI
- ;;
- COVERAGE)
- echo "Code coverage is turned on for this build."
- code_coverage=ON
- ;;
- NINJA)
- generator=Ninja
- ;;
- SCAN-BUILD)
- echo "Static analysis is turned on for this build."
- scan_build=ON
- ;;
- *)
- __UnprocessedCMakeArgs="${__UnprocessedCMakeArgs}${__UnprocessedCMakeArgs:+ }$i"
- esac
-done
-
-OS=`uname`
-
-# Locate llvm
-# This can be a little complicated, because the common use-case of Ubuntu with
-# llvm-3.5 installed uses a rather unusual llvm installation with the version
-# number postfixed (i.e. llvm-ar-3.5), so we check for that first.
-# On FreeBSD the version number is appended without point and dash (i.e.
-# llvm-ar35).
-# Additionally, OSX doesn't use the llvm- prefix.
-if [ $OS = "Linux" -o $OS = "FreeBSD" -o $OS = "OpenBSD" -o $OS = "NetBSD" -o $OS = "SunOS" ]; then
- llvm_prefix="llvm-"
-elif [ $OS = "Darwin" ]; then
- llvm_prefix=""
-else
- echo "Unable to determine build platform"
- exit 1
-fi
-
-locate_llvm_exec() {
- if command -v "$llvm_prefix$1$desired_llvm_version" > /dev/null 2>&1
- then
- echo "$(command -v $llvm_prefix$1$desired_llvm_version)"
- elif command -v "$llvm_prefix$1" > /dev/null 2>&1
- then
- echo "$(command -v $llvm_prefix$1)"
- else
- exit 1
- fi
-}
-
-llvm_ar="$(locate_llvm_exec ar)"
-[[ $? -eq 0 ]] || { echo "Unable to locate llvm-ar"; exit 1; }
-llvm_link="$(locate_llvm_exec link)"
-[[ $? -eq 0 ]] || { echo "Unable to locate llvm-link"; exit 1; }
-llvm_nm="$(locate_llvm_exec nm)"
-[[ $? -eq 0 ]] || { echo "Unable to locate llvm-nm"; exit 1; }
-if [ $OS = "Linux" -o $OS = "FreeBSD" -o $OS = "OpenBSD" -o $OS = "NetBSD" -o $OS = "SunOS" ]; then
- llvm_objdump="$(locate_llvm_exec objdump)"
- [[ $? -eq 0 ]] || { echo "Unable to locate llvm-objdump"; exit 1; }
-fi
-
-cmake_extra_defines=
-if [[ -n "$LLDB_LIB_DIR" ]]; then
- cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_LIBS=$LLDB_LIB_DIR"
-fi
-if [[ -n "$LLDB_INCLUDE_DIR" ]]; then
- cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_INCLUDES=$LLDB_INCLUDE_DIR"
-fi
-if [ "$CROSSCOMPILE" == "1" ]; then
- platform="$(uname)"
- # OSX doesn't use rootfs
- if ! [[ -n "$ROOTFS_DIR" || "$platform" == "Darwin" ]]; then
- echo "ROOTFS_DIR not set for crosscompile"
- exit 1
- fi
- if [[ -z $CONFIG_DIR ]]; then
- CONFIG_DIR="$1/eng/cross"
- fi
- export TARGET_BUILD_ARCH=$build_arch
- cmake_extra_defines="$cmake_extra_defines -C $CONFIG_DIR/tryrun.cmake"
- cmake_extra_defines="$cmake_extra_defines -DCLR_UNIX_CROSS_BUILD=1"
-
- if [[ "$platform" == "Darwin" ]]; then
- cmake_extra_defines="$cmake_extra_defines -DCMAKE_SYSTEM_NAME=Darwin"
- else
- cmake_extra_defines="$cmake_extra_defines -DCMAKE_TOOLCHAIN_FILE=$CONFIG_DIR/toolchain.cmake"
- fi
-fi
-if [ $OS == "Linux" ]; then
- linux_id_file="/etc/os-release"
- if [[ -n "$CROSSCOMPILE" ]]; then
- linux_id_file="$ROOTFS_DIR/$linux_id_file"
- fi
- if [[ -e $linux_id_file ]]; then
- source $linux_id_file
- cmake_extra_defines="$cmake_extra_defines -DCLR_CMAKE_LINUX_ID=$ID"
- fi
-fi
-if [ "$build_arch" == "armel" ]; then
- cmake_extra_defines="$cmake_extra_defines -DARM_SOFTFP=1"
-fi
-
-clang_version=$( $CC --version | head -1 | sed 's/[^0-9]*\([0-9]*\.[0-9]*\).*/\1/' )
-# Use O1 option when the clang version is smaller than 3.9
-# Otherwise use O3 option in release build
-if [[ ( ${clang_version%.*} -eq 3 && ${clang_version#*.} -lt 9 ) &&
- ( "$build_arch" == "arm" || "$build_arch" == "armel" ) ]]; then
- overridefile=clang-compiler-override-arm.txt
-else
- overridefile=clang-compiler-override.txt
-fi
-
-__currentScriptDir="$script_dir"
-
-cmake_command=cmake
-
-if [[ "$scan_build" == "ON" ]]; then
- export CCC_CC=$CC
- export CCC_CXX=$CXX
- export SCAN_BUILD_COMMAND=$(command -v scan-build$desired_llvm_version)
- cmake_command="$SCAN_BUILD_COMMAND $cmake_command"
-fi
-
-$cmake_command \
- -G "$generator" \
- "-DCMAKE_USER_MAKE_RULES_OVERRIDE=${__currentScriptDir}/$overridefile" \
- "-DCMAKE_AR=$llvm_ar" \
- "-DCMAKE_LINKER=$llvm_link" \
- "-DCMAKE_NM=$llvm_nm" \
- "-DCMAKE_OBJDUMP=$llvm_objdump" \
- "-DCMAKE_BUILD_TYPE=$buildtype" \
- "-DCMAKE_EXPORT_COMPILE_COMMANDS=1 " \
- "-DCLR_CMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \
- "-DCLR_CMAKE_COMPILER=Clang" \
- $cmake_extra_defines \
- $__UnprocessedCMakeArgs \
- "$1"
+++ /dev/null
-@if not defined _echo @echo off
-rem
-rem This file invokes cmake and generates the build system for windows.
-
-set argC=0
-for %%x in (%*) do Set /A argC+=1
-
-if %argC% lss 3 GOTO :USAGE
-if %1=="/?" GOTO :USAGE
-
-setlocal
-set basePath=%~dp0
-:: remove quotes
-set "basePath=%basePath:"=%"
-:: remove trailing slash
-if %basePath:~-1%==\ set "basePath=%basePath:~0,-1%"
-
-set __SourceDir=%1
-set __VSVersion=%2
-set __Arch=%3
-set __CmakeGenerator=Visual Studio
-
-if /i "%__NMakeMakefiles%" == "1" (
- set __CmakeGenerator=NMake Makefiles
-) else (
- if /i "%__VSVersion%" == "vs2019" (set __CmakeGenerator=%__CmakeGenerator% 16 2019)
- if /i "%__VSVersion%" == "vs2017" (set __CmakeGenerator=%__CmakeGenerator% 15 2017)
-
- if /i "%__Arch%" == "x64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
- if /i "%__Arch%" == "arm" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM)
- if /i "%__Arch%" == "arm64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)
- if /i "%__Arch%" == "x86" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A Win32)
-)
-
-:loop
-if [%4] == [] goto end_loop
-set __ExtraCmakeParams=%__ExtraCmakeParams% %4
-shift
-goto loop
-:end_loop
-
-if defined CMakePath goto DoGen
-
-:: Eval the output from set-cmake-path.ps1
-for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& "%basePath%\set-cmake-path.ps1""') do %%a
-
-:DoGen
-"%CMakePath%" "-DCMAKE_USER_MAKE_RULES_OVERRIDE=%basePath%\windows-compiler-override.txt" "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DCLR_CMAKE_HOST_ARCH=%__Arch%" %__ExtraCmakeParams% -G "%__CmakeGenerator%" %__SourceDir%
-endlocal
-GOTO :DONE
-
-:USAGE
- echo "Usage..."
- echo "gen-buildsys-win.bat <path to top level CMakeLists.txt> <VSVersion>"
- echo "Specify the path to the top level CMake file - <ProjectK>/src/NDP"
- echo "Specify the VSVersion to be used - VS2017 or VS2019"
- EXIT /B 1
-
-:DONE
- EXIT /B 0
+++ /dev/null
-{
- # Remove the CR character in case the sources are mapped from
- # a Windows share and contain CRLF line endings
- gsub(/\r/,"", $0);
-
- # Skip empty lines and comment lines starting with semicolon
- if (NF && !match($0, /^[:space:]*;/))
- {
- print "_" $0;
- }
-}
+++ /dev/null
-BEGIN {
- print "V1.0 {";
- print " global:";
-}
-{
- # Remove the CR character in case the sources are mapped from
- # a Windows share and contain CRLF line endings
- gsub(/\r/,"", $0);
-
- # Skip empty lines and comment lines starting with semicolon
- if (NF && !match($0, /^[ \t]*;/))
- {
- print " " $0 ";";
- }
-}
-END {
- print " local: *;"
- print "};";
-}
+++ /dev/null
-#!/usr/bin/env bash
-
-# initNonPortableDistroRid
-#
-# Input:
-# buildOs: (str)
-# buildArch: (str)
-# isPortable: (int)
-# rootfsDir: (str)
-#
-# Return:
-# None
-#
-# Notes:
-#
-# initNonPortableDistroRid will attempt to initialize a non portable rid. These
-# rids are specific to distros need to build the product/package and consume
-# them on the same platform.
-#
-# If -portablebuild=false is passed a non-portable rid will be created for any
-# distro.
-#
-# Below is the list of current non-portable platforms.
-#
-# Builds from the following *must* be non-portable:
-#
-# | OS | Expected RID |
-# -------------------------------------------------
-# | rhel6 | rhel.6-x64 |
-# | alpine* | linux-musl-(arch) |
-# | freeBSD | freebsd.(version)-x64 |
-#
-# It is important to note that the function does not return anything, but it
-# will set __DistroRid if there is a non-portable distro rid to be used.
-#
-initNonPortableDistroRid()
-{
- # Make sure out parameter is cleared.
- __DistroRid=
-
- local buildOs=$1
- local buildArch=$2
- local isPortable=$3
- local rootfsDir=$4
-
- if [ "$buildOs" = "Linux" ]; then
- # RHEL 6 is the only distro we will check redHat release for.
- if [ -e "${rootfsDir}/etc/os-release" ]; then
- source "${rootfsDir}/etc/os-release"
-
- # We have forced __PortableBuild=0. This is because -portablebuld
- # has been passed as false.
- if (( ${isPortable} == 0 )); then
- if [ "${ID}" == "rhel" ]; then
- # remove the last version digit
- VERSION_ID=${VERSION_ID%.*}
- fi
-
- nonPortableBuildID="${ID}.${VERSION_ID}-${buildArch}"
- fi
-
- if [ "${ID}" == "alpine" ]; then
- export __Alpine=true
- fi
-
- elif [ -e "${rootfsDir}/etc/redhat-release" ]; then
- local redhatRelease=$(<${rootfsDir}/etc/redhat-release)
-
- if [[ "${redhatRelease}" == "CentOS release 6."* || "$redhatRelease" == "Red Hat Enterprise Linux Server release 6."* ]]; then
- nonPortableBuildID="rhel.6-${buildArch}"
- fi
- elif [ -e "${rootfsDir}/android_platform" ]; then
- source $rootfsDir/android_platform
- nonPortableBuildID="$RID"
- fi
- fi
-
- if [ "$buildOs" = "FreeBSD" ]; then
- __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
- nonPortableBuildID="freebsd.$__freebsd_version-${buildArch}"
- fi
-
- if [ "${nonPortableBuildID}" != "" ]; then
- export __DistroRid=${nonPortableBuildID}
-
- # We are using a non-portable build rid. Force __PortableBuild to false.
- export __PortableBuild=0
- fi
-}
-
-
-# initDistroRidGlobal
-#
-# Input:
-# os: (str)
-# arch: (str)
-# isPortable: (int)
-# rootfsDir?: (nullable:string)
-#
-# Return:
-# None
-#
-# Notes:
-#
-# The following out parameters are returned
-#
-# __DistroRid
-# __PortableBuild
-#
-initDistroRidGlobal()
-{
- # __DistroRid must be set at the end of the function.
- # Previously we would create a variable __HostDistroRid and/or __DistroRid.
- #
- # __HostDistroRid was used in the case of a non-portable build, it has been
- # deprecated. Now only __DistroRid is supported. It will be used for both
- # portable and non-portable rids and will be used in build-packages.sh
-
- local buildOs=$1
- local buildArch=$2
- local isPortable=$3
- local rootfsDir=$4
-
- # Setup whether this is a crossbuild. We can find this out if rootfsDir
- # is set.
- local isCrossBuild=0
-
- if [ -z "${rootfsDir}" ]; then
- isCrossBuild=0
- else
- # We may have a cross build. Check for the existance of the rootfsDir
- if [ -e ${rootfsDir} ]; then
- isCrossBuild=1
- else
- echo "Error rootfsDir has been passed, but the location is not valid."
- exit 1
- fi
- fi
-
- initNonPortableDistroRid ${buildOs} ${buildArch} ${isPortable} ${rootfsDir}
-
- if [ -z "${__DistroRid}" ]; then
- # The non-portable build rid was not set. Set the portable rid.
-
- export __PortableBuild=1
- local distroRid=""
-
- # Check for alpine. It is the only portable build that will will have
- # its name in the portable build rid.
- if [ -e "${rootfsDir}/etc/os-release" ]; then
- source "${rootfsDir}/etc/os-release"
- if [ "${ID}" = "alpine" ]; then
- distroRid="linux-musl-${buildArch}"
- fi
- fi
-
- if [ "${distroRid}" == "" ]; then
- if [ "$buildOs" = "Linux" ]; then
- distroRid="linux-$buildArch"
- elif [ "$buildOs" = "OSX" ]; then
- distroRid="osx-$buildArch"
- elif [ "$buildOs" = "FreeBSD" ]; then
- distroRid="freebsd-$buildArch"
- fi
- fi
-
- export __DistroRid=${distroRid}
- fi
-
- if [ -z "$__DistroRid" ]; then
- echo "DistroRid is not set. This is almost certainly an error"
- exit 1
- else
- export __RuntimeId=${__DistroRid}
- fi
-}
--- /dev/null
+#!/usr/bin/env bash
+
+initTargetDistroRid()
+{
+ source "$__RepoRootDir/eng/native/init-distro-rid.sh"
+
+ local passedRootfsDir=""
+
+ # Only pass ROOTFS_DIR if cross is specified and the target platform is not Darwin that doesn't use rootfs
+ if [[ "$__CrossBuild" == 1 && "$platform" != "Darwin" ]]; then
+ passedRootfsDir="$ROOTFS_DIR"
+ fi
+
+ initDistroRidGlobal "$__TargetOS" "$__BuildArch" "$__PortableBuild" "$passedRootfsDir"
+}
+
+setup_dirs()
+{
+ echo Setting up directories for build
+
+ mkdir -p "$__RootBinDir"
+ mkdir -p "$__BinDir"
+ mkdir -p "$__IntermediatesDir"
+}
+
+# Check the system to ensure the right prereqs are in place
+check_prereqs()
+{
+ echo "Checking prerequisites..."
+
+ if [[ "$__HostOS" == "OSX" ]]; then
+ # Check presence of pkg-config on the path
+ command -v pkg-config 2>/dev/null || { echo >&2 "Please install pkg-config before running this script, see https://github.com/dotnet/runtime/blob/main/docs/workflow/requirements/macos-requirements.md"; exit 1; }
+
+ if ! pkg-config openssl ; then
+ # We export the proper PKG_CONFIG_PATH where openssl was installed by Homebrew
+ # It's important to _export_ it since build-commons.sh is sourced by other scripts such as build-native.sh
+ export PKG_CONFIG_PATH=$(brew --prefix)/opt/openssl@1.1/lib/pkgconfig:$(brew --prefix)/opt/openssl/lib/pkgconfig
+ # We try again with the PKG_CONFIG_PATH in place, if pkg-config still can't find OpenSSL, exit with an error, cmake won't find OpenSSL either
+ pkg-config openssl || { echo >&2 "Please install openssl before running this script, see https://github.com/dotnet/runtime/blob/main/docs/workflow/requirements/macos-requirements.md"; exit 1; }
+ fi
+ fi
+
+ if [[ "$__UseNinja" == 1 ]]; then
+ command -v ninja 2>/dev/null || command -v ninja-build 2>/dev/null || { echo "Unable to locate ninja!"; exit 1; }
+ fi
+}
+
+build_native()
+{
+ if [[ ! -e "$__RepoRootDir/artifacts/obj/_version.c" ]]; then
+ eval "$__RepoRootDir/eng/native/version/copy_version_files.sh"
+ fi
+
+ targetOS="$1"
+ platformArch="$2"
+ cmakeDir="$3"
+ intermediatesDir="$4"
+ target="$5"
+ cmakeArgs="$6"
+ message="$7"
+
+ # All set to commence the build
+ echo "Commencing build of \"$target\" target in \"$message\" for $__TargetOS.$__BuildArch.$__BuildType in $intermediatesDir"
+
+ if [[ "$targetOS" == OSX || "$targetOS" == MacCatalyst ]]; then
+ if [[ "$platformArch" == x64 ]]; then
+ cmakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"x86_64\" $cmakeArgs"
+ elif [[ "$platformArch" == arm64 ]]; then
+ cmakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $cmakeArgs"
+ else
+ echo "Error: Unknown OSX architecture $platformArch."
+ exit 1
+ fi
+ fi
+
+ if [[ "$targetOS" == MacCatalyst ]]; then
+ cmakeArgs="-DCMAKE_SYSTEM_VARIANT=MacCatalyst $cmakeArgs"
+ fi
+
+ if [[ "$targetOS" == Android && -z "$ROOTFS_DIR" ]]; then
+ if [[ -z "$ANDROID_NDK_ROOT" ]]; then
+ echo "Error: You need to set the ANDROID_NDK_ROOT environment variable pointing to the Android NDK root."
+ exit 1
+ fi
+
+ # keep ANDROID_NATIVE_API_LEVEL in sync with src/mono/Directory.Build.props
+ cmakeArgs="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=21 $cmakeArgs"
+
+ # Don't try to set CC/CXX in init-compiler.sh - it's handled in android.toolchain.cmake already
+ __Compiler="default"
+
+ if [[ "$platformArch" == x64 ]]; then
+ cmakeArgs="-DANDROID_ABI=x86_64 $cmakeArgs"
+ elif [[ "$platformArch" == x86 ]]; then
+ cmakeArgs="-DANDROID_ABI=x86 $cmakeArgs"
+ elif [[ "$platformArch" == arm64 ]]; then
+ cmakeArgs="-DANDROID_ABI=arm64-v8a $cmakeArgs"
+ elif [[ "$platformArch" == arm ]]; then
+ cmakeArgs="-DANDROID_ABI=armeabi-v7a $cmakeArgs"
+ else
+ echo "Error: Unknown Android architecture $platformArch."
+ exit 1
+ fi
+ fi
+
+ if [[ "$__UseNinja" == 1 ]]; then
+ generator="ninja"
+ buildTool="$(command -v ninja || command -v ninja-build)"
+ else
+ buildTool="make"
+ fi
+
+ if [[ "$__SkipConfigure" == 0 ]]; then
+
+ if [[ "$__StaticAnalyzer" == 1 ]]; then
+ scan_build=scan-build
+ fi
+
+ nextCommand="\"$__RepoRootDir/eng/native/gen-buildsys.sh\" \"$cmakeDir\" \"$intermediatesDir\" $platformArch $__Compiler \"$__CompilerMajorVersion\" \"$__CompilerMinorVersion\" $__BuildType \"$generator\" $scan_build $cmakeArgs"
+ echo "Invoking $nextCommand"
+ eval $nextCommand
+
+ local exit_code="$?"
+ if [[ "$exit_code" != 0 ]]; then
+ echo "${__ErrMsgPrefix}Failed to generate \"$message\" build project!"
+ exit "$exit_code"
+ fi
+ fi
+
+ # Check that the makefiles were created.
+ if [[ ! -f "$intermediatesDir/CMakeCache.txt" ]]; then
+ echo "${__ErrMsgPrefix}Unable to find generated build files for \"$message\" project!"
+ exit 1
+ fi
+
+ # Build
+ if [[ "$__ConfigureOnly" == 1 ]]; then
+ echo "Finish configuration & skipping \"$message\" build."
+ return
+ fi
+
+ SAVED_CFLAGS="${CFLAGS}"
+ SAVED_CXXFLAGS="${CXXFLAGS}"
+ SAVED_LDFLAGS="${LDFLAGS}"
+
+ # Let users provide additional compiler/linker flags via EXTRA_CFLAGS/EXTRA_CXXFLAGS/EXTRA_LDFLAGS.
+ # If users directly override CFLAG/CXXFLAGS/LDFLAGS, that may lead to some configure tests working incorrectly.
+ # See https://github.com/dotnet/runtime/issues/35727 for more information.
+ export CFLAGS="${CFLAGS} ${EXTRA_CFLAGS}"
+ export CXXFLAGS="${CXXFLAGS} ${EXTRA_CXXFLAGS}"
+ export LDFLAGS="${LDFLAGS} ${EXTRA_LDFLAGS}"
+
+ local exit_code
+ if [[ "$__StaticAnalyzer" == 1 ]]; then
+ pushd "$intermediatesDir"
+
+ buildTool="$SCAN_BUILD_COMMAND -o $__BinDir/scan-build-log $buildTool"
+ echo "Executing $buildTool $target -j $__NumProc"
+ "$buildTool" $target -j "$__NumProc"
+ exit_code="$?"
+
+ popd
+ else
+ cmake_command=cmake
+ if [[ "$build_arch" == "wasm" ]]; then
+ cmake_command="emcmake cmake"
+ echo "Executing $cmake_command --build \"$intermediatesDir\" --target $target -- -j $__NumProc"
+ $cmake_command --build "$intermediatesDir" --target $target -- -j "$__NumProc"
+ exit_code="$?"
+ else
+ # For non-wasm Unix scenarios, we may have to use an old version of CMake that doesn't support
+ # multiple targets. Instead, directly invoke the build tool to build multiple targets in one invocation.
+ pushd "$intermediatesDir"
+
+ echo "Executing $buildTool $target -j $__NumProc"
+ "$buildTool" $target -j "$__NumProc"
+ exit_code="$?"
+
+ popd
+ fi
+ fi
+
+ CFLAGS="${SAVED_CFLAGS}"
+ CXXFLAGS="${SAVED_CXXFLAGS}"
+ LDFLAGS="${SAVED_LDFLAGS}"
+
+ if [[ "$exit_code" != 0 ]]; then
+ echo "${__ErrMsgPrefix}Failed to build \"$message\"."
+ exit "$exit_code"
+ fi
+}
+
+usage()
+{
+ echo "Usage: $0 <options>"
+ echo ""
+ echo "Common Options:"
+ echo ""
+ echo "BuildArch can be: -arm, -armel, -arm64, -s390x, x64, x86, -wasm"
+ echo "BuildType can be: -debug, -checked, -release"
+ echo "-os: target OS (defaults to running OS)"
+ echo "-bindir: output directory (defaults to $__ProjectRoot/artifacts)"
+ echo "-ci: indicates if this is a CI build."
+ echo "-clang: optional argument to build using clang in PATH (default)."
+ echo "-clangx.y: optional argument to build using clang version x.y."
+ echo "-cmakeargs: user-settable additional arguments passed to CMake."
+ echo "-configureonly: do not perform any builds; just configure the build."
+ echo "-cross: optional argument to signify cross compilation,"
+ echo " will use ROOTFS_DIR environment variable if set."
+ echo "-gcc: optional argument to build using gcc in PATH."
+ echo "-gccx.y: optional argument to build using gcc version x.y."
+ echo "-ninja: target ninja instead of GNU make"
+ echo "-numproc: set the number of build processes."
+ echo "-portablebuild: pass -portablebuild=false to force a non-portable build."
+ echo "-skipconfigure: skip build configuration."
+ echo "-keepnativesymbols: keep native/unmanaged debug symbols."
+ echo "-verbose: optional argument to enable verbose build output."
+ echo ""
+ echo "Additional Options:"
+ echo ""
+ for i in "${!usage_list[@]}"; do
+ echo "${usage_list[${i}]}"
+ done
+ echo ""
+ exit 1
+}
+
+source "$__RepoRootDir/eng/native/init-os-and-arch.sh"
+
+__BuildArch=$arch
+__HostArch=$arch
+__TargetOS=$os
+__HostOS=$os
+__BuildOS=$os
+
+# Get the number of processors available to the scheduler
+# Other techniques such as `nproc` only get the number of
+# processors available to a single process.
+platform="$(uname)"
+if [[ "$platform" == "FreeBSD" ]]; then
+ __NumProc=$(($(sysctl -n hw.ncpu)+1))
+elif [[ "$platform" == "NetBSD" || "$platform" == "SunOS" ]]; then
+ __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
+elif [[ "$platform" == "Darwin" ]]; then
+ __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
+else
+ if command -v nproc > /dev/null 2>&1; then
+ __NumProc=$(nproc --all)
+ elif (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then
+ __NumProc=$(getconf _NPROCESSORS_ONLN)
+ else
+ __NumProc=1
+ fi
+fi
+
+while :; do
+ if [[ "$#" -le 0 ]]; then
+ break
+ fi
+
+ lowerI="$(echo "${1/--/-}" | tr "[:upper:]" "[:lower:]")"
+ case "$lowerI" in
+ -\?|-h|--help)
+ usage
+ exit 1
+ ;;
+
+ arm|-arm)
+ __BuildArch=arm
+ ;;
+
+ arm64|-arm64)
+ __BuildArch=arm64
+ ;;
+
+ armel|-armel)
+ __BuildArch=armel
+ ;;
+
+ bindir|-bindir)
+ if [[ -n "$2" ]]; then
+ __RootBinDir="$2"
+ if [[ ! -d "$__RootBinDir" ]]; then
+ mkdir "$__RootBinDir"
+ fi
+ __RootBinParent=$(dirname "$__RootBinDir")
+ __RootBinName="${__RootBinDir##*/}"
+ __RootBinDir="$(cd "$__RootBinParent" &>/dev/null && printf %s/%s "$PWD" "$__RootBinName")"
+ shift
+ else
+ echo "ERROR: 'bindir' requires a non-empty option argument"
+ exit 1
+ fi
+ ;;
+
+ checked|-checked)
+ __BuildType=Checked
+ ;;
+
+ ci|-ci)
+ __ArcadeScriptArgs="--ci"
+ __ErrMsgPrefix="##vso[task.logissue type=error]"
+ ;;
+
+ clang*|-clang*)
+ __Compiler=clang
+ # clangx.y or clang-x.y
+ version="$(echo "$lowerI" | tr -d '[:alpha:]-=')"
+ parts=(${version//./ })
+ __CompilerMajorVersion="${parts[0]}"
+ __CompilerMinorVersion="${parts[1]}"
+ if [[ -z "$__CompilerMinorVersion" && "$__CompilerMajorVersion" -le 6 ]]; then
+ __CompilerMinorVersion=0;
+ fi
+ ;;
+
+ cmakeargs|-cmakeargs)
+ if [[ -n "$2" ]]; then
+ __CMakeArgs="$2 $__CMakeArgs"
+ shift
+ else
+ echo "ERROR: 'cmakeargs' requires a non-empty option argument"
+ exit 1
+ fi
+ ;;
+
+ configureonly|-configureonly)
+ __ConfigureOnly=1
+ __SkipMSCorLib=1
+ __SkipNuget=1
+ ;;
+
+ cross|-cross)
+ __CrossBuild=1
+ ;;
+
+ debug|-debug)
+ __BuildType=Debug
+ ;;
+
+ gcc*|-gcc*)
+ __Compiler=gcc
+ # gccx.y or gcc-x.y
+ version="$(echo "$lowerI" | tr -d '[:alpha:]-=')"
+ parts=(${version//./ })
+ __CompilerMajorVersion="${parts[0]}"
+ __CompilerMinorVersion="${parts[1]}"
+ ;;
+
+ keepnativesymbols|-keepnativesymbols)
+ __CMakeArgs="$__CMakeArgs -DCLR_CMAKE_KEEP_NATIVE_SYMBOLS=true"
+ ;;
+
+ ninja|-ninja)
+ __UseNinja=1
+ ;;
+
+ numproc|-numproc)
+ if [[ -n "$2" ]]; then
+ __NumProc="$2"
+ shift
+ else
+ echo "ERROR: 'numproc' requires a non-empty option argument"
+ exit 1
+ fi
+ ;;
+
+ portablebuild=false|-portablebuild=false)
+ __PortableBuild=0
+ ;;
+
+ release|-release)
+ __BuildType=Release
+ ;;
+
+ skipconfigure|-skipconfigure)
+ __SkipConfigure=1
+ ;;
+
+ verbose|-verbose)
+ __VerboseBuild=1
+ ;;
+
+ x86|-x86)
+ __BuildArch=x86
+ ;;
+
+ x64|-x64)
+ __BuildArch=x64
+ ;;
+
+ s390x|-s390x)
+ __BuildArch=s390x
+ ;;
+
+ wasm|-wasm)
+ __BuildArch=wasm
+ ;;
+
+ os|-os)
+ if [[ -n "$2" ]]; then
+ __TargetOS="$2"
+ shift
+ else
+ echo "ERROR: 'os' requires a non-empty option argument"
+ exit 1
+ fi
+ ;;
+
+ *)
+ handle_arguments "$1" "$2"
+ if [[ "$__ShiftArgs" == 1 ]]; then
+ shift
+ __ShiftArgs=0
+ fi
+ ;;
+ esac
+
+ shift
+done
+
+__CommonMSBuildArgs="/p:TargetArchitecture=$__BuildArch /p:Configuration=$__BuildType /p:TargetOS=$__TargetOS /nodeReuse:false $__OfficialBuildIdArg $__SignTypeArg $__SkipRestoreArg"
+
+# Configure environment if we are doing a verbose build
+if [[ "$__VerboseBuild" == 1 ]]; then
+ VERBOSE=1
+ export VERBOSE
+ __CommonMSBuildArgs="$__CommonMSBuildArgs /v:detailed"
+fi
+
+if [[ "$__PortableBuild" == 0 ]]; then
+ __CommonMSBuildArgs="$__CommonMSBuildArgs /p:PortableBuild=false"
+fi
+
+if [[ "$__BuildArch" == wasm ]]; then
+ # nothing to do here
+ true
+elif [[ "$__TargetOS" == iOS || "$__TargetOS" == iOSSimulator ]]; then
+ # nothing to do here
+ true
+elif [[ "$__TargetOS" == tvOS || "$__TargetOS" == tvOSSimulator ]]; then
+ # nothing to do here
+ true
+elif [[ "$__TargetOS" == Android ]]; then
+ # nothing to do here
+ true
+else
+ __CMakeArgs="-DFEATURE_DISTRO_AGNOSTIC_SSL=$__PortableBuild $__CMakeArgs"
+fi
+
+# Configure environment if we are doing a cross compile.
+if [[ "$__CrossBuild" == 1 ]]; then
+ CROSSCOMPILE=1
+ export CROSSCOMPILE
+ # Darwin that doesn't use rootfs
+ if [[ ! -n "$ROOTFS_DIR" && "$platform" != "Darwin" ]]; then
+ ROOTFS_DIR="$__RepoRootDir/.tools/rootfs/$__BuildArch"
+ export ROOTFS_DIR
+ fi
+fi
+
+# init the target distro name
+initTargetDistroRid
--- /dev/null
+include(${CMAKE_CURRENT_LIST_DIR}/configuretools.cmake)
+
+# Set initial flags for each configuration
+
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_C_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+include(CheckCCompilerFlag)
+include(CheckCXXCompilerFlag)
+
+# "configureoptimization.cmake" must be included after CLR_CMAKE_HOST_UNIX has been set.
+include(${CMAKE_CURRENT_LIST_DIR}/configureoptimization.cmake)
+
+#-----------------------------------------------------
+# Initialize Cmake compiler flags and other variables
+#-----------------------------------------------------
+
+if (CLR_CMAKE_HOST_UNIX)
+ add_compile_options(-g)
+ add_compile_options(-Wall)
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ add_compile_options(-Wno-null-conversion)
+ else()
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Werror=conversion-null>)
+ endif()
+endif()
+
+if (CMAKE_CONFIGURATION_TYPES) # multi-configuration generator?
+ set(CMAKE_CONFIGURATION_TYPES "Debug;Checked;Release;RelWithDebInfo" CACHE STRING "" FORCE)
+endif (CMAKE_CONFIGURATION_TYPES)
+
+set(CMAKE_C_FLAGS_CHECKED "")
+set(CMAKE_CXX_FLAGS_CHECKED "")
+set(CMAKE_EXE_LINKER_FLAGS_CHECKED "")
+set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "")
+
+set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "")
+set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "")
+set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "")
+set(CMAKE_EXE_LINKER_FLAGS_DEBUG "")
+set(CMAKE_EXE_LINKER_FLAGS_DEBUG "")
+set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "")
+
+add_compile_definitions("$<$<CONFIG:DEBUG>:DEBUG;_DEBUG;_DBG;URTBLDENV_FRIENDLY=Debug;BUILDENV_DEBUG=1>")
+add_compile_definitions("$<$<CONFIG:CHECKED>:DEBUG;_DEBUG;_DBG;URTBLDENV_FRIENDLY=Checked;BUILDENV_CHECKED=1>")
+add_compile_definitions("$<$<OR:$<CONFIG:RELEASE>,$<CONFIG:RELWITHDEBINFO>>:NDEBUG;URTBLDENV_FRIENDLY=Retail>")
+
+if (MSVC)
+ add_linker_flag(/guard:cf)
+
+ # Linker flags
+ #
+ set (WINDOWS_SUBSYSTEM_VERSION 6.01)
+
+ if (CLR_CMAKE_HOST_ARCH_ARM)
+ set(WINDOWS_SUBSYSTEM_VERSION 6.02) #windows subsystem - arm minimum is 6.02
+ elseif(CLR_CMAKE_HOST_ARCH_ARM64)
+ set(WINDOWS_SUBSYSTEM_VERSION 6.03) #windows subsystem - arm64 minimum is 6.03
+ endif ()
+
+ #Do not create Side-by-Side Assembly Manifest
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO")
+ # can handle addresses larger than 2 gigabytes
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE")
+ #shrink pdb size
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /PDBCOMPRESS")
+
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /IGNORE:4197,4013,4254,4070,4221")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,${WINDOWS_SUBSYSTEM_VERSION}")
+
+ set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4221")
+
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /PDBCOMPRESS")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1572864")
+
+ # Checked build specific flags
+ add_linker_flag(/INCREMENTAL:NO CHECKED) # prevent "warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:REF' specification"
+ add_linker_flag(/OPT:REF CHECKED)
+ add_linker_flag(/OPT:NOICF CHECKED)
+
+ # Release build specific flags
+ add_linker_flag(/LTCG RELEASE)
+ add_linker_flag(/OPT:REF RELEASE)
+ add_linker_flag(/OPT:ICF RELEASE)
+ add_linker_flag(/INCREMENTAL:NO RELEASE)
+ set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")
+
+ # ReleaseWithDebugInfo build specific flags
+ add_linker_flag(/LTCG RELWITHDEBINFO)
+ add_linker_flag(/OPT:REF RELWITHDEBINFO)
+ add_linker_flag(/OPT:ICF RELWITHDEBINFO)
+ set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
+
+ # Force uCRT to be dynamically linked for Release build
+ add_linker_flag(/NODEFAULTLIB:libucrt.lib RELEASE)
+ add_linker_flag(/DEFAULTLIB:ucrt.lib RELEASE)
+
+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")
+
+ # Use uppercase CMAKE_BUILD_TYPE for the string comparisons below
+ string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_CMAKE_BUILD_TYPE)
+
+ set(CLR_SANITIZE_CXX_OPTIONS "")
+ set(CLR_SANITIZE_LINK_OPTIONS "")
+
+ # 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))
+ 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
+ "bool"
+ bounds
+ enum
+ float-cast-overflow
+ float-divide-by-zero
+ "function"
+ integer
+ nonnull-attribute
+ null
+ object-size
+ "return"
+ returns-nonnull-attribute
+ shift
+ unreachable
+ vla-bound
+ vptr)
+ list(APPEND CLR_LINK_SANITIZERS
+ undefined)
+ message("Undefined Behavior Sanitizer (ubsan) enabled")
+ endif ()
+ list(JOIN CLR_CXX_SANITIZERS "," CLR_CXX_SANITIZERS_OPTIONS)
+ list(APPEND CLR_SANITIZE_CXX_OPTIONS "-fsanitize=${CLR_CXX_SANITIZERS_OPTIONS}")
+ list(JOIN CLR_LINK_SANITIZERS "," CLR_LINK_SANITIZERS_OPTIONS)
+ list(APPEND CLR_SANITIZE_LINK_OPTIONS "-fsanitize=${CLR_LINK_SANITIZERS_OPTIONS}")
+
+ # -fdata-sections -ffunction-sections: each function has own section instead of one per .o file (needed for --gc-sections)
+ # -O1: optimization level used instead of -O0 to avoid compile error "invalid operand for inline asm constraint"
+ add_compile_options("$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>:${CLR_SANITIZE_CXX_OPTIONS};-fdata-sections;--ffunction-sections;-O1>")
+ add_linker_flag("${CLR_SANITIZE_LINK_OPTIONS}" DEBUG CHECKED)
+ # -Wl and --gc-sections: drop unused sections\functions (similar to Windows /Gy function-level-linking)
+ add_linker_flag("-Wl,--gc-sections" DEBUG CHECKED)
+ endif ()
+ endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
+
+ if(CLR_CMAKE_HOST_BROWSER)
+ # The emscripten build has additional warnings so -Werror breaks
+ add_compile_options(-Wno-unused-parameter)
+ add_compile_options(-Wno-alloca)
+ add_compile_options(-Wno-implicit-int-float-conversion)
+ endif()
+endif(MSVC)
+
+# CLR_ADDITIONAL_LINKER_FLAGS - used for passing additional arguments to linker
+# CLR_ADDITIONAL_COMPILER_OPTIONS - used for passing additional arguments to compiler
+#
+# For example:
+# ./build-native.sh cmakeargs "-DCLR_ADDITIONAL_COMPILER_OPTIONS=<...>" cmakeargs "-DCLR_ADDITIONAL_LINKER_FLAGS=<...>"
+#
+if(CLR_CMAKE_HOST_UNIX)
+ foreach(ADDTL_LINKER_FLAG ${CLR_ADDITIONAL_LINKER_FLAGS})
+ add_linker_flag(${ADDTL_LINKER_FLAG})
+ endforeach()
+endif(CLR_CMAKE_HOST_UNIX)
+
+if(CLR_CMAKE_HOST_LINUX)
+ add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
+ add_linker_flag(-Wl,--build-id=sha1)
+ add_linker_flag(-Wl,-z,relro,-z,now)
+elseif(CLR_CMAKE_HOST_FREEBSD)
+ add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
+ add_linker_flag("-Wl,--build-id=sha1")
+elseif(CLR_CMAKE_HOST_SUNOS)
+ add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
+ add_definitions(-D__EXTENSIONS__ -D_XPG4_2 -D_POSIX_PTHREAD_SEMANTICS)
+elseif(CLR_CMAKE_HOST_OSX AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS)
+ add_definitions(-D_XOPEN_SOURCE)
+ add_linker_flag("-Wl,-bind_at_load")
+endif()
+
+#------------------------------------
+# Definitions (for platform)
+#-----------------------------------
+if (CLR_CMAKE_HOST_ARCH_AMD64)
+ set(ARCH_HOST_NAME x64)
+ add_definitions(-DHOST_AMD64 -DHOST_64BIT)
+elseif (CLR_CMAKE_HOST_ARCH_I386)
+ set(ARCH_HOST_NAME x86)
+ add_definitions(-DHOST_X86)
+elseif (CLR_CMAKE_HOST_ARCH_ARM)
+ set(ARCH_HOST_NAME arm)
+ add_definitions(-DHOST_ARM)
+elseif (CLR_CMAKE_HOST_ARCH_ARM64)
+ set(ARCH_HOST_NAME arm64)
+ add_definitions(-DHOST_ARM64 -DHOST_64BIT)
+elseif (CLR_CMAKE_HOST_ARCH_S390X)
+ set(ARCH_HOST_NAME s390x)
+ add_definitions(-DHOST_S390X -DHOST_64BIT -DBIGENDIAN)
+elseif (CLR_CMAKE_HOST_ARCH_WASM)
+ set(ARCH_HOST_NAME wasm)
+ add_definitions(-DHOST_WASM -DHOST_32BIT=1)
+elseif (CLR_CMAKE_HOST_ARCH_MIPS64)
+ set(ARCH_HOST_NAME mips64)
+ add_definitions(-DHOST_MIPS64 -DHOST_64BIT=1)
+else ()
+ clr_unknown_arch()
+endif ()
+
+if (CLR_CMAKE_HOST_UNIX)
+ if(CLR_CMAKE_HOST_LINUX)
+ if(CLR_CMAKE_HOST_UNIX_AMD64)
+ message("Detected Linux x86_64")
+ elseif(CLR_CMAKE_HOST_UNIX_ARM)
+ message("Detected Linux ARM")
+ elseif(CLR_CMAKE_HOST_UNIX_ARM64)
+ message("Detected Linux ARM64")
+ elseif(CLR_CMAKE_HOST_UNIX_X86)
+ message("Detected Linux i686")
+ elseif(CLR_CMAKE_HOST_UNIX_S390X)
+ message("Detected Linux s390x")
+ else()
+ clr_unknown_arch()
+ endif()
+ endif(CLR_CMAKE_HOST_LINUX)
+endif(CLR_CMAKE_HOST_UNIX)
+
+if (CLR_CMAKE_HOST_UNIX)
+ add_definitions(-DHOST_UNIX)
+
+ if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST)
+ add_definitions(-DHOST_OSX)
+ if(CLR_CMAKE_HOST_UNIX_AMD64)
+ message("Detected OSX x86_64")
+ elseif(CLR_CMAKE_HOST_UNIX_ARM64)
+ message("Detected OSX ARM64")
+ else()
+ clr_unknown_arch()
+ endif()
+ elseif(CLR_CMAKE_HOST_FREEBSD)
+ message("Detected FreeBSD amd64")
+ elseif(CLR_CMAKE_HOST_NETBSD)
+ message("Detected NetBSD amd64")
+ elseif(CLR_CMAKE_HOST_SUNOS)
+ message("Detected SunOS amd64")
+ endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST)
+endif(CLR_CMAKE_HOST_UNIX)
+
+if (CLR_CMAKE_HOST_WIN32)
+ add_definitions(-DHOST_WINDOWS)
+
+ # Define the CRT lib references that link into Desktop imports
+ set(STATIC_MT_CRT_LIB "libcmt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
+ set(STATIC_MT_VCRT_LIB "libvcruntime$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
+ set(STATIC_MT_CPP_LIB "libcpmt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
+endif(CLR_CMAKE_HOST_WIN32)
+
+# Unconditionally define _FILE_OFFSET_BITS as 64 on all platforms.
+add_definitions(-D_FILE_OFFSET_BITS=64)
+
+# Architecture specific files folder name
+if (CLR_CMAKE_TARGET_ARCH_AMD64)
+ set(ARCH_SOURCES_DIR amd64)
+ set(ARCH_TARGET_NAME x64)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_AMD64>)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_64BIT>)
+elseif (CLR_CMAKE_TARGET_ARCH_ARM64)
+ set(ARCH_SOURCES_DIR arm64)
+ set(ARCH_TARGET_NAME arm64)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_ARM64>)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_64BIT>)
+elseif (CLR_CMAKE_TARGET_ARCH_ARM)
+ set(ARCH_SOURCES_DIR arm)
+ set(ARCH_TARGET_NAME arm)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_ARM>)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_32BIT>)
+elseif (CLR_CMAKE_TARGET_ARCH_I386)
+ set(ARCH_TARGET_NAME x86)
+ set(ARCH_SOURCES_DIR i386)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_X86>)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_32BIT>)
+elseif (CLR_CMAKE_TARGET_ARCH_S390X)
+ set(ARCH_TARGET_NAME s390x)
+ set(ARCH_SOURCES_DIR s390x)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_S390X>)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_64BIT>)
+elseif (CLR_CMAKE_TARGET_ARCH_WASM)
+ set(ARCH_TARGET_NAME wasm)
+ set(ARCH_SOURCES_DIR wasm)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_WASM>)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_32BIT>)
+elseif (CLR_CMAKE_TARGET_ARCH_MIPS64)
+ set(ARCH_TARGET_NAME mips64)
+ set(ARCH_SOURCES_DIR mips64)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_MIPS64>)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_64BIT>)
+else ()
+ clr_unknown_arch()
+endif ()
+
+#--------------------------------------
+# Compile Options
+#--------------------------------------
+if (CLR_CMAKE_HOST_UNIX)
+ # Disable frame pointer optimizations so profilers can get better call stacks
+ add_compile_options(-fno-omit-frame-pointer)
+
+ # The -fms-extensions enable the stuff like __if_exists, __declspec(uuid()), etc.
+ add_compile_options(-fms-extensions)
+ #-fms-compatibility Enable full Microsoft Visual C++ compatibility
+ #-fms-extensions Accept some non-standard constructs supported by the Microsoft compiler
+
+ # Make signed arithmetic overflow of addition, subtraction, and multiplication wrap around
+ # using twos-complement representation (this is normally undefined according to the C++ spec).
+ add_compile_options(-fwrapv)
+
+ if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST)
+ # We cannot enable "stack-protector-strong" on OS X due to a bug in clang compiler (current version 7.0.2)
+ add_compile_options(-fstack-protector)
+ elseif(NOT CLR_CMAKE_HOST_BROWSER)
+ check_c_compiler_flag(-fstack-protector-strong COMPILER_SUPPORTS_F_STACK_PROTECTOR_STRONG)
+ if (COMPILER_SUPPORTS_F_STACK_PROTECTOR_STRONG)
+ add_compile_options(-fstack-protector-strong)
+ endif()
+ endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST)
+
+ # Suppress warnings-as-errors in release branches to reduce servicing churn
+ if (PRERELEASE)
+ add_compile_options(-Werror)
+ endif(PRERELEASE)
+
+ # Disabled common warnings
+ add_compile_options(-Wno-unused-variable)
+ add_compile_options(-Wno-unused-value)
+ add_compile_options(-Wno-unused-function)
+ add_compile_options(-Wno-tautological-compare)
+ add_compile_options(-Wno-unknown-pragmas)
+
+ # Explicitly enabled warnings
+ check_c_compiler_flag(-Wimplicit-fallthrough COMPILER_SUPPORTS_W_IMPLICIT_FALLTHROUGH)
+ if (COMPILER_SUPPORTS_W_IMPLICIT_FALLTHROUGH)
+ add_compile_options(-Wimplicit-fallthrough)
+ endif()
+
+ #These seem to indicate real issues
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-invalid-offsetof>)
+
+ add_compile_options(-Wno-unused-but-set-variable)
+
+ if (CMAKE_C_COMPILER_ID MATCHES "Clang")
+ add_compile_options(-Wno-unknown-warning-option)
+
+ # The -ferror-limit is helpful during the porting, it makes sure the compiler doesn't stop
+ # after hitting just about 20 errors.
+ add_compile_options(-ferror-limit=4096)
+
+ # Disabled warnings
+ add_compile_options(-Wno-unused-private-field)
+ # There are constants of type BOOL used in a condition. But BOOL is defined as int
+ # and so the compiler thinks that there is a mistake.
+ add_compile_options(-Wno-constant-logical-operand)
+ # We use pshpack1/2/4/8.h and poppack.h headers to set and restore packing. However
+ # clang 6.0 complains when the packing change lifetime is not contained within
+ # a header file.
+ add_compile_options(-Wno-pragma-pack)
+
+ # The following warning indicates that an attribute __attribute__((__ms_struct__)) was applied
+ # to a struct or a class that has virtual members or a base class. In that case, clang
+ # may not generate the same object layout as MSVC.
+ add_compile_options(-Wno-incompatible-ms-struct)
+
+ add_compile_options(-Wno-reserved-identifier)
+ else()
+ add_compile_options(-Wno-uninitialized)
+ add_compile_options(-Wno-strict-aliasing)
+ add_compile_options(-Wno-array-bounds)
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>)
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-misleading-indentation>)
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-stringop-overflow>)
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-stringop-truncation>)
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-placement-new>)
+
+ if (CMAKE_CXX_COMPILER_ID)
+ check_cxx_compiler_flag(-faligned-new COMPILER_SUPPORTS_F_ALIGNED_NEW)
+ if (COMPILER_SUPPORTS_F_ALIGNED_NEW)
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-faligned-new>)
+ endif()
+ endif()
+ endif()
+
+ # Some architectures (e.g., ARM) assume char type is unsigned while CoreCLR assumes char is signed
+ # as x64 does. It has been causing issues in ARM (https://github.com/dotnet/runtime/issues/5778)
+ add_compile_options(-fsigned-char)
+
+ # We mark the function which needs exporting with DLLEXPORT
+ add_compile_options(-fvisibility=hidden)
+
+ # Specify the minimum supported version of macOS
+ # Mac Catalyst needs a special CFLAG, exclusive with mmacosx-version-min
+ if(CLR_CMAKE_HOST_MACCATALYST)
+ # Somewhere between CMake 3.17 and 3.19.4, it became impossible to not pass
+ # a value for mmacosx-version-min (blank CMAKE_OSX_DEPLOYMENT_TARGET gets
+ # replaced with a default value, and always gets expanded to an OS version.
+ # https://gitlab.kitware.com/cmake/cmake/-/issues/20132
+ # We need to disable the warning that -tagret replaces -mmacosx-version-min
+ set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-t-option)
+ add_link_options(-Wno-overriding-t-option)
+ if(CLR_CMAKE_HOST_ARCH_ARM64)
+ set(MACOS_VERSION_MIN_FLAGS "-target arm64-apple-ios14.2-macabi")
+ add_link_options(-target arm64-apple-ios14.2-macabi)
+ elseif(CLR_CMAKE_HOST_ARCH_AMD64)
+ set(MACOS_VERSION_MIN_FLAGS "-target x86_64-apple-ios13.5-macabi")
+ add_link_options(-target x86_64-apple-ios13.5-macabi)
+ else()
+ clr_unknown_arch()
+ endif()
+ # These options are intentionally set using the CMAKE_XXX_FLAGS instead of
+ # add_compile_options so that they take effect on the configuration functions
+ # in various configure.cmake files.
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MACOS_VERSION_MIN_FLAGS} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MACOS_VERSION_MIN_FLAGS} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
+ set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${MACOS_VERSION_MIN_FLAGS} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
+ elseif(CLR_CMAKE_HOST_OSX)
+ if(CLR_CMAKE_HOST_ARCH_ARM64)
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
+ add_compile_options(-arch arm64)
+ elseif(CLR_CMAKE_HOST_ARCH_AMD64)
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
+ add_compile_options(-arch x86_64)
+ else()
+ clr_unknown_arch()
+ endif()
+ endif(CLR_CMAKE_HOST_MACCATALYST)
+
+endif(CLR_CMAKE_HOST_UNIX)
+
+if(CLR_CMAKE_TARGET_UNIX)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_UNIX>)
+ # Contracts are disabled on UNIX.
+ add_definitions(-DDISABLE_CONTRACTS)
+ if(CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_OSX>)
+ elseif(CLR_CMAKE_TARGET_FREEBSD)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_FREEBSD>)
+ elseif(CLR_CMAKE_TARGET_ANDROID)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_ANDROID>)
+ elseif(CLR_CMAKE_TARGET_LINUX)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_LINUX>)
+ elseif(CLR_CMAKE_TARGET_NETBSD)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_NETBSD>)
+ elseif(CLR_CMAKE_TARGET_SUNOS)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_SUNOS>)
+ endif()
+else(CLR_CMAKE_TARGET_UNIX)
+ add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_WINDOWS>)
+endif(CLR_CMAKE_TARGET_UNIX)
+
+if(CLR_CMAKE_HOST_UNIX_ARM)
+ if (NOT DEFINED CLR_ARM_FPU_TYPE)
+ set(CLR_ARM_FPU_TYPE vfpv3)
+ endif(NOT DEFINED CLR_ARM_FPU_TYPE)
+
+ # Because we don't use CMAKE_C_COMPILER/CMAKE_CXX_COMPILER to use clang
+ # we have to set the triple by adding a compiler argument
+ add_compile_options(-mthumb)
+ add_compile_options(-mfpu=${CLR_ARM_FPU_TYPE})
+ if (NOT DEFINED CLR_ARM_FPU_CAPABILITY)
+ set(CLR_ARM_FPU_CAPABILITY 0x7)
+ endif(NOT DEFINED CLR_ARM_FPU_CAPABILITY)
+ add_definitions(-DCLR_ARM_FPU_CAPABILITY=${CLR_ARM_FPU_CAPABILITY})
+ add_compile_options(-march=armv7-a)
+ if(ARM_SOFTFP)
+ add_definitions(-DARM_SOFTFP)
+ add_compile_options(-mfloat-abi=softfp)
+ endif(ARM_SOFTFP)
+endif(CLR_CMAKE_HOST_UNIX_ARM)
+
+if(CLR_CMAKE_HOST_UNIX_X86)
+ add_compile_options(-msse2)
+endif()
+
+if(CLR_CMAKE_HOST_UNIX)
+ add_compile_options(${CLR_ADDITIONAL_COMPILER_OPTIONS})
+endif(CLR_CMAKE_HOST_UNIX)
+
+if (MSVC)
+ # Compile options for targeting windows
+
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/nologo>) # Suppress Startup Banner
+ # /W3 is added by default by CMake, so remove it
+ string(REPLACE "/W3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ string(REPLACE "/W3" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+ # set default warning level to 3 but allow targets to override it.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/W$<GENEX_EVAL:$<IF:$<BOOL:$<TARGET_PROPERTY:MSVC_WARNING_LEVEL>>,$<TARGET_PROPERTY:MSVC_WARNING_LEVEL>,3>>>)
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/WX>) # treat warnings as errors
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Oi>) # enable intrinsics
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Oy->) # disable suppressing of the creation of frame pointers on the call stack for quicker function calls
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Gm->) # disable minimal rebuild
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zp8>) # pack structs on 8-byte boundary
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Gy>) # separate functions for linker
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/GS>) # Explicitly enable the buffer security checks
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/fp:precise>) # Enable precise floating point
+
+ # disable C++ RTTI
+ # /GR is added by default by CMake, so remove it manually.
+ string(REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
+
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/FC>) # use full pathnames in diagnostics
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/MP>) # Build with Multiple Processes (number of processes equal to the number of processors)
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zm200>) # Specify Precompiled Header Memory Allocation Limit of 150MB
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zc:strictStrings>) # Disable string-literal to char* or wchar_t* conversion
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zc:wchar_t>) # wchar_t is a built-in type.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zc:inline>) # All inline functions must have their definition available in the current translation unit.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zc:forScope>) # Enforce standards-compliant for scope.
+
+ # Disable Warnings:
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4065>) # switch statement contains 'default' but no 'case' labels
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4100>) # 'identifier' : unreferenced formal parameter
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4127>) # conditional expression is constant
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4189>) # local variable is initialized but not referenced
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4200>) # nonstandard extension used : zero-sized array in struct/union
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4201>) # nonstandard extension used : nameless struct/union
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4245>) # conversion from 'type1' to 'type2', signed/unsigned mismatch
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4291>) # no matching operator delete found; memory will not be freed if initialization throws an exception
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4456>) # declaration of 'identifier' hides previous local declaration
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4457>) # declaration of 'identifier' hides function parameter
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4458>) # declaration of 'identifier' hides class member
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4733>) # Inline asm assigning to 'FS:0' : handler not registered as safe handler
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4838>) # conversion from 'type_1' to 'type_2' requires a narrowing conversion
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4960>) # 'function' is too big to be profiled
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4961>) # No profile data was merged into '.pgd file', profile-guided optimizations disabled
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd5105>) # macro expansion producing 'defined' has undefined behavior
+
+ # Treat Warnings as Errors:
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4007>) # 'main' : must be __cdecl.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4013>) # 'function' undefined - assuming extern returning int.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4102>) # "'%$S' : unreferenced label".
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4551>) # Function call missing argument list.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4700>) # Local used w/o being initialized.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4640>) # 'instance' : construction of local static object is not thread-safe
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4806>) # Unsafe operation involving type 'bool'.
+
+ # Set Warning Level 3:
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34092>) # Sizeof returns 'unsigned long'.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34121>) # Structure is sensitive to alignment.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34125>) # Decimal digit in octal sequence.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34130>) # Logical operation on address of string constant.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34132>) # Const object should be initialized.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34212>) # Function declaration used ellipsis.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34530>) # C++ exception handler used, but unwind semantics are not enabled. Specify -GX.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w35038>) # data member 'member1' will be initialized after data member 'member2'.
+
+ # Set Warning Level 4:
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w44177>) # Pragma data_seg s/b at global scope.
+
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zi>) # enable debugging information
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/ZH:SHA_256>) # use SHA256 for generating hashes of compiler processed source files.
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/source-charset:utf-8>) # Force MSVC to compile source as UTF-8.
+
+ if (CLR_CMAKE_HOST_ARCH_I386)
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Gz>)
+ endif (CLR_CMAKE_HOST_ARCH_I386)
+
+ add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>>:/GL>)
+
+ if (CLR_CMAKE_HOST_ARCH_AMD64)
+ # The generator expression in the following command means that the /homeparams option is added only for debug builds for C and C++ source files
+ add_compile_options($<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C,CXX>>:/homeparams>) # Force parameters passed in registers to be written to the stack
+ endif (CLR_CMAKE_HOST_ARCH_AMD64)
+
+ # enable control-flow-guard support for native components for non-Arm64 builds
+ # Added using variables instead of add_compile_options to let individual projects override it
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /guard:cf")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf")
+
+ # Enable EH-continuation table and CET-compatibility for native components for amd64 builds except for components of the Mono
+ # runtime. Added some switches using variables instead of add_compile_options to let individual projects override it.
+ if (CLR_CMAKE_HOST_ARCH_AMD64 AND NOT CLR_CMAKE_RUNTIME_MONO)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /guard:ehcont")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:ehcont")
+ set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /guard:ehcont")
+ add_linker_flag(/guard:ehcont)
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /CETCOMPAT")
+ endif (CLR_CMAKE_HOST_ARCH_AMD64 AND NOT CLR_CMAKE_RUNTIME_MONO)
+
+ # Statically linked CRT (libcmt[d].lib, libvcruntime[d].lib and libucrt[d].lib) by default. This is done to avoid
+ # linking in VCRUNTIME140.DLL for a simplified xcopy experience by reducing the dependency on VC REDIST.
+ #
+ # 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>)
+
+ add_compile_options($<$<COMPILE_LANGUAGE:ASM_MASM>:/ZH:SHA_256>)
+
+ if (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)
+ # Contracts work too slow on ARM/ARM64 DEBUG/CHECKED.
+ add_definitions(-DDISABLE_CONTRACTS)
+ endif (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)
+
+ # Don't display the output header when building RC files.
+ add_compile_options($<$<COMPILE_LANGUAGE:RC>:/nologo>)
+endif (MSVC)
+
+if(CLR_CMAKE_ENABLE_CODE_COVERAGE)
+
+ if(CLR_CMAKE_HOST_UNIX)
+ string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_CMAKE_BUILD_TYPE)
+ if(NOT UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
+ message( WARNING "Code coverage results with an optimised (non-Debug) build may be misleading" )
+ endif(NOT UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
+
+ add_compile_options(-fprofile-arcs)
+ add_compile_options(-ftest-coverage)
+ add_linker_flag(--coverage)
+ else()
+ message(FATAL_ERROR "Code coverage builds not supported on current platform")
+ endif(CLR_CMAKE_HOST_UNIX)
+
+endif(CLR_CMAKE_ENABLE_CODE_COVERAGE)
+
+if (CMAKE_GENERATOR MATCHES "(Makefile|Ninja)")
+ set(CMAKE_RC_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
+endif()
+
+# Ensure other tools are present
+if (CLR_CMAKE_HOST_WIN32)
+ if(CLR_CMAKE_HOST_ARCH_ARM)
+
+ # Explicitly specify the assembler to be used for Arm32 compile
+ file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm\\armasm.exe" CMAKE_ASM_COMPILER)
+
+ set(CMAKE_ASM_MASM_COMPILER ${CMAKE_ASM_COMPILER})
+ message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}")
+
+ # Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly
+ # use ml[64].exe as the assembler.
+ enable_language(ASM)
+ set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "")
+ set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "")
+ set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "")
+ set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "")
+ set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -g <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")
+
+ elseif(CLR_CMAKE_HOST_ARCH_ARM64)
+
+ # Explicitly specify the assembler to be used for Arm64 compile
+ file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER)
+
+ set(CMAKE_ASM_MASM_COMPILER ${CMAKE_ASM_COMPILER})
+ message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}")
+
+ # Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly
+ # use ml[64].exe as the assembler.
+ enable_language(ASM)
+ set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "")
+ set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "")
+ set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "")
+ set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "")
+ set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -g <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")
+ else()
+ enable_language(ASM_MASM)
+ set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "")
+ set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "")
+ set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "")
+ set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "")
+ endif()
+
+ # Ensure that MC is present
+ find_program(MC mc)
+ if (MC STREQUAL "MC-NOTFOUND")
+ message(FATAL_ERROR "MC not found")
+ endif()
+
+elseif (NOT CLR_CMAKE_HOST_BROWSER)
+ enable_language(ASM)
+
+endif(CLR_CMAKE_HOST_WIN32)
--- /dev/null
+if(CLR_CMAKE_HOST_WIN32)
+ add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:Debug>>:/Od>)
+ if (CLR_CMAKE_HOST_ARCH_I386)
+ # The Windows x86 Checked CLR has some kind of problem with exception handling
+ # when compiled with /O2. Issue: https://github.com/dotnet/runtime/issues/59845.
+ add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:Checked>>:/O1>)
+ else()
+ add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:Checked>>:/O2>)
+ endif()
+ add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:Release>>:/Ox>)
+ add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:RelWithDebInfo>>:/O2>)
+elseif(CLR_CMAKE_HOST_UNIX)
+ add_compile_options($<$<CONFIG:Debug>:-O0>)
+ add_compile_options($<$<CONFIG:Checked>:-O2>)
+ add_compile_options($<$<CONFIG:Release>:-O3>)
+ add_compile_options($<$<CONFIG:RelWithDebInfo>:-O2>)
+endif()
--- /dev/null
+get_filename_component(CLR_REPO_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUTE)
+set(CLR_ENG_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR})
+get_filename_component(CLR_SRC_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../src/native ABSOLUTE)
+get_filename_component(CLR_SRC_LIBS_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../src/libraries/Native ABSOLUTE)
+set (CLR_ARTIFACTS_OBJ_DIR "${CLR_REPO_ROOT_DIR}/artifacts/obj")
+set(VERSION_HEADER_PATH "${CLR_ARTIFACTS_OBJ_DIR}/_version.h")
+set(VERSION_FILE_PATH "${CLR_ARTIFACTS_OBJ_DIR}/_version.c")
+set(VERSION_FILE_RC_PATH "${CLR_ARTIFACTS_OBJ_DIR}/NativeVersion.rc")
+set(RUNTIME_VERSION_HEADER_PATH "${CLR_ARTIFACTS_OBJ_DIR}/runtime_version.h")
--- /dev/null
+include(${CMAKE_CURRENT_LIST_DIR}/functions.cmake)
+
+# If set, indicates that this is not an officially supported release
+# Keep in sync with IsPrerelease in Directory.Build.props
+set(PRERELEASE 1)
+
+#----------------------------------------
+# Detect and set platform variable names
+# - for non-windows build platform & architecture is detected using inbuilt CMAKE variables and cross target component configure
+# - for windows we use the passed in parameter to CMAKE to determine build arch
+#----------------------------------------
+set(CLR_CMAKE_HOST_OS ${CMAKE_SYSTEM_NAME})
+if(CLR_CMAKE_HOST_OS STREQUAL Linux)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ if(CLR_CROSS_COMPONENTS_BUILD)
+ # CMAKE_HOST_SYSTEM_PROCESSOR returns the value of `uname -p` on host.
+ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL amd64)
+ if(CLR_CMAKE_TARGET_ARCH STREQUAL "arm" OR CLR_CMAKE_TARGET_ARCH STREQUAL "armel")
+ if(CMAKE_CROSSCOMPILING)
+ set(CLR_CMAKE_HOST_UNIX_X86 1)
+ else()
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ endif()
+ else()
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ endif()
+ elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL i686)
+ set(CLR_CMAKE_HOST_UNIX_X86 1)
+ else()
+ clr_unknown_arch()
+ endif()
+ else()
+ # CMAKE_SYSTEM_PROCESSOR returns the value of `uname -p` on target.
+ # For the AMD/Intel 64bit architecture two different strings are common.
+ # Linux and Darwin identify it as "x86_64" while FreeBSD and netbsd uses the
+ # "amd64" string. Accept either of the two here.
+ if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
+ set(CLR_CMAKE_HOST_UNIX_ARM 1)
+ set(CLR_CMAKE_HOST_UNIX_ARMV7L 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm OR CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a)
+ set(CLR_CMAKE_HOST_UNIX_ARM 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
+ set(CLR_CMAKE_HOST_UNIX_ARM64 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686 OR CMAKE_SYSTEM_PROCESSOR STREQUAL x86)
+ set(CLR_CMAKE_HOST_UNIX_X86 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL s390x)
+ set(CLR_CMAKE_HOST_UNIX_S390X 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL mips64)
+ set(CLR_CMAKE_HOST_UNIX_MIPS64 1)
+ else()
+ clr_unknown_arch()
+ endif()
+ endif()
+ set(CLR_CMAKE_HOST_LINUX 1)
+
+ # Detect Linux ID
+ set(LINUX_ID_FILE "/etc/os-release")
+ if(CMAKE_CROSSCOMPILING)
+ set(LINUX_ID_FILE "${CMAKE_SYSROOT}${LINUX_ID_FILE}")
+ endif()
+
+ if(EXISTS ${LINUX_ID_FILE})
+ execute_process(
+ COMMAND bash -c "source ${LINUX_ID_FILE} && echo \$ID"
+ OUTPUT_VARIABLE CLR_CMAKE_LINUX_ID
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ endif()
+
+ if(DEFINED CLR_CMAKE_LINUX_ID)
+ if(CLR_CMAKE_LINUX_ID STREQUAL tizen)
+ set(CLR_CMAKE_TARGET_TIZEN_LINUX 1)
+ set(CLR_CMAKE_HOST_OS ${CLR_CMAKE_LINUX_ID})
+ elseif(CLR_CMAKE_LINUX_ID STREQUAL alpine)
+ set(CLR_CMAKE_HOST_ALPINE_LINUX 1)
+ set(CLR_CMAKE_HOST_OS ${CLR_CMAKE_LINUX_ID})
+ endif()
+ endif(DEFINED CLR_CMAKE_LINUX_ID)
+endif(CLR_CMAKE_HOST_OS STREQUAL Linux)
+
+if(CLR_CMAKE_HOST_OS STREQUAL Darwin)
+ set(CLR_CMAKE_HOST_UNIX 1)
+
+ if(CMAKE_SYSTEM_VARIANT STREQUAL MacCatalyst)
+ set(CLR_CMAKE_HOST_MACCATALYST 1)
+ else()
+ set(CLR_CMAKE_HOST_OSX 1)
+ endif(CMAKE_SYSTEM_VARIANT STREQUAL MacCatalyst)
+
+ if(CMAKE_OSX_ARCHITECTURES STREQUAL x86_64)
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ elseif(CMAKE_OSX_ARCHITECTURES STREQUAL arm64)
+ set(CLR_CMAKE_HOST_UNIX_ARM64 1)
+ else()
+ clr_unknown_arch()
+ endif()
+ set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> <INCLUDES> -o <OBJECT> -c <SOURCE>")
+endif(CLR_CMAKE_HOST_OS STREQUAL Darwin)
+
+if(CLR_CMAKE_HOST_OS STREQUAL iOS OR CLR_CMAKE_HOST_OS STREQUAL iOSSimulator)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ set(CLR_CMAKE_HOST_IOS 1)
+ if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ elseif(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
+ set(CLR_CMAKE_HOST_UNIX_X86 1)
+ elseif(CMAKE_OSX_ARCHITECTURES MATCHES "armv7")
+ set(CLR_CMAKE_HOST_UNIX_ARM 1)
+ elseif(CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
+ set(CLR_CMAKE_HOST_UNIX_ARM64 1)
+ else()
+ clr_unknown_arch()
+ endif()
+endif(CLR_CMAKE_HOST_OS STREQUAL iOS OR CLR_CMAKE_HOST_OS STREQUAL iOSSimulator)
+
+if(CLR_CMAKE_HOST_OS STREQUAL tvOS OR CLR_CMAKE_HOST_OS STREQUAL tvOSSimulator)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ set(CLR_CMAKE_HOST_TVOS 1)
+ if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ elseif(CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
+ set(CLR_CMAKE_HOST_UNIX_ARM64 1)
+ else()
+ clr_unknown_arch()
+ endif()
+endif(CLR_CMAKE_HOST_OS STREQUAL tvOS OR CLR_CMAKE_HOST_OS STREQUAL tvOSSimulator)
+
+if(CLR_CMAKE_HOST_OS STREQUAL Android)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ set(CLR_CMAKE_HOST_LINUX 1)
+ set(CLR_CMAKE_HOST_ANDROID 1)
+ if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a)
+ set(CLR_CMAKE_HOST_UNIX_ARM 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
+ set(CLR_CMAKE_HOST_UNIX_ARM64 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
+ set(CLR_CMAKE_HOST_UNIX_X86 1)
+ else()
+ clr_unknown_arch()
+ endif()
+endif(CLR_CMAKE_HOST_OS STREQUAL Android)
+
+if(CLR_CMAKE_HOST_OS STREQUAL FreeBSD)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ set(CLR_CMAKE_HOST_FREEBSD 1)
+endif(CLR_CMAKE_HOST_OS STREQUAL FreeBSD)
+
+if(CLR_CMAKE_HOST_OS STREQUAL OpenBSD)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ set(CLR_CMAKE_HOST_OPENBSD 1)
+endif(CLR_CMAKE_HOST_OS STREQUAL OpenBSD)
+
+if(CLR_CMAKE_HOST_OS STREQUAL NetBSD)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ set(CLR_CMAKE_HOST_NETBSD 1)
+endif(CLR_CMAKE_HOST_OS STREQUAL NetBSD)
+
+if(CLR_CMAKE_HOST_OS STREQUAL SunOS)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ EXECUTE_PROCESS(
+ COMMAND isainfo -n
+ OUTPUT_VARIABLE SUNOS_NATIVE_INSTRUCTION_SET)
+
+ if(SUNOS_NATIVE_INSTRUCTION_SET MATCHES "amd64" OR CMAKE_CROSSCOMPILING)
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ set(CMAKE_SYSTEM_PROCESSOR "amd64")
+ else()
+ clr_unknown_arch()
+ endif()
+
+ EXECUTE_PROCESS(
+ COMMAND uname -o
+ OUTPUT_VARIABLE SUNOS_KERNEL_KIND
+ ERROR_QUIET)
+
+ set(CLR_CMAKE_HOST_SUNOS 1)
+ if(SUNOS_KERNEL_KIND STREQUAL illumos OR CMAKE_CROSSCOMPILING)
+ set(CLR_CMAKE_HOST_OS_ILLUMOS 1)
+ else(SUNOS_KERNEL_KIND STREQUAL illumos OR CMAKE_CROSSCOMPILING)
+ set(CLR_CMAKE_HOST_OS_SOLARIS 1)
+ endif(SUNOS_KERNEL_KIND STREQUAL illumos OR CMAKE_CROSSCOMPILING)
+endif(CLR_CMAKE_HOST_OS STREQUAL SunOS)
+
+if(CLR_CMAKE_HOST_OS STREQUAL Windows)
+ set(CLR_CMAKE_HOST_OS windows)
+ set(CLR_CMAKE_HOST_WIN32 1)
+endif(CLR_CMAKE_HOST_OS STREQUAL Windows)
+
+if(CLR_CMAKE_HOST_OS STREQUAL Emscripten)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ set(CLR_CMAKE_HOST_BROWSER 1)
+endif(CLR_CMAKE_HOST_OS STREQUAL Emscripten)
+
+#--------------------------------------------
+# This repo builds two set of binaries
+# 1. binaries which execute on target arch machine
+# - for such binaries host architecture & target architecture are same
+# - eg. coreclr.dll
+# 2. binaries which execute on host machine but target another architecture
+# - host architecture is different from target architecture
+# - eg. crossgen.exe - runs on x64 machine and generates nis targeting arm64
+# - for complete list of such binaries refer to file crosscomponents.cmake
+#-------------------------------------------------------------
+# Set HOST architecture variables
+if(CLR_CMAKE_HOST_UNIX_ARM)
+ set(CLR_CMAKE_HOST_ARCH_ARM 1)
+ set(CLR_CMAKE_HOST_ARCH "arm")
+
+ if(CLR_CMAKE_HOST_UNIX_ARMV7L)
+ set(CLR_CMAKE_HOST_ARCH_ARMV7L 1)
+ endif()
+elseif(CLR_CMAKE_HOST_UNIX_ARM64)
+ set(CLR_CMAKE_HOST_ARCH_ARM64 1)
+ set(CLR_CMAKE_HOST_ARCH "arm64")
+elseif(CLR_CMAKE_HOST_UNIX_AMD64)
+ set(CLR_CMAKE_HOST_ARCH_AMD64 1)
+ set(CLR_CMAKE_HOST_ARCH "x64")
+elseif(CLR_CMAKE_HOST_UNIX_X86)
+ set(CLR_CMAKE_HOST_ARCH_I386 1)
+ set(CLR_CMAKE_HOST_ARCH "x86")
+elseif(CLR_CMAKE_HOST_UNIX_S390X)
+ set(CLR_CMAKE_HOST_ARCH_S390X 1)
+ set(CLR_CMAKE_HOST_ARCH "s390x")
+elseif(CLR_CMAKE_HOST_BROWSER)
+ set(CLR_CMAKE_HOST_ARCH_WASM 1)
+ set(CLR_CMAKE_HOST_ARCH "wasm")
+elseif(CLR_CMAKE_HOST_UNIX_MIPS64)
+ set(CLR_CMAKE_HOST_ARCH_MIPS64 1)
+ set(CLR_CMAKE_HOST_ARCH "mips64")
+elseif(WIN32)
+ # CLR_CMAKE_HOST_ARCH is passed in as param to cmake
+ if (CLR_CMAKE_HOST_ARCH STREQUAL x64)
+ set(CLR_CMAKE_HOST_ARCH_AMD64 1)
+ elseif(CLR_CMAKE_HOST_ARCH STREQUAL x86)
+ set(CLR_CMAKE_HOST_ARCH_I386 1)
+ elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm)
+ set(CLR_CMAKE_HOST_ARCH_ARM 1)
+ elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm64)
+ set(CLR_CMAKE_HOST_ARCH_ARM64 1)
+ else()
+ clr_unknown_arch()
+ endif()
+endif()
+
+# Set TARGET architecture variables
+# Target arch will be a cmake param (optional) for both windows as well as non-windows build
+# if target arch is not specified then host & target are same
+if(NOT DEFINED CLR_CMAKE_TARGET_ARCH OR CLR_CMAKE_TARGET_ARCH STREQUAL "" )
+ set(CLR_CMAKE_TARGET_ARCH ${CLR_CMAKE_HOST_ARCH})
+
+ # This is required for "arm" targets (CMAKE_SYSTEM_PROCESSOR "armv7l"),
+ # for which this flag otherwise won't be set up below
+ if (CLR_CMAKE_HOST_ARCH_ARMV7L)
+ set(CLR_CMAKE_TARGET_ARCH_ARMV7L 1)
+ endif()
+endif()
+
+# Set target architecture variables
+if (CLR_CMAKE_TARGET_ARCH STREQUAL x64)
+ set(CLR_CMAKE_TARGET_ARCH_AMD64 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86)
+ set(CLR_CMAKE_TARGET_ARCH_I386 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm64)
+ set(CLR_CMAKE_TARGET_ARCH_ARM64 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm)
+ set(CLR_CMAKE_TARGET_ARCH_ARM 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL armel)
+ set(CLR_CMAKE_TARGET_ARCH_ARM 1)
+ set(CLR_CMAKE_TARGET_ARCH_ARMV7L 1)
+ set(ARM_SOFTFP 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL s390x)
+ set(CLR_CMAKE_TARGET_ARCH_S390X 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL wasm)
+ set(CLR_CMAKE_TARGET_ARCH_WASM 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL mips64)
+ set(CLR_CMAKE_TARGET_ARCH_MIPS64 1)
+ else()
+ clr_unknown_arch()
+endif()
+
+# Set TARGET architecture variables
+# Target os will be a cmake param (optional) for both windows as well as non-windows build
+# if target os is not specified then host & target os are same
+if (NOT DEFINED CLR_CMAKE_TARGET_OS OR CLR_CMAKE_TARGET_OS STREQUAL "" )
+ set(CLR_CMAKE_TARGET_OS ${CLR_CMAKE_HOST_OS})
+endif()
+
+if(CLR_CMAKE_TARGET_OS STREQUAL Linux)
+ set(CLR_CMAKE_TARGET_UNIX 1)
+ set(CLR_CMAKE_TARGET_LINUX 1)
+endif(CLR_CMAKE_TARGET_OS STREQUAL Linux)
+
+if(CLR_CMAKE_TARGET_OS STREQUAL tizen)
+ set(CLR_CMAKE_TARGET_UNIX 1)
+ set(CLR_CMAKE_TARGET_LINUX 1)
+ set(CLR_CMAKE_TARGET_TIZEN_LINUX 1)
+endif(CLR_CMAKE_TARGET_OS STREQUAL tizen)
+
+if(CLR_CMAKE_TARGET_OS STREQUAL alpine)
+ set(CLR_CMAKE_TARGET_UNIX 1)
+ set(CLR_CMAKE_TARGET_LINUX 1)
+ set(CLR_CMAKE_TARGET_ALPINE_LINUX 1)
+endif(CLR_CMAKE_TARGET_OS STREQUAL alpine)
+
+if(CLR_CMAKE_TARGET_OS STREQUAL Android)
+ set(CLR_CMAKE_TARGET_UNIX 1)
+ set(CLR_CMAKE_TARGET_LINUX 1)
+ set(CLR_CMAKE_TARGET_ANDROID 1)
+endif(CLR_CMAKE_TARGET_OS STREQUAL Android)
+
+if(CLR_CMAKE_TARGET_OS STREQUAL Darwin)
+ set(CLR_CMAKE_TARGET_UNIX 1)
+
+ if(CMAKE_SYSTEM_VARIANT STREQUAL MacCatalyst)
+ set(CLR_CMAKE_TARGET_MACCATALYST 1)
+ else()
+ set(CLR_CMAKE_TARGET_OSX 1)
+ endif(CMAKE_SYSTEM_VARIANT STREQUAL MacCatalyst)
+endif(CLR_CMAKE_TARGET_OS STREQUAL Darwin)
+
+if(CLR_CMAKE_TARGET_OS STREQUAL iOS OR CLR_CMAKE_TARGET_OS STREQUAL iOSSimulator)
+ set(CLR_CMAKE_TARGET_UNIX 1)
+ set(CLR_CMAKE_TARGET_IOS 1)
+endif(CLR_CMAKE_TARGET_OS STREQUAL iOS OR CLR_CMAKE_TARGET_OS STREQUAL iOSSimulator)
+
+if(CLR_CMAKE_TARGET_OS STREQUAL tvOS OR CLR_CMAKE_TARGET_OS STREQUAL tvOSSimulator)
+ set(CLR_CMAKE_TARGET_UNIX 1)
+ set(CLR_CMAKE_TARGET_TVOS 1)
+endif(CLR_CMAKE_TARGET_OS STREQUAL tvOS OR CLR_CMAKE_TARGET_OS STREQUAL tvOSSimulator)
+
+if(CLR_CMAKE_TARGET_OS STREQUAL FreeBSD)
+ set(CLR_CMAKE_TARGET_UNIX 1)
+ set(CLR_CMAKE_TARGET_FREEBSD 1)
+endif(CLR_CMAKE_TARGET_OS STREQUAL FreeBSD)
+
+if(CLR_CMAKE_TARGET_OS STREQUAL OpenBSD)
+ set(CLR_CMAKE_TARGET_UNIX 1)
+ set(CLR_CMAKE_TARGET_OPENBSD 1)
+endif(CLR_CMAKE_TARGET_OS STREQUAL OpenBSD)
+
+if(CLR_CMAKE_TARGET_OS STREQUAL NetBSD)
+ set(CLR_CMAKE_TARGET_UNIX 1)
+ set(CLR_CMAKE_TARGET_NETBSD 1)
+endif(CLR_CMAKE_TARGET_OS STREQUAL NetBSD)
+
+if(CLR_CMAKE_TARGET_OS STREQUAL SunOS)
+ set(CLR_CMAKE_TARGET_UNIX 1)
+ if(CLR_CMAKE_HOST_OS_ILLUMOS)
+ set(CLR_CMAKE_TARGET_OS_ILLUMOS 1)
+ else(CLR_CMAKE_HOST_OS_ILLUMOS)
+ set(CLR_CMAKE_TARGET_OS_SOLARIS 1)
+ endif(CLR_CMAKE_HOST_OS_ILLUMOS)
+ set(CLR_CMAKE_TARGET_SUNOS 1)
+endif(CLR_CMAKE_TARGET_OS STREQUAL SunOS)
+
+if(CLR_CMAKE_TARGET_OS STREQUAL Emscripten)
+ set(CLR_CMAKE_TARGET_UNIX 1)
+ set(CLR_CMAKE_TARGET_LINUX 1)
+ set(CLR_CMAKE_TARGET_BROWSER 1)
+endif(CLR_CMAKE_TARGET_OS STREQUAL Emscripten)
+
+if(CLR_CMAKE_TARGET_UNIX)
+ if(CLR_CMAKE_TARGET_ARCH STREQUAL x64)
+ set(CLR_CMAKE_TARGET_UNIX_AMD64 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL armel)
+ set(CLR_CMAKE_TARGET_UNIX_ARM 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm)
+ set(CLR_CMAKE_TARGET_UNIX_ARM 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm64)
+ set(CLR_CMAKE_TARGET_UNIX_ARM64 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86)
+ set(CLR_CMAKE_TARGET_UNIX_X86 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL s390x)
+ set(CLR_CMAKE_TARGET_UNIX_S390X 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL wasm)
+ set(CLR_CMAKE_TARGET_UNIX_WASM 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL mips64)
+ set(CLR_CMAKE_TARGET_UNIX_MIPS64 1)
+ else()
+ clr_unknown_arch()
+ endif()
+else()
+ set(CLR_CMAKE_TARGET_WIN32 1)
+endif(CLR_CMAKE_TARGET_UNIX)
+
+# check if host & target os/arch combination are valid
+if (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS)
+ if(NOT(CLR_CMAKE_TARGET_ARCH STREQUAL CLR_CMAKE_HOST_ARCH))
+ if(NOT((CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_ARM64) OR (CLR_CMAKE_HOST_ARCH_I386 AND CLR_CMAKE_TARGET_ARCH_ARM) OR (CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_ARM) OR (CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_I386)))
+ message(FATAL_ERROR "Invalid platform and target arch combination TARGET_ARCH=${CLR_CMAKE_TARGET_ARCH} HOST_ARCH=${CLR_CMAKE_HOST_ARCH}")
+ endif()
+ endif()
+else()
+ if(NOT (CLR_CMAKE_HOST_OS STREQUAL windows))
+ message(FATAL_ERROR "Invalid host and target os/arch combination. Host OS: ${CLR_CMAKE_HOST_OS}")
+ endif()
+ if(NOT (CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_ALPINE_LINUX))
+ message(FATAL_ERROR "Invalid host and target os/arch combination. Target OS: ${CLR_CMAKE_TARGET_OS}")
+ endif()
+ if(NOT ((CLR_CMAKE_HOST_ARCH_AMD64 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64)) OR (CLR_CMAKE_HOST_ARCH_I386 AND CLR_CMAKE_TARGET_ARCH_ARM)))
+ message(FATAL_ERROR "Invalid host and target os/arch combination. Host Arch: ${CLR_CMAKE_HOST_ARCH} Target Arch: ${CLR_CMAKE_TARGET_ARCH}")
+ endif()
+endif()
+
+if(NOT CLR_CMAKE_TARGET_BROWSER)
+ # The default linker on Solaris also does not support PIE.
+ if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS AND NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_IOS AND NOT MSVC)
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
+ add_compile_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-fPIE>)
+ add_compile_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:-fPIC>)
+ endif()
+
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+endif()
+
+string(TOLOWER "${CMAKE_BUILD_TYPE}" LOWERCASE_CMAKE_BUILD_TYPE)
+if(LOWERCASE_CMAKE_BUILD_TYPE STREQUAL debug)
+ # Clear _FORTIFY_SOURCE=2, if set
+ string(REPLACE "-D_FORTIFY_SOURCE=2 " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ string(REPLACE "-D_FORTIFY_SOURCE=2 " "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+endif()
--- /dev/null
+include(${CMAKE_CURRENT_LIST_DIR}/configureplatform.cmake)
+
+# Get the version of the compiler that is in the file name for tool location.
+set (CLR_CMAKE_COMPILER_FILE_NAME_VERSION "")
+if (CMAKE_C_COMPILER MATCHES "-?[0-9]+(\.[0-9]+)?$")
+ set(CLR_CMAKE_COMPILER_FILE_NAME_VERSION "${CMAKE_MATCH_0}")
+endif()
+
+if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_BROWSER)
+ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ if(APPLE)
+ set(TOOLSET_PREFIX "")
+ else()
+ set(TOOLSET_PREFIX "llvm-")
+ endif()
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ if(CMAKE_CROSSCOMPILING)
+ set(TOOLSET_PREFIX "${CMAKE_CXX_COMPILER_TARGET}-")
+ else()
+ set(TOOLSET_PREFIX "")
+ endif()
+ endif()
+
+ function(locate_toolchain_exec exec var)
+ string(TOUPPER ${exec} EXEC_UPPERCASE)
+ if(NOT "$ENV{CLR_${EXEC_UPPERCASE}}" STREQUAL "")
+ set(${var} "$ENV{CLR_${EXEC_UPPERCASE}}" PARENT_SCOPE)
+ return()
+ endif()
+
+ find_program(EXEC_LOCATION_${exec}
+ NAMES
+ "${TOOLSET_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}"
+ "${TOOLSET_PREFIX}${exec}")
+
+ if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND")
+ message(FATAL_ERROR "Unable to find toolchain executable. Name: ${exec}, Prefix: ${TOOLSET_PREFIX}.")
+ endif()
+ set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE)
+ endfunction()
+
+ locate_toolchain_exec(ar CMAKE_AR)
+ locate_toolchain_exec(nm CMAKE_NM)
+ locate_toolchain_exec(ranlib CMAKE_RANLIB)
+
+ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+ locate_toolchain_exec(link CMAKE_LINKER)
+ endif()
+
+ if(NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND (NOT CLR_CMAKE_TARGET_ANDROID OR CROSS_ROOTFS))
+ locate_toolchain_exec(objdump CMAKE_OBJDUMP)
+
+ if(CLR_CMAKE_TARGET_ANDROID)
+ set(TOOLSET_PREFIX ${ANDROID_TOOLCHAIN_PREFIX})
+ elseif(CMAKE_CROSSCOMPILING AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD AND (CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l OR
+ CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm OR CMAKE_SYSTEM_PROCESSOR STREQUAL s390x))
+ set(TOOLSET_PREFIX "${TOOLCHAIN}-")
+ else()
+ set(TOOLSET_PREFIX "")
+ endif()
+
+ locate_toolchain_exec(objcopy CMAKE_OBJCOPY)
+ endif()
+endif()
+
+if (NOT CLR_CMAKE_HOST_WIN32)
+ # detect linker
+ separate_arguments(ldVersion UNIX_COMMAND "${CMAKE_C_COMPILER} ${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version")
+ execute_process(COMMAND ${ldVersion}
+ ERROR_QUIET
+ OUTPUT_VARIABLE ldVersionOutput)
+
+ if("${ldVersionOutput}" MATCHES "LLD")
+ set(LD_LLVM 1)
+ elseif("${ldVersionOutput}" MATCHES "GNU ld" OR "${ldVersionOutput}" MATCHES "GNU gold" OR "${ldVersionOutput}" MATCHES "GNU linkers")
+ set(LD_GNU 1)
+ elseif("${ldVersionOutput}" MATCHES "Solaris Link")
+ set(LD_SOLARIS 1)
+ else(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST)
+ set(LD_OSX 1)
+ endif()
+endif()
--- /dev/null
+function(clr_unknown_arch)
+ if (WIN32)
+ message(FATAL_ERROR "Only AMD64, ARM64, ARM and I386 are supported. Found: ${CMAKE_SYSTEM_PROCESSOR}")
+ elseif(CLR_CROSS_COMPONENTS_BUILD)
+ message(FATAL_ERROR "Only AMD64, I386 host are supported for linux cross-architecture component. Found: ${CMAKE_SYSTEM_PROCESSOR}")
+ else()
+ message(FATAL_ERROR "Only AMD64, ARM64 and ARM are supported. Found: ${CMAKE_SYSTEM_PROCESSOR}")
+ endif()
+endfunction()
+
+# Build a list of compiler definitions by putting -D in front of each define.
+function(get_compile_definitions DefinitionName)
+ # Get the current list of definitions
+ get_directory_property(COMPILE_DEFINITIONS_LIST COMPILE_DEFINITIONS)
+
+ # The entries that contain generator expressions must have the -D inside of the
+ # expression. So we transform e.g. $<$<CONFIG:Debug>:_DEBUG> to $<$<CONFIG:Debug>:-D_DEBUG>
+
+ # CMake's support for multiple values within a single generator expression is somewhat ad-hoc.
+ # Since we have a number of complex generator expressions, we use them with multiple values to ensure that
+ # we don't forget to update all of the generator expressions if one needs to be updated.
+ # As a result, we need to expand out the multi-valued generator expression to wrap each individual value here.
+ # Otherwise, CMake will fail to expand it.
+ set(LastGeneratorExpression "")
+ foreach(DEFINITION IN LISTS COMPILE_DEFINITIONS_LIST)
+ # If there is a definition that uses the $<TARGET_PROPERTY:prop> generator expression
+ # we need to remove it since that generator expression is only valid on binary targets.
+ # Assume that the value is 0.
+ string(REGEX REPLACE "\\$<TARGET_PROPERTY:[^,>]+>" "0" DEFINITION "${DEFINITION}")
+
+ if (${DEFINITION} MATCHES "^\\$<(.+):([^>]+)(>?)$")
+ if("${CMAKE_MATCH_3}" STREQUAL "")
+ set(DEFINITION "$<${CMAKE_MATCH_1}:-D${CMAKE_MATCH_2}>")
+ set(LastGeneratorExpression "${CMAKE_MATCH_1}")
+ else()
+ set(DEFINITION "$<${CMAKE_MATCH_1}:-D${CMAKE_MATCH_2}>")
+ endif()
+ elseif(${DEFINITION} MATCHES "([^>]+)>$")
+ # This entry is the last in a list nested within a generator expression.
+ set(DEFINITION "$<${LastGeneratorExpression}:-D${CMAKE_MATCH_1}>")
+ set(LastGeneratorExpression "")
+ elseif(NOT "${LastGeneratorExpression}" STREQUAL "")
+ set(DEFINITION "$<${LastGeneratorExpression}:-D${DEFINITION}>")
+ else()
+ set(DEFINITION -D${DEFINITION})
+ endif()
+ list(APPEND DEFINITIONS ${DEFINITION})
+ endforeach()
+ set(${DefinitionName} ${DEFINITIONS} PARENT_SCOPE)
+endfunction(get_compile_definitions)
+
+# Build a list of include directories
+function(get_include_directories IncludeDirectories)
+ get_directory_property(dirs INCLUDE_DIRECTORIES)
+ foreach(dir IN LISTS dirs)
+
+ if (CLR_CMAKE_HOST_ARCH_ARM AND WIN32)
+ list(APPEND INC_DIRECTORIES /I${dir})
+ else()
+ list(APPEND INC_DIRECTORIES -I${dir})
+ endif(CLR_CMAKE_HOST_ARCH_ARM AND WIN32)
+
+ endforeach()
+ set(${IncludeDirectories} ${INC_DIRECTORIES} PARENT_SCOPE)
+endfunction(get_include_directories)
+
+# Build a list of include directories for consumption by the assembler
+function(get_include_directories_asm IncludeDirectories)
+ get_directory_property(dirs INCLUDE_DIRECTORIES)
+
+ foreach(dir IN LISTS dirs)
+ list(APPEND INC_DIRECTORIES -I${dir};)
+ endforeach()
+
+ set(${IncludeDirectories} ${INC_DIRECTORIES} PARENT_SCOPE)
+endfunction(get_include_directories_asm)
+
+# Finds and returns unwind libs
+function(find_unwind_libs UnwindLibs)
+ if(CLR_CMAKE_HOST_ARCH_ARM)
+ find_library(UNWIND_ARCH NAMES unwind-arm)
+ endif()
+
+ if(CLR_CMAKE_HOST_ARCH_ARM64)
+ find_library(UNWIND_ARCH NAMES unwind-aarch64)
+ endif()
+
+ if(CLR_CMAKE_HOST_ARCH_AMD64)
+ find_library(UNWIND_ARCH NAMES unwind-x86_64)
+ endif()
+
+ if(CLR_CMAKE_HOST_ARCH_S390X)
+ find_library(UNWIND_ARCH NAMES unwind-s390x)
+ endif()
+
+ if(NOT UNWIND_ARCH STREQUAL UNWIND_ARCH-NOTFOUND)
+ set(UNWIND_LIBS ${UNWIND_ARCH})
+ endif()
+
+ find_library(UNWIND_GENERIC NAMES unwind-generic)
+
+ if(NOT UNWIND_GENERIC STREQUAL UNWIND_GENERIC-NOTFOUND)
+ set(UNWIND_LIBS ${UNWIND_LIBS} ${UNWIND_GENERIC})
+ endif()
+
+ find_library(UNWIND NAMES unwind)
+
+ if(UNWIND STREQUAL UNWIND-NOTFOUND)
+ message(FATAL_ERROR "Cannot find libunwind. Try installing libunwind8-dev or libunwind-devel.")
+ endif()
+
+ set(${UnwindLibs} ${UNWIND_LIBS} ${UNWIND} PARENT_SCOPE)
+endfunction(find_unwind_libs)
+
+# Set the passed in RetSources variable to the list of sources with added current source directory
+# to form absolute paths.
+# The parameters after the RetSources are the input files.
+function(convert_to_absolute_path RetSources)
+ set(Sources ${ARGN})
+ foreach(Source IN LISTS Sources)
+ list(APPEND AbsolutePathSources ${CMAKE_CURRENT_SOURCE_DIR}/${Source})
+ endforeach()
+ set(${RetSources} ${AbsolutePathSources} PARENT_SCOPE)
+endfunction(convert_to_absolute_path)
+
+#Preprocess file
+function(preprocess_file inputFilename outputFilename)
+ get_compile_definitions(PREPROCESS_DEFINITIONS)
+ get_include_directories(PREPROCESS_INCLUDE_DIRECTORIES)
+ if (MSVC)
+ add_custom_command(
+ OUTPUT ${outputFilename}
+ COMMAND ${CMAKE_CXX_COMPILER} ${PREPROCESS_INCLUDE_DIRECTORIES} /P /EP /TC ${PREPROCESS_DEFINITIONS} /Fi${outputFilename} ${inputFilename} /nologo
+ DEPENDS ${inputFilename}
+ COMMENT "Preprocessing ${inputFilename}. Outputting to ${outputFilename}"
+ )
+ else()
+ add_custom_command(
+ OUTPUT ${outputFilename}
+ COMMAND ${CMAKE_CXX_COMPILER} -E -P ${PREPROCESS_DEFINITIONS} ${PREPROCESS_INCLUDE_DIRECTORIES} -o ${outputFilename} -x c ${inputFilename}
+ DEPENDS ${inputFilename}
+ COMMENT "Preprocessing ${inputFilename}. Outputting to ${outputFilename}"
+ )
+ endif()
+
+ set_source_files_properties(${outputFilename}
+ PROPERTIES GENERATED TRUE)
+endfunction()
+
+# preprocess_files(PreprocessedFilesList [fileToPreprocess1 [fileToPreprocess2 ...]])
+function(preprocess_files PreprocessedFilesList)
+ set(FilesToPreprocess ${ARGN})
+ foreach(ASM_FILE IN LISTS FilesToPreprocess)
+ # Inserts a custom command in CMake build to preprocess each asm source file
+ get_filename_component(name ${ASM_FILE} NAME_WE)
+ file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${name}.asm" ASM_PREPROCESSED_FILE)
+ preprocess_file(${ASM_FILE} ${ASM_PREPROCESSED_FILE})
+ list(APPEND PreprocessedFiles ${ASM_PREPROCESSED_FILE})
+ endforeach()
+ set(${PreprocessedFilesList} ${PreprocessedFiles} PARENT_SCOPE)
+endfunction()
+
+function(set_exports_linker_option exports_filename)
+ if(LD_GNU OR LD_SOLARIS OR LD_LLVM)
+ # Add linker exports file option
+ if(LD_SOLARIS)
+ set(EXPORTS_LINKER_OPTION -Wl,-M,${exports_filename} PARENT_SCOPE)
+ else()
+ set(EXPORTS_LINKER_OPTION -Wl,--version-script=${exports_filename} PARENT_SCOPE)
+ endif()
+ elseif(LD_OSX)
+ # Add linker exports file option
+ set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${exports_filename} PARENT_SCOPE)
+ endif()
+endfunction()
+
+# compile_asm(TARGET target ASM_FILES file1 [file2 ...] OUTPUT_OBJECTS [variableName])
+# CMake does not support the ARM or ARM64 assemblers on Windows when using the
+# MSBuild generator. When the MSBuild generator is in use, we manually compile the assembly files
+# using this function.
+function(compile_asm)
+ set(options "")
+ set(oneValueArgs TARGET OUTPUT_OBJECTS)
+ set(multiValueArgs ASM_FILES)
+ cmake_parse_arguments(COMPILE_ASM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV})
+
+ get_include_directories_asm(ASM_INCLUDE_DIRECTORIES)
+
+ set (ASSEMBLED_OBJECTS "")
+
+ foreach(ASM_FILE ${COMPILE_ASM_ASM_FILES})
+ get_filename_component(name ${ASM_FILE} NAME_WE)
+ # Produce object file where CMake would store .obj files for an OBJECT library.
+ # ex: artifacts\obj\coreclr\windows.arm64.Debug\src\vm\wks\cee_wks.dir\Debug\AsmHelpers.obj
+ set (OBJ_FILE "${CMAKE_CURRENT_BINARY_DIR}/${COMPILE_ASM_TARGET}.dir/${CMAKE_CFG_INTDIR}/${name}.obj")
+
+ # Need to compile asm file using custom command as include directories are not provided to asm compiler
+ add_custom_command(OUTPUT ${OBJ_FILE}
+ COMMAND "${CMAKE_ASM_COMPILER}" -g ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_FILE}
+ DEPENDS ${ASM_FILE}
+ COMMENT "Assembling ${ASM_FILE} ---> \"${CMAKE_ASM_COMPILER}\" -g ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_FILE}")
+
+ # mark obj as source that does not require compile
+ set_source_files_properties(${OBJ_FILE} PROPERTIES EXTERNAL_OBJECT TRUE)
+
+ # Add the generated OBJ in the dependency list so that it gets consumed during linkage
+ list(APPEND ASSEMBLED_OBJECTS ${OBJ_FILE})
+ endforeach()
+
+ set(${COMPILE_ASM_OUTPUT_OBJECTS} ${ASSEMBLED_OBJECTS} PARENT_SCOPE)
+endfunction()
+
+# add_component(componentName [targetName] [EXCLUDE_FROM_ALL])
+function(add_component componentName)
+ if (${ARGC} GREATER 2 OR ${ARGC} EQUAL 2)
+ set(componentTargetName "${ARGV1}")
+ else()
+ set(componentTargetName "${componentName}")
+ endif()
+ if (${ARGC} EQUAL 3 AND "${ARG2}" STREQUAL "EXCLUDE_FROM_ALL")
+ set(exclude_from_all_flag "EXCLUDE_FROM_ALL")
+ endif()
+ get_property(definedComponents GLOBAL PROPERTY CLR_CMAKE_COMPONENTS)
+ list (FIND definedComponents "${componentName}" componentIndex)
+ if (${componentIndex} EQUAL -1)
+ list (APPEND definedComponents "${componentName}")
+ add_custom_target("${componentTargetName}"
+ COMMAND "${CMAKE_COMMAND}" "-DCMAKE_INSTALL_COMPONENT=${componentName}" "-DBUILD_TYPE=$<CONFIG>" -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
+ ${exclude_from_all_flag})
+ set_property(GLOBAL PROPERTY CLR_CMAKE_COMPONENTS ${definedComponents})
+ endif()
+endfunction()
+
+function(generate_exports_file)
+ set(INPUT_LIST ${ARGN})
+ list(GET INPUT_LIST -1 outputFilename)
+ list(REMOVE_AT INPUT_LIST -1)
+
+ if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
+ set(SCRIPT_NAME generateexportedsymbols.sh)
+ else()
+ set(SCRIPT_NAME generateversionscript.sh)
+ endif()
+
+ add_custom_command(
+ OUTPUT ${outputFilename}
+ COMMAND ${CLR_ENG_NATIVE_DIR}/${SCRIPT_NAME} ${INPUT_LIST} >${outputFilename}
+ DEPENDS ${INPUT_LIST} ${CLR_ENG_NATIVE_DIR}/${SCRIPT_NAME}
+ COMMENT "Generating exports file ${outputFilename}"
+ )
+ set_source_files_properties(${outputFilename}
+ PROPERTIES GENERATED TRUE)
+endfunction()
+
+function(generate_exports_file_prefix inputFilename outputFilename prefix)
+
+ if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+ set(SCRIPT_NAME generateexportedsymbols.sh)
+ else()
+ set(SCRIPT_NAME generateversionscript.sh)
+ if (NOT ${prefix} STREQUAL "")
+ set(EXTRA_ARGS ${prefix})
+ endif()
+ endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+
+ add_custom_command(
+ OUTPUT ${outputFilename}
+ COMMAND ${CLR_ENG_NATIVE_DIR}/${SCRIPT_NAME} ${inputFilename} ${EXTRA_ARGS} >${outputFilename}
+ DEPENDS ${inputFilename} ${CLR_ENG_NATIVE_DIR}/${SCRIPT_NAME}
+ COMMENT "Generating exports file ${outputFilename}"
+ )
+ set_source_files_properties(${outputFilename}
+ PROPERTIES GENERATED TRUE)
+endfunction()
+
+function (get_symbol_file_name targetName outputSymbolFilename)
+ if (CLR_CMAKE_HOST_UNIX)
+ if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
+ set(strip_destination_file $<TARGET_FILE:${targetName}>.dwarf)
+ else ()
+ set(strip_destination_file $<TARGET_FILE:${targetName}>.dbg)
+ endif ()
+
+ set(${outputSymbolFilename} ${strip_destination_file} PARENT_SCOPE)
+ else(CLR_CMAKE_HOST_UNIX)
+ # We can't use the $<TARGET_PDB_FILE> generator expression here since
+ # the generator expression isn't supported on resource DLLs.
+ set(${outputSymbolFilename} $<TARGET_FILE_DIR:${targetName}>/$<TARGET_FILE_PREFIX:${targetName}>$<TARGET_FILE_BASE_NAME:${targetName}>.pdb PARENT_SCOPE)
+ endif(CLR_CMAKE_HOST_UNIX)
+endfunction()
+
+function(strip_symbols targetName outputFilename)
+ get_symbol_file_name(${targetName} strip_destination_file)
+ set(${outputFilename} ${strip_destination_file} PARENT_SCOPE)
+ if (CLR_CMAKE_HOST_UNIX)
+ set(strip_source_file $<TARGET_FILE:${targetName}>)
+
+ if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
+
+ # Ensure that dsymutil and strip are present
+ find_program(DSYMUTIL dsymutil)
+ if (DSYMUTIL STREQUAL "DSYMUTIL-NOTFOUND")
+ message(FATAL_ERROR "dsymutil not found")
+ endif()
+
+ find_program(STRIP strip)
+ if (STRIP STREQUAL "STRIP-NOTFOUND")
+ message(FATAL_ERROR "strip not found")
+ endif()
+
+ string(TOLOWER "${CMAKE_BUILD_TYPE}" LOWERCASE_CMAKE_BUILD_TYPE)
+ if (LOWERCASE_CMAKE_BUILD_TYPE STREQUAL release)
+ set(strip_command ${STRIP} -no_code_signature_warning -S ${strip_source_file} && codesign -f -s - ${strip_source_file})
+ else ()
+ set(strip_command)
+ endif ()
+
+ add_custom_command(
+ TARGET ${targetName}
+ POST_BUILD
+ VERBATIM
+ COMMAND ${DSYMUTIL} --flat --minimize ${strip_source_file}
+ COMMAND ${strip_command}
+ COMMENT "Stripping symbols from ${strip_source_file} into file ${strip_destination_file}"
+ )
+ else (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
+
+ add_custom_command(
+ TARGET ${targetName}
+ POST_BUILD
+ VERBATIM
+ COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
+ COMMAND ${CMAKE_OBJCOPY} --strip-unneeded ${strip_source_file}
+ COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file}
+ COMMENT "Stripping symbols from ${strip_source_file} into file ${strip_destination_file}"
+ )
+ endif (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
+ endif(CLR_CMAKE_HOST_UNIX)
+endfunction()
+
+function(install_with_stripped_symbols targetName kind destination)
+ if(NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS)
+ strip_symbols(${targetName} symbol_file)
+ install_symbol_file(${symbol_file} ${destination} ${ARGN})
+ endif()
+
+ if ((CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) AND ("${kind}" STREQUAL "TARGETS"))
+ # We want to avoid the kind=TARGET install behaviors which corrupt code signatures on osx-arm64
+ set(kind PROGRAMS)
+ endif()
+
+ if ("${kind}" STREQUAL "TARGETS")
+ set(install_source ${targetName})
+ elseif("${kind}" STREQUAL "PROGRAMS")
+ set(install_source $<TARGET_FILE:${targetName}>)
+ else()
+ message(FATAL_ERROR "The `kind` argument has to be either TARGETS or PROGRAMS, ${kind} was provided instead")
+ endif()
+ install(${kind} ${install_source} DESTINATION ${destination} ${ARGN})
+endfunction()
+
+function(install_symbol_file symbol_file destination_path)
+ if(CLR_CMAKE_TARGET_WIN32)
+ install(FILES ${symbol_file} DESTINATION ${destination_path}/PDB ${ARGN})
+ else()
+ install(FILES ${symbol_file} DESTINATION ${destination_path} ${ARGN})
+ endif()
+endfunction()
+
+# install_clr(TARGETS targetName [targetName2 ...] [DESTINATIONS destination [destination2 ...]] [COMPONENT componentName])
+function(install_clr)
+ set(multiValueArgs TARGETS DESTINATIONS)
+ set(singleValueArgs COMPONENT)
+ set(options "")
+ cmake_parse_arguments(INSTALL_CLR "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGV})
+
+ if ("${INSTALL_CLR_TARGETS}" STREQUAL "")
+ message(FATAL_ERROR "At least one target must be passed to install_clr(TARGETS )")
+ endif()
+
+ if ("${INSTALL_CLR_DESTINATIONS}" STREQUAL "")
+ message(FATAL_ERROR "At least one destination must be passed to install_clr.")
+ endif()
+
+ set(destinations "")
+
+ if (NOT "${INSTALL_CLR_DESTINATIONS}" STREQUAL "")
+ list(APPEND destinations ${INSTALL_CLR_DESTINATIONS})
+ endif()
+
+ if ("${INSTALL_CLR_COMPONENT}" STREQUAL "")
+ set(INSTALL_CLR_COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
+ endif()
+
+ foreach(targetName ${INSTALL_CLR_TARGETS})
+ if (NOT "${INSTALL_CLR_COMPONENT}" STREQUAL "${targetName}")
+ get_property(definedComponents GLOBAL PROPERTY CLR_CMAKE_COMPONENTS)
+ list(FIND definedComponents "${INSTALL_CLR_COMPONENT}" componentIdx)
+ if (${componentIdx} EQUAL -1)
+ message(FATAL_ERROR "The ${INSTALL_CLR_COMPONENT} component is not defined. Add a call to `add_component(${INSTALL_CLR_COMPONENT})` to define the component in the build.")
+ endif()
+ add_dependencies(${INSTALL_CLR_COMPONENT} ${targetName})
+ endif()
+ get_target_property(targetType ${targetName} TYPE)
+ if (NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS AND NOT "${targetType}" STREQUAL "STATIC_LIBRARY")
+ get_symbol_file_name(${targetName} symbolFile)
+ endif()
+
+ foreach(destination ${destinations})
+ # We don't need to install the export libraries for our DLLs
+ # since they won't be directly linked against.
+ install(PROGRAMS $<TARGET_FILE:${targetName}> DESTINATION ${destination} COMPONENT ${INSTALL_CLR_COMPONENT})
+ if (NOT "${symbolFile}" STREQUAL "")
+ install_symbol_file(${symbolFile} ${destination} COMPONENT ${INSTALL_CLR_COMPONENT})
+ endif()
+
+ if(CLR_CMAKE_PGO_INSTRUMENT)
+ if(WIN32)
+ get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if(is_multi_config)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pgd DESTINATION ${destination}/PGD OPTIONAL COMPONENT ${INSTALL_CLR_COMPONENT})
+ else()
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${targetName}.pgd DESTINATION ${destination}/PGD OPTIONAL COMPONENT ${INSTALL_CLR_COMPONENT})
+ endif()
+ endif()
+ endif()
+ endforeach()
+ endforeach()
+endfunction()
+
+# Disable PAX mprotect that would prevent JIT and other codegen in coreclr from working.
+# PAX mprotect prevents:
+# - changing the executable status of memory pages that were
+# not originally created as executable,
+# - making read-only executable pages writable again,
+# - creating executable pages from anonymous memory,
+# - making read-only-after-relocations (RELRO) data pages writable again.
+function(disable_pax_mprotect targetName)
+ # Disabling PAX hardening only makes sense in systems that use Elf image formats. Particularly, looking
+ # for paxctl in macOS is problematic as it collides with popular software for that OS that performs completely
+ # unrelated functionality. Only look for it when we'll generate Elf images.
+ if (CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS)
+ # Try to locate the paxctl tool. Failure to find it is not fatal,
+ # but the generated executables won't work on a system where PAX is set
+ # to prevent applications to create executable memory mappings.
+ find_program(PAXCTL paxctl)
+
+ if (NOT PAXCTL STREQUAL "PAXCTL-NOTFOUND")
+ add_custom_command(
+ TARGET ${targetName}
+ POST_BUILD
+ VERBATIM
+ COMMAND ${PAXCTL} -c -m $<TARGET_FILE:${targetName}>
+ )
+ endif()
+ endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS)
+endfunction()
+
+if (CMAKE_VERSION VERSION_LESS "3.12")
+ # Polyfill add_compile_definitions when it is unavailable
+ function(add_compile_definitions)
+ get_directory_property(DIR_COMPILE_DEFINITIONS COMPILE_DEFINITIONS)
+ list(APPEND DIR_COMPILE_DEFINITIONS ${ARGV})
+ set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${DIR_COMPILE_DEFINITIONS}")
+ endfunction()
+endif()
+
+if (CMAKE_VERSION VERSION_LESS "3.16")
+ # Provide a no-op polyfill for precompiled headers on old CMake versions
+ function(target_precompile_headers)
+ endfunction()
+endif()
+
+# add_linker_flag(Flag [Config1 Config2 ...])
+function(add_linker_flag Flag)
+ if (ARGN STREQUAL "")
+ set("CMAKE_EXE_LINKER_FLAGS" "${CMAKE_EXE_LINKER_FLAGS} ${Flag}" PARENT_SCOPE)
+ set("CMAKE_SHARED_LINKER_FLAGS" "${CMAKE_SHARED_LINKER_FLAGS} ${Flag}" PARENT_SCOPE)
+ else()
+ foreach(Config ${ARGN})
+ set("CMAKE_EXE_LINKER_FLAGS_${Config}" "${CMAKE_EXE_LINKER_FLAGS_${Config}} ${Flag}" PARENT_SCOPE)
+ set("CMAKE_SHARED_LINKER_FLAGS_${Config}" "${CMAKE_SHARED_LINKER_FLAGS_${Config}} ${Flag}" PARENT_SCOPE)
+ endforeach()
+ endif()
+endfunction()
+
+function(link_natvis_sources_for_target targetName linkKind)
+ if (NOT CLR_CMAKE_HOST_WIN32)
+ return()
+ 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()
+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)
+ 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()
+endfunction()
--- /dev/null
+@if not defined _echo @echo off
+rem
+rem This file invokes cmake and generates the build system for windows.
+
+setlocal
+
+set argC=0
+for %%x in (%*) do Set /A argC+=1
+
+if %argC% lss 4 GOTO :USAGE
+if %1=="/?" GOTO :USAGE
+
+setlocal enabledelayedexpansion
+set basePath=%~dp0
+set __repoRoot=%~dp0..\..\
+:: remove quotes
+set "basePath=%basePath:"=%"
+:: remove trailing slash
+if %basePath:~-1%==\ set "basePath=%basePath:~0,-1%"
+
+set __SourceDir=%1
+set __IntermediatesDir=%2
+set __VSVersion=%3
+set __Arch=%4
+set __CmakeGenerator=Visual Studio
+set __UseEmcmake=0
+if /i "%__Ninja%" == "1" (
+ set __CmakeGenerator=Ninja
+) else (
+ if /i NOT "%__Arch%" == "wasm" (
+ if /i "%__VSVersion%" == "vs2022" (set __CmakeGenerator=%__CmakeGenerator% 17 2022)
+ if /i "%__VSVersion%" == "vs2019" (set __CmakeGenerator=%__CmakeGenerator% 16 2019)
+ if /i "%__VSVersion%" == "vs2017" (set __CmakeGenerator=%__CmakeGenerator% 15 2017)
+
+ if /i "%__Arch%" == "x64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
+ if /i "%__Arch%" == "arm" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM)
+ if /i "%__Arch%" == "arm64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)
+ if /i "%__Arch%" == "x86" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A Win32)
+ ) else (
+ set __CmakeGenerator=NMake Makefiles
+ )
+)
+
+if /i "%__Arch%" == "wasm" (
+
+ if "%EMSDK_PATH%" == "" (
+ if not exist "%__repoRoot%src\mono\wasm\emsdk" (
+ echo Error: Should set EMSDK_PATH environment variable pointing to emsdk root.
+ exit /B 1
+ )
+
+ set EMSDK_PATH=%__repoRoot%src\mono\wasm\emsdk
+ set EMSDK_PATH=!EMSDK_PATH:\=/!
+ )
+
+ set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_TOOLCHAIN_FILE=!EMSDK_PATH!/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
+ set __UseEmcmake=1
+) else (
+ set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_SYSTEM_VERSION=10.0"
+)
+
+:loop
+if [%5] == [] goto end_loop
+set __ExtraCmakeParams=%__ExtraCmakeParams% %5
+shift
+goto loop
+:end_loop
+
+set __ExtraCmakeParams="-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DCLR_CMAKE_HOST_ARCH=%__Arch%" %__ExtraCmakeParams%
+
+set __CmdLineOptionsUpToDateFile=%__IntermediatesDir%\cmake_cmd_line.txt
+set __CMakeCmdLineCache=
+if not "%__ConfigureOnly%" == "1" (
+ REM MSBuild can't reload from a CMake reconfigure during build correctly, so only do this
+ REM command-line up to date check for non-VS generators.
+ if "%__CmakeGenerator:Visual Studio=%" == "%__CmakeGenerator%" (
+ if exist "%__CmdLineOptionsUpToDateFile%" (
+ set /p __CMakeCmdLineCache=<"%__CmdLineOptionsUpToDateFile%"
+ REM Strip the extra space from the end of the cached command line
+ if "!__ExtraCmakeParams!" == "!__CMakeCmdLineCache:~0,-1!" (
+ echo The CMake command line is the same as the last run. Skipping running CMake.
+ exit /B 0
+ ) else (
+ echo The CMake command line differs from the last run. Running CMake again.
+ echo %__ExtraCmakeParams% > %__CmdLineOptionsUpToDateFile%
+ )
+ ) else (
+ echo %__ExtraCmakeParams% > %__CmdLineOptionsUpToDateFile%
+ )
+ )
+)
+
+if /i "%__UseEmcmake%" == "1" (
+ call "!EMSDK_PATH!/emsdk_env.bat" > nul 2>&1 && emcmake "%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
+) else (
+ "%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
+)
+endlocal
+exit /B %errorlevel%
+
+:USAGE
+ echo "Usage..."
+ echo "gen-buildsys.cmd <path to top level CMakeLists.txt> <path to location for intermediate files> <VSVersion> <arch>"
+ echo "Specify the path to the top level CMake file - <ProjectK>/src/NDP"
+ echo "Specify the VSVersion to be used - VS2017 or VS2019"
+ EXIT /B 1
--- /dev/null
+#!/usr/bin/env bash
+#
+# This file invokes cmake and generates the build system for Clang.
+#
+
+scriptroot="$( cd -P "$( dirname "$0" )" && pwd )"
+
+if [[ "$#" -lt 4 ]]; then
+ echo "Usage..."
+ echo "gen-buildsys.sh <path to top level CMakeLists.txt> <path to intermediate directory> <Architecture> <compiler> <compiler major version> <compiler minor version> [build flavor] [ninja] [scan-build] [cmakeargs]"
+ echo "Specify the path to the top level CMake file."
+ echo "Specify the path that the build system files are generated in."
+ echo "Specify the target architecture."
+ echo "Specify the name of compiler (clang or gcc)."
+ echo "Specify the major version of compiler."
+ echo "Specify the minor version of compiler."
+ echo "Optionally specify the build configuration (flavor.) Defaults to DEBUG."
+ echo "Optionally specify 'scan-build' to enable build with clang static analyzer."
+ echo "Use the Ninja generator instead of the Unix Makefiles generator."
+ echo "Pass additional arguments to CMake call."
+ exit 1
+fi
+
+build_arch="$3"
+compiler="$4"
+majorVersion="$5"
+minorVersion="$6"
+
+if [[ "$compiler" != "default" ]]; then
+ nativescriptroot="$( cd -P "$scriptroot/../common/native" && pwd )"
+ source "$nativescriptroot/init-compiler.sh" "$nativescriptroot" "$build_arch" "$compiler" "$majorVersion" "$minorVersion"
+
+ CCC_CC="$CC"
+ CCC_CXX="$CXX"
+fi
+
+export CCC_CC CCC_CXX
+
+buildtype=DEBUG
+code_coverage=OFF
+build_tests=OFF
+scan_build=OFF
+generator="Unix Makefiles"
+__UnprocessedCMakeArgs=""
+
+for i in "${@:7}"; do
+ upperI="$(echo "$i" | tr "[:lower:]" "[:upper:]")"
+ case "$upperI" in
+ # Possible build types are DEBUG, CHECKED, RELEASE, RELWITHDEBINFO.
+ DEBUG | CHECKED | RELEASE | RELWITHDEBINFO)
+ buildtype="$upperI"
+ ;;
+ NINJA)
+ generator=Ninja
+ ;;
+ SCAN-BUILD)
+ echo "Static analysis is turned on for this build."
+ scan_build=ON
+ ;;
+ *)
+ __UnprocessedCMakeArgs="${__UnprocessedCMakeArgs}${__UnprocessedCMakeArgs:+ }$i"
+ esac
+done
+
+cmake_extra_defines=
+if [[ "$CROSSCOMPILE" == "1" ]]; then
+ platform="$(uname)"
+ # OSX doesn't use rootfs
+ if ! [[ -n "$ROOTFS_DIR" || "$platform" == "Darwin" ]]; then
+ echo "ROOTFS_DIR not set for crosscompile"
+ exit 1
+ fi
+
+ TARGET_BUILD_ARCH="$build_arch"
+ export TARGET_BUILD_ARCH
+
+ cmake_extra_defines="$cmake_extra_defines -C $scriptroot/tryrun.cmake"
+
+ if [[ "$platform" == "Darwin" ]]; then
+ cmake_extra_defines="$cmake_extra_defines -DCMAKE_SYSTEM_NAME=Darwin"
+ else
+ cmake_extra_defines="$cmake_extra_defines -DCMAKE_TOOLCHAIN_FILE=$scriptroot/../common/cross/toolchain.cmake"
+ fi
+fi
+
+if [[ "$build_arch" == "armel" ]]; then
+ cmake_extra_defines="$cmake_extra_defines -DARM_SOFTFP=1"
+fi
+
+if ! cmake_command=$(command -v cmake); then
+ echo "CMake was not found in PATH."
+ exit 1
+fi
+
+if [[ "$scan_build" == "ON" && -n "$SCAN_BUILD_COMMAND" ]]; then
+ cmake_command="$SCAN_BUILD_COMMAND $cmake_command"
+fi
+
+if [[ "$build_arch" == "wasm" ]]; then
+ cmake_command="emcmake $cmake_command"
+fi
+
+cmake_args_to_cache="$scan_build\n$SCAN_BUILD_COMMAND\n$generator\n$__UnprocessedCMakeArgs"
+cmake_args_cache_file="$2/cmake_cmd_line.txt"
+if [[ -z "$__ConfigureOnly" ]]; then
+ if [[ -e "$cmake_args_cache_file" ]]; then
+ cmake_args_cache=$(<"$cmake_args_cache_file")
+ if [[ "$cmake_args_cache" == "$cmake_args_to_cache" ]]; then
+ echo "CMake command line is unchanged. Reusing previous cache instead of regenerating."
+ exit 0
+ fi
+ fi
+ echo $cmake_args_to_cache > $cmake_args_cache_file
+fi
+
+# We have to be able to build with CMake 3.6.2, so we can't use the -S or -B options
+pushd "$2"
+
+$cmake_command \
+ --no-warn-unused-cli \
+ -G "$generator" \
+ "-DCMAKE_BUILD_TYPE=$buildtype" \
+ "-DCMAKE_INSTALL_PREFIX=$__CMakeBinDir" \
+ $cmake_extra_defines \
+ $__UnprocessedCMakeArgs \
+ "$1"
+
+popd
--- /dev/null
+#!/usr/bin/env bash
+
+saved=("$@")
+while test $# -gt 0; do
+ case "$1" in
+ --help|-h)
+ printf "Usage:\ngenerateexportedsymbols.sh <filename>\n"
+ exit 1;;
+ esac
+ shift
+done
+set -- "${saved[@]}"
+
+while read -r line; do
+ # Skip empty lines and comment lines starting with semicolon
+ if [[ "$line" =~ ^\;.*$|^[[:space:]]*$ ]]; then
+ continue
+ fi
+
+ # Remove the CR character in case the sources are mapped from
+ # a Windows share and contain CRLF line endings
+ line="${line//$'\r'/}"
+
+ printf "_%s\n" "${line//#/}"
+done < "$1"
--- /dev/null
+#!/usr/bin/env bash
+
+saved=("$@")
+while test $# -gt 0; do
+ case "$1" in
+ --help|-h)
+ printf "Usage:\ngenerateversionscript.sh <filename> <prefix>\n"
+ exit 1;;
+ esac
+ shift
+done
+set -- "${saved[@]}"
+
+prefix="$2"
+
+printf "V1.0 {\n global:\n"
+
+while read -r line; do
+ # Skip empty lines and comment lines starting with semicolon
+ if [[ "$line" =~ ^\;.*$|^[[:space:]]*$ ]]; then
+ continue
+ fi
+
+ # Remove the CR character in case the sources are mapped from
+ # a Windows share and contain CRLF line endings
+ line="${line//$'\r'/}"
+
+ # Only prefix the entries that start with "#"
+ if [[ "$line" =~ ^#.*$ ]]; then
+ printf " %s%s;\n" "$prefix" "${line//#/}"
+ else
+ printf " %s;\n" "$line"
+ fi
+done < "$1"
+
+printf " local: *;\n};\n"
--- /dev/null
+@echo off
+REM Generate module index header
+
+if [%1]==[] goto :Usage
+if [%2]==[] goto :Usage
+
+setlocal
+for /f "tokens=1" %%i in ('dumpbin /HEADERS %1 ^| findstr /c:"size of image"') do set imagesize=%%i
+REM Pad the extracted size to 8 hex digits
+set imagesize=00000000%imagesize%
+set imagesize=%imagesize:~-8%
+
+for /f "tokens=1" %%i in ('dumpbin /HEADERS %1 ^| findstr /c:"time date"') do set timestamp=%%i
+REM Pad the extracted time stamp to 8 hex digits
+set timestamp=00000000%timestamp%
+set timestamp=%timestamp:~-8%
+
+echo 0x08, 0x%timestamp:~6,2%, 0x%timestamp:~4,2%, 0x%timestamp:~2,2%, 0x%timestamp:~0,2%, 0x%imagesize:~6,2%, 0x%imagesize:~4,2%, 0x%imagesize:~2,2%, 0x%imagesize:~0,2%, > %2
+
+endlocal
+exit /b 0
+
+:Usage
+echo Usage: genmoduleindex.cmd ModuleBinaryFile IndexHeaderFile
+exit /b 1
--- /dev/null
+#!/usr/bin/env bash
+#
+# Generate module index header
+#
+set -euo pipefail
+
+if [[ "$#" -lt 2 ]]; then
+ echo "Usage: genmoduleindex.sh ModuleBinaryFile IndexHeaderFile"
+ exit 1
+fi
+
+function printIdAsBinary() {
+ id="$1"
+
+ # Print length in bytes
+ bytesLength="${#id}"
+ printf "0x%02x, " "$((bytesLength/2))"
+
+ # Print each pair of hex digits with 0x prefix followed by a comma
+ while [[ "$id" ]]; do
+ printf '0x%s, ' "${id:0:2}"
+ id=${id:2}
+ done
+}
+
+case "$(uname -s)" in
+Darwin)
+ cmd="dwarfdump -u $1"
+ pattern='^UUID: ([0-9A-Fa-f\-]+)';;
+*)
+ cmd="readelf -n $1"
+ pattern='^[[:space:]]*Build ID: ([0-9A-Fa-f\-]+)';;
+esac
+
+while read -r line; do
+ if [[ "$line" =~ $pattern ]]; then
+ printIdAsBinary "${BASH_REMATCH[1]//-/}"
+ break
+ fi
+done < <(eval "$cmd") > "$2"
--- /dev/null
+#!/usr/bin/env bash
+
+# initNonPortableDistroRid
+#
+# Input:
+# targetOs: (str)
+# buildArch: (str)
+# isPortable: (int)
+# rootfsDir: (str)
+#
+# Return:
+# None
+#
+# Notes:
+#
+# initNonPortableDistroRid will attempt to initialize a non portable rid. These
+# rids are specific to distros need to build the product/package and consume
+# them on the same platform.
+#
+# If -portablebuild=false is passed a non-portable rid will be created for any
+# distro.
+#
+# It is important to note that the function does not return anything, but it
+# exports __DistroRid, if there is a non-portable distro rid to be used.
+#
+initNonPortableDistroRid()
+{
+ # Make sure out parameter is cleared.
+ __DistroRid=
+
+ local targetOs="$1"
+ local buildArch="$2"
+ local isPortable="$3"
+ local rootfsDir="$4"
+ local nonPortableBuildID=""
+
+ if [ "$targetOs" = "Linux" ]; then
+ if [ -e "${rootfsDir}/etc/os-release" ]; then
+ source "${rootfsDir}/etc/os-release"
+
+ # We have forced __PortableBuild=0. This is because -portablebuld
+ # has been passed as false.
+ if (( isPortable == 0 )); then
+ if [ "${ID}" = "rhel" ] || [ "${ID}" = "rocky" ]; then
+ # remove the last version digit
+ VERSION_ID="${VERSION_ID%.*}"
+ fi
+
+ if [ -z "${VERSION_ID+x}" ]; then
+ # Rolling release distros do not set VERSION_ID, so omit
+ # it here to be consistent with everything else.
+ nonPortableBuildID="${ID}-${buildArch}"
+ else
+ nonPortableBuildID="${ID}.${VERSION_ID}-${buildArch}"
+ fi
+ fi
+
+ elif [ -e "${rootfsDir}/android_platform" ]; then
+ source "$rootfsDir"/android_platform
+ nonPortableBuildID="$RID"
+ fi
+ fi
+
+ if [ "$targetOs" = "FreeBSD" ]; then
+ if (( isPortable == 0 )); then
+ # $rootfsDir can be empty. freebsd-version is shell script and it should always work.
+ __freebsd_major_version=$($rootfsDir/bin/freebsd-version | { read v; echo "${v%%.*}"; })
+ nonPortableBuildID="freebsd.$__freebsd_major_version-${buildArch}"
+ fi
+ elif command -v getprop && getprop ro.product.system.model 2>&1 | grep -qi android; then
+ __android_sdk_version=$(getprop ro.build.version.sdk)
+ nonPortableBuildID="android.$__android_sdk_version-${buildArch}"
+ elif [ "$targetOs" = "illumos" ]; then
+ __uname_version=$(uname -v)
+ case "$__uname_version" in
+ omnios-*)
+ __omnios_major_version=$(echo "${__uname_version:8:2}")
+ nonPortableBuildID=omnios."$__omnios_major_version"-"$buildArch"
+ ;;
+ joyent_*)
+ __smartos_major_version=$(echo "${__uname_version:7:4}")
+ nonPortableBuildID=smartos."$__smartos_major_version"-"$buildArch"
+ ;;
+ illumos_*)
+ nonPortableBuildID=openindiana-"$buildArch"
+ ;;
+ esac
+ elif [ "$targetOs" = "Solaris" ]; then
+ __uname_version=$(uname -v)
+ __solaris_major_version=$(echo "${__uname_version%.*}")
+ nonPortableBuildID=solaris."$__solaris_major_version"-"$buildArch"
+ fi
+
+ if [ -n "${nonPortableBuildID}" ]; then
+ __DistroRid="${nonPortableBuildID}"
+
+ # We are using a non-portable build rid. Force __PortableBuild to false.
+ __PortableBuild=0
+
+ export __DistroRid __PortableBuild
+ fi
+}
+
+# initDistroRidGlobal
+#
+# Input:
+# os: (str)
+# arch: (str)
+# isPortable: (int)
+# rootfsDir?: (nullable:string)
+#
+# Return:
+# None
+#
+# Notes:
+#
+# It is important to note that the function does not return anything, but it
+# exports the following variables on success:
+#
+# __DistroRid
+# __PortableBuild
+#
+initDistroRidGlobal()
+{
+ # __DistroRid must be set at the end of the function.
+ # Previously we would create a variable __HostDistroRid and/or __DistroRid.
+ #
+ # __HostDistroRid was used in the case of a non-portable build, it has been
+ # deprecated. Now only __DistroRid is supported. It will be used for both
+ # portable and non-portable rids and will be used in build-packages.sh
+
+ local targetOs="$1"
+ local buildArch="$2"
+ local isPortable="$3"
+ local rootfsDir=""
+ if [ "$#" -ge 4 ]; then
+ rootfsDir="$4"
+ fi
+
+ if [ -n "${rootfsDir}" ]; then
+ # We may have a cross build. Check for the existance of the rootfsDir
+ if [ ! -e "${rootfsDir}" ]; then
+ echo "Error rootfsDir has been passed, but the location is not valid."
+ exit 1
+ fi
+ fi
+
+ initNonPortableDistroRid "${targetOs}" "${buildArch}" "${isPortable}" "${rootfsDir}"
+
+ if [ "$buildArch" = "wasm" ]; then
+ __DistroRid=browser-wasm
+ export __DistroRid
+ fi
+
+ if [ -z "${__DistroRid}" ]; then
+ # The non-portable build rid was not set. Set the portable rid.
+
+ __PortableBuild=1
+ export __PortableBuild
+ local distroRid=""
+
+ # Check for musl-based distros (e.g Alpine Linux, Void Linux).
+ if "${rootfsDir}/usr/bin/ldd" --version 2>&1 | grep -q musl ||
+ strings "${rootfsDir}/usr/bin/ldd" 2>&1 | grep -q musl; then
+ distroRid="linux-musl-${buildArch}"
+ fi
+
+ if [ -z "${distroRid}" ]; then
+ if [ "$targetOs" = "Linux" ]; then
+ distroRid="linux-$buildArch"
+ elif [ "$targetOs" = "OSX" ]; then
+ distroRid="osx-$buildArch"
+ elif [ "$targetOs" = "MacCatalyst" ]; then
+ distroRid="maccatalyst-$buildArch"
+ elif [ "$targetOs" = "tvOS" ]; then
+ distroRid="tvos-$buildArch"
+ elif [ "$targetOs" = "tvOSSimulator" ]; then
+ distroRid="tvossimulator-$buildArch"
+ elif [ "$targetOs" = "iOS" ]; then
+ distroRid="ios-$buildArch"
+ elif [ "$targetOs" = "iOSSimulator" ]; then
+ distroRid="iossimulator-$buildArch"
+ elif [ "$targetOs" = "Android" ]; then
+ distroRid="android-$buildArch"
+ elif [ "$targetOs" = "Browser" ]; then
+ distroRid="browser-$buildArch"
+ elif [ "$targetOs" = "FreeBSD" ]; then
+ distroRid="freebsd-$buildArch"
+ elif [ "$targetOs" = "illumos" ]; then
+ distroRid="illumos-$buildArch"
+ elif [ "$targetOs" = "Solaris" ]; then
+ distroRid="solaris-$buildArch"
+ fi
+ fi
+
+ __DistroRid="${distroRid}"
+ export __DistroRid
+ fi
+
+ if [ -z "$__DistroRid" ]; then
+ echo "DistroRid is not set. This is almost certainly an error"
+ exit 1
+ fi
+
+ echo "__DistroRid: ${__DistroRid}"
+}
--- /dev/null
+#!/usr/bin/env bash
+
+# Use uname to determine what the OS is.
+OSName=$(uname -s)
+
+if command -v getprop && getprop ro.product.system.model 2>&1 | grep -qi android; then
+ OSName="Android"
+fi
+
+case "$OSName" in
+FreeBSD|Linux|NetBSD|OpenBSD|SunOS|Android)
+ os="$OSName" ;;
+Darwin)
+ os=OSX ;;
+*)
+ echo "Unsupported OS $OSName detected, configuring as if for Linux"
+ os=Linux ;;
+esac
+
+# On Solaris, `uname -m` is discouraged, see https://docs.oracle.com/cd/E36784_01/html/E36870/uname-1.html
+# and `uname -p` returns processor type (e.g. i386 on amd64).
+# The appropriate tool to determine CPU is isainfo(1) https://docs.oracle.com/cd/E36784_01/html/E36870/isainfo-1.html.
+if [ "$os" = "SunOS" ]; then
+ if uname -o 2>&1 | grep -q illumos; then
+ os="illumos"
+ else
+ os="Solaris"
+ fi
+ CPUName=$(isainfo -n)
+else
+ # For the rest of the operating systems, use uname(1) to determine what the CPU is.
+ CPUName=$(uname -m)
+fi
+
+case "$CPUName" in
+ arm64|aarch64)
+ arch=arm64
+ ;;
+
+ amd64|x86_64)
+ arch=x64
+ ;;
+
+ armv7l)
+ if (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then
+ arch=armel
+ else
+ arch=arm
+ fi
+ ;;
+
+ i[3-6]86)
+ echo "Unsupported CPU $CPUName detected, build might not succeed!"
+ arch=x86
+ ;;
+
+ s390x)
+ arch=s390x
+ ;;
+
+ *)
+ echo "Unknown CPU $CPUName detected, configuring as if for x64"
+ arch=x64
+ ;;
+esac
--- /dev/null
+@if not defined _echo @echo off
+
+:: Initializes Visual Studio developer environment. If a build architecture is passed
+:: as an argument, it also initializes VC++ build environment and CMakePath.
+
+set "__VCBuildArch="
+if /i "%~1" == "x86" (set __VCBuildArch=x86)
+if /i "%~1" == "x64" (set __VCBuildArch=x86_amd64)
+if /i "%~1" == "arm" (set __VCBuildArch=x86_arm)
+if /i "%~1" == "arm64" (set __VCBuildArch=x86_arm64)
+if /i "%~1" == "wasm" (set __VCBuildArch=x86_amd64)
+
+:: Default to highest Visual Studio version available that has Visual C++ tools.
+::
+:: For VS2017 and later, multiple instances can be installed on the same box SxS and VS1*0COMNTOOLS
+:: is no longer set as a global environment variable and is instead only set if the user
+:: has launched the Visual Studio Developer Command Prompt.
+::
+:: Following this logic, we will default to the Visual Studio toolset assocated with the active
+:: Developer Command Prompt. Otherwise, we will query VSWhere to locate the later version of
+:: Visual Studio available on the machine. Finally, we will fail the script if no supported
+:: instance can be found.
+
+if defined VisualStudioVersion goto :VSDetected
+
+set "__VSWhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
+set "__VSCOMNTOOLS="
+
+if exist "%__VSWhere%" (
+ for /f "tokens=*" %%p in (
+ '"%__VSWhere%" -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath'
+ ) do set __VSCOMNTOOLS=%%p\Common7\Tools
+)
+
+if not exist "%__VSCOMNTOOLS%" goto :VSMissing
+
+:: Make sure the current directory stays intact
+set "VSCMD_START_DIR=%CD%"
+
+call "%__VSCOMNTOOLS%\VsDevCmd.bat" -no_logo
+
+:: Clean up helper variables
+set "__VSWhere="
+set "__VSCOMNTOOLS="
+set "VSCMD_START_DIR="
+
+:VSDetected
+if "%VisualStudioVersion%"=="16.0" (
+ set __VSVersion=vs2019
+ set __PlatformToolset=v142
+ goto :SetVCEnvironment
+)
+if "%VisualStudioVersion%"=="17.0" (
+ set __VSVersion=vs2022
+ set __PlatformToolset=v142
+ goto :SetVCEnvironment
+)
+
+:VSMissing
+echo %__MsgPrefix%Error: Visual Studio 2019 or 2022 with C++ tools required. ^
+Please see https://github.com/dotnet/runtime/blob/main/docs/workflow/requirements/windows-requirements.md for build requirements.
+exit /b 1
+
+:SetVCEnvironment
+
+if "%__VCBuildArch%"=="" exit /b 0
+
+:: Set the environment for the native build
+call "%VCINSTALLDIR%Auxiliary\Build\vcvarsall.bat" %__VCBuildArch%
+if not "%ErrorLevel%"=="0" exit /b 1
+
+set "__VCBuildArch="
+
+:: Set CMakePath by evaluating the output from set-cmake-path.ps1.
+:: In case of a failure the output is "exit /b 1".
+for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass -File "%~dp0set-cmake-path.ps1"') do %%a
--- /dev/null
+<Project>
+ <PropertyGroup>
+ <StaticLibPrefix>lib</StaticLibPrefix>
+ </PropertyGroup>
+
+ <!-- Add path globs specific to native binaries to exclude unnecessary files from packages. -->
+ <Choose>
+ <When Condition="$(PackageRID.StartsWith('win'))">
+ <PropertyGroup>
+ <ExeSuffix>.exe</ExeSuffix>
+ <LibSuffix>.dll</LibSuffix>
+ <StaticLibSuffix>.lib</StaticLibSuffix>
+ <SymbolsSuffix>.pdb</SymbolsSuffix>
+ </PropertyGroup>
+ </When>
+ <When Condition="$(PackageRID.StartsWith('osx'))">
+ <PropertyGroup>
+ <LibPrefix Condition=" '$(SkipLibraryPrefixFromUnix)' == '' ">lib</LibPrefix>
+ <LibSuffix>.dylib</LibSuffix>
+ <StaticLibSuffix>.a</StaticLibSuffix>
+ <SymbolsSuffix>.dwarf</SymbolsSuffix>
+ </PropertyGroup>
+ </When>
+ <When Condition="$(PackageRID.StartsWith('android'))">
+ <PropertyGroup>
+ <LibPrefix Condition=" '$(SkipLibraryPrefixFromUnix)' == '' ">lib</LibPrefix>
+ <LibSuffix>.so</LibSuffix>
+ <StaticLibSuffix>.a</StaticLibSuffix>
+ <!--symbols included in .so, like Linux, but can be generated externally and if so, uses .debug ext-->
+ <SymbolsSuffix>.debug</SymbolsSuffix>
+ </PropertyGroup>
+ </When>
+ <Otherwise>
+ <PropertyGroup>
+ <LibPrefix Condition=" '$(SkipLibraryPrefixFromUnix)' == '' ">lib</LibPrefix>
+ <LibSuffix>.so</LibSuffix>
+ <StaticLibSuffix>.a</StaticLibSuffix>
+ <SymbolsSuffix>.dbg</SymbolsSuffix>
+ </PropertyGroup>
+ </Otherwise>
+ </Choose>
+
+ <ItemGroup>
+ <AdditionalLibPackageExcludes Condition="'$(SymbolsSuffix)' != ''" Include="%2A%2A\%2A$(SymbolsSuffix)" />
+ <AdditionalSymbolPackageExcludes Condition="'$(LibSuffix)' != ''" Include="%2A%2A\%2A.a;%2A%2A\%2A$(LibSuffix)" />
+ </ItemGroup>
+
+ <!-- arcade is using long name for this property; 'SymbolFileExtension'.
+ remove this property group when arcade is updated with short name (SymbolsSuffix). -->
+ <PropertyGroup>
+ <SymbolFileExtension>$(SymbolsSuffix)</SymbolFileExtension>
+ </PropertyGroup>
+
+</Project>
--- /dev/null
+# Output the toolchain information required to create a command line that builds with the right rootfs as XML
+
+set (ADDED_COMPILE_OPTIONS)
+if (CMAKE_SCRIPT_MODE_FILE)
+ # add_compile_options and add_definitions can't be used in scripts,
+ # so override the implementations to append to a local property
+ macro(add_compile_options)
+ list(APPEND ADDED_COMPILE_OPTIONS ${ARGV})
+ endmacro()
+ macro(add_definitions)
+ list(APPEND ADDED_COMPILE_OPTIONS ${ARGV})
+ endmacro()
+endif()
+
+include(${CMAKE_CURRENT_LIST_DIR}/../common/cross/toolchain.cmake)
+
+message("<toolchain-info>")
+message("<target-triple>${TOOLCHAIN}</target-triple>")
+message("<linker-args>${CMAKE_SHARED_LINKER_FLAGS_INIT}</linker-args>")
+message("<compiler-args>${ADDED_COMPILE_OPTIONS}</compiler-args>")
+message("</toolchain-info>")
\ No newline at end of file
--- /dev/null
+# This file has exclusions to the Clang address sanitizer to suppress error reports
+# When Clang 3.8 is available, convert these to suppression list instead as that is preferred for internal code
+
+# CMiniMdBase::UsesAllocatedMemory - suppress stack-buffer-underflow (code backs up pointer by -1 to check allocation ownership)
+fun:_ZN11CMiniMdBase19UsesAllocatedMemoryEP11CMiniColDef
+
+# JIT_InitPInvokeFrame - suppress unknown sanitizer issue causing SEGV on unknown address 0x000000000000
+# 0 0x4e8a0c in __ubsan::checkDynamicType(void*, void*, unsigned long)
+# 1 0x4e807f in HandleDynamicTypeCacheMiss(__ubsan::DynamicTypeCacheMissData*, unsigned long, unsigned long, __ubsan::ReportOptions)
+# 2 0x4e8051 in __ubsan_handle_dynamic_type_cache_miss
+# 3 0x7f02ce676cd8 in JIT_InitPInvokeFrame(InlinedCallFrame*, void*) /home/steveharter/git/dotnet_coreclr/vm/jithelpers.cpp:6491:9
+# 4 0x7f0252bbceb2 (<unknown module>)
+fun:_Z20JIT_InitPInvokeFrameP16InlinedCallFramePv
+
--- /dev/null
+# This script locates the CMake executable for the build system and outputs either the "set CMakePath=..."
+# command (if CMake is found) or the "exit /b 1" command (if not found) for evaluating from batch files.
+
+Set-StrictMode -Version 3
+
+function LocateCMake {
+ # Find the first cmake.exe on the PATH
+ $cmakeApp = (Get-Command cmake.exe -ErrorAction SilentlyContinue)
+ if ($cmakeApp -ne $null) {
+ return $cmakeApp.Path
+ }
+
+ # Find cmake.exe using the registry
+ $cmakeRegKey = Get-ItemProperty HKLM:\SOFTWARE\Kitware\CMake -Name InstallDir -ErrorAction SilentlyContinue
+ if ($cmakeRegKey -eq $null) {
+ $cmakeRegKey = Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Kitware\CMake -Name InstallDir -ErrorAction SilentlyContinue
+ }
+
+ if ($cmakeRegKey -ne $null) {
+ $cmakePath = $cmakeRegKey.InstallDir + "bin\cmake.exe"
+ if (Test-Path $cmakePath -PathType Leaf) {
+ return $cmakePath
+ }
+ }
+
+ return $null
+}
+
+try {
+ $cmakePath = LocateCMake
+
+ if ($cmakePath -eq $null) {
+ throw "CMake is a pre-requisite to build this repository but it was not found on the PATH or in the registry. Please install CMake from https://cmake.org/download/."
+ }
+
+ $version = [Version]$(& $cmakePath --version | Select-String -Pattern '\d+\.\d+\.\d+' | %{$_.Matches.Value})
+
+ if ($version -lt [Version]"3.16.4") {
+ throw "CMake 3.16.4 or newer is required for building this repository. The newest version of CMake installed is $version. Please install CMake 3.16.4 or newer from https://cmake.org/download/."
+ }
+
+ [System.Console]::WriteLine("set CMakePath=" + $cmakePath)
+
+}
+catch {
+ [System.Console]::Error.WriteLine($_.Exception.Message)
+ [System.Console]::WriteLine("exit /b 1")
+}
--- /dev/null
+set(CROSS_ROOTFS $ENV{ROOTFS_DIR})
+set(TARGET_ARCH_NAME $ENV{TARGET_BUILD_ARCH})
+
+macro(set_cache_value)
+ set(${ARGV0} ${ARGV1} CACHE STRING "Result from TRY_RUN" FORCE)
+ set(${ARGV0}__TRYRUN_OUTPUT "dummy output" CACHE STRING "Output from TRY_RUN" FORCE)
+endmacro()
+
+if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv7-alpine-linux-musleabihf OR
+ EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR
+ EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl)
+
+ set(ALPINE_LINUX 1)
+elseif(EXISTS ${CROSS_ROOTFS}/bin/freebsd-version)
+ set(FREEBSD 1)
+ set(CMAKE_SYSTEM_NAME FreeBSD)
+ set(CLR_CMAKE_TARGET_OS FreeBSD)
+elseif(EXISTS ${CROSS_ROOTFS}/usr/platform/i86pc)
+ set(ILLUMOS 1)
+ set(CLR_CMAKE_TARGET_OS SunOS)
+elseif(EXISTS /System/Library/CoreServices)
+ set(DARWIN 1)
+endif()
+
+if(DARWIN)
+ if(TARGET_ARCH_NAME MATCHES "^(arm64|x64)$")
+ set_cache_value(FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL_EXITCODE 1)
+ set_cache_value(GETPWUID_R_SETS_ERRNO_EXITCODE 1)
+ set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 1)
+ set_cache_value(HAVE_BROKEN_FIFO_KEVENT_EXITCODE 1)
+ set_cache_value(HAVE_BROKEN_FIFO_SELECT_EXITCODE 1)
+ set_cache_value(HAVE_CLOCK_MONOTONIC_COARSE_EXITCODE 1)
+ set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0)
+ set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0)
+ set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0)
+ set_cache_value(HAVE_CLOCK_GETTIME_NSEC_NP_EXITCODE 0)
+ set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0)
+ set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0)
+ set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 0)
+ set_cache_value(HAVE_COMPATIBLE_EXP_EXITCODE 1)
+ set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 0)
+ set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 1)
+ set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0)
+ set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0)
+ set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0)
+ set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 1)
+ set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 0)
+ set_cache_value(HAVE_MMAP_DEV_ZERO_EXITCODE 1)
+ set_cache_value(HAVE_PROCFS_CTL_EXITCODE 1)
+ set_cache_value(HAVE_PROCFS_MAPS_EXITCODE 1)
+ set_cache_value(HAVE_PROCFS_STATUS_EXITCODE 1)
+ set_cache_value(HAVE_PROCFS_STAT_EXITCODE 1)
+ set_cache_value(HAVE_SCHED_GETCPU_EXITCODE 1)
+ set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0)
+ set_cache_value(HAVE_VALID_NEGATIVE_INF_POW_EXITCODE 0)
+ set_cache_value(HAVE_VALID_POSITIVE_INF_POW_EXITCODE 0)
+ set_cache_value(HAVE_WORKING_CLOCK_GETTIME_EXITCODE 0)
+ set_cache_value(HAVE_WORKING_GETTIMEOFDAY_EXITCODE 0)
+ set_cache_value(MMAP_ANON_IGNORES_PROTECTION_EXITCODE 1)
+ set_cache_value(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS_EXITCODE 1)
+ set_cache_value(PTHREAD_CREATE_MODIFIES_ERRNO_EXITCODE 1)
+ set_cache_value(REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 1)
+ set_cache_value(SEM_INIT_MODIFIES_ERRNO_EXITCODE 1)
+ set_cache_value(SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 1)
+ set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 0)
+ set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 1)
+ set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 0)
+ else()
+ message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm64 or x64 is supported for OSX cross build!")
+ endif()
+elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|s390x|x86)$" OR FREEBSD OR ILLUMOS)
+ set_cache_value(FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL_EXITCODE 1)
+ set_cache_value(GETPWUID_R_SETS_ERRNO_EXITCODE 0)
+ set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 0)
+ set_cache_value(HAVE_CLOCK_MONOTONIC_COARSE_EXITCODE 0)
+ set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0)
+ set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0)
+ set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0)
+ set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0)
+ set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0)
+ set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 0)
+ set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 1)
+ set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 1)
+ set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0)
+ set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0)
+ set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0)
+ set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 0)
+ set_cache_value(HAVE_MMAP_DEV_ZERO_EXITCODE 0)
+ set_cache_value(HAVE_PROCFS_CTL_EXITCODE 1)
+ set_cache_value(HAVE_PROCFS_MAPS_EXITCODE 0)
+ set_cache_value(HAVE_PROCFS_STATUS_EXITCODE 0)
+ set_cache_value(HAVE_PROCFS_STAT_EXITCODE 0)
+ set_cache_value(HAVE_SCHED_GETCPU_EXITCODE 0)
+ set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0)
+ set_cache_value(HAVE_VALID_NEGATIVE_INF_POW_EXITCODE 0)
+ set_cache_value(HAVE_VALID_POSITIVE_INF_POW_EXITCODE 0)
+ set_cache_value(HAVE_WORKING_CLOCK_GETTIME_EXITCODE 0)
+ set_cache_value(HAVE_WORKING_GETTIMEOFDAY_EXITCODE 0)
+ set_cache_value(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS_EXITCODE 1)
+ set_cache_value(PTHREAD_CREATE_MODIFIES_ERRNO_EXITCODE 1)
+ set_cache_value(REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 1)
+ set_cache_value(SEM_INIT_MODIFIES_ERRNO_EXITCODE 1)
+
+
+ if(ALPINE_LINUX)
+ set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 1)
+ set_cache_value(SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 0)
+ set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 1)
+ set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 1)
+ else()
+ set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 0)
+ set_cache_value(SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 1)
+ set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 0)
+ set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 0)
+ endif()
+
+ if (FREEBSD)
+ set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP 1)
+ set_cache_value(HAVE_CLOCK_MONOTONIC 1)
+ set_cache_value(HAVE_CLOCK_REALTIME 1)
+ set_cache_value(HAVE_BROKEN_FIFO_KEVENT_EXITCODE 1)
+ set_cache_value(HAVE_PROCFS_MAPS 0)
+ set_cache_value(HAVE_PROCFS_STAT 0)
+ set_cache_value(HAVE_PROCFS_STATUS_EXITCODE 1)
+ set_cache_value(GETPWUID_R_SETS_ERRNO 0)
+ set_cache_value(UNGETC_NOT_RETURN_EOF 0)
+ set_cache_value(HAVE_COMPATIBLE_ILOGBNAN 1)
+ set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0)
+ elseif(ILLUMOS)
+ set_cache_value(GETPWUID_R_SETS_ERRNO_EXITCODE 1)
+ set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 1)
+ set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 1)
+ set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 1)
+ set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 1)
+ set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 0)
+ set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 1)
+ set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 1)
+ set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 1)
+ set_cache_value(HAVE_PROCFS_CTL_EXITCODE 0)
+ set_cache_value(SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 1)
+ set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 1)
+ set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 0)
+ set_cache_value(COMPILER_SUPPORTS_W_CLASS_MEMACCESS 1)
+ set_cache_value(HAVE_SET_MAX_VARIABLE 1)
+ set_cache_value(HAVE_FULLY_FEATURED_PTHREAD_MUTEXES 1)
+ set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0)
+ endif()
+else()
+ message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, arm64, s390x and x86 are supported!")
+endif()
+
+if(TARGET_ARCH_NAME STREQUAL "x86" OR TARGET_ARCH_NAME STREQUAL "s390x")
+ set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0)
+endif()
--- /dev/null
+#include "_version.h"
+
+#include <windows.h>
+
+VS_VERSION_INFO VERSIONINFO
+FILEVERSION VER_FILEVERSION
+PRODUCTVERSION VER_PRODUCTVERSION
+FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+FILEFLAGS VER_DEBUG
+FILEOS VOS__WINDOWS32
+FILETYPE VFT_DLL
+FILESUBTYPE VFT2_UNKNOWN
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904E4"
+ BEGIN
+ VALUE "CompanyName", VER_COMPANYNAME_STR
+ VALUE "FileDescription", VER_FILEDESCRIPTION_STR
+ VALUE "FileVersion", VER_FILEVERSION_STR
+ VALUE "InternalName", VER_INTERNALNAME_STR
+ VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
+ VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
+ VALUE "ProductName", VER_PRODUCTNAME_STR
+ VALUE "ProductVersion", VER_PRODUCTVERSION_STR
+ END
+ END
+
+ BLOCK "VarFileInfo"
+ BEGIN
+ /* The following line should only be modified for localized versions. */
+ /* It consists of any number of WORD,WORD pairs, with each pair */
+ /* describing a language,codepage combination supported by the file. */
+ /* */
+ /* For example, a file might have values "0x409,1252" indicating that it */
+ /* supports English language (0x409) in the Windows ANSI codepage (1252). */
+
+ VALUE "Translation", 0x409, 1252
+
+ END
+END
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+static char sccsid[] __attribute__((used)) = "@(#)No version information produced";
--- /dev/null
+#ifndef VER_COMPANYNAME_STR
+#define VER_COMPANYNAME_STR ".NET Foundation"
+#endif
+#ifndef VER_FILEDESCRIPTION_STR
+#define VER_FILEDESCRIPTION_STR ".NET Runtime"
+#endif
+#ifndef VER_INTERNALNAME_STR
+#define VER_INTERNALNAME_STR VER_FILEDESCRIPTION_STR
+#endif
+#ifndef VER_ORIGINALFILENAME_STR
+#define VER_ORIGINALFILENAME_STR VER_FILEDESCRIPTION_STR
+#endif
+#ifndef VER_PRODUCTNAME_STR
+#define VER_PRODUCTNAME_STR ".NET"
+#endif
+#undef VER_PRODUCTVERSION
+#define VER_PRODUCTVERSION 00,00,00,00000
+#undef VER_PRODUCTVERSION_STR
+#define VER_PRODUCTVERSION_STR "0.0.0"
+#undef VER_FILEVERSION
+#define VER_FILEVERSION 00,00,00,00000
+#undef VER_FILEVERSION_STR
+#define VER_FILEVERSION_STR "00,00,00,00000"
+#ifndef VER_LEGALCOPYRIGHT_STR
+#define VER_LEGALCOPYRIGHT_STR ".NET Foundation"
+#endif
+#ifndef VER_DEBUG
+#define VER_DEBUG VS_FF_DEBUG
+#endif
--- /dev/null
+@if not defined _echo @echo off
+setlocal EnableDelayedExpansion EnableExtensions
+
+set __VersionFolder=%~dp0
+set __RepoRoot=%~dp0..\..\..
+set __artifactsObjDir=%__RepoRoot%\artifacts\obj
+
+for /r "%__VersionFolder%" %%a in (*.h *.rc) do (
+ if not exist "%__artifactsObjDir%\%%~nxa" (
+ copy "%%a" "%__artifactsObjDir%"
+ )
+)
--- /dev/null
+#!/usr/bin/env bash
+
+__VersionFolder="$(cd "$(dirname "$0")"; pwd -P)"
+__RepoRoot="$(cd "$(dirname "$__VersionFolder")/../../"; pwd -P)"
+
+for path in "${__VersionFolder}/"*{.h,.c}; do
+ if [[ "$(basename $path)" == _version.c ]]; then
+ # For _version.c, update the commit ID if it has changed from the last build.
+ # Set IFS to nothing to prevent the shell from combining all of the piped output into a single line in the script below
+ IFS=
+ # update commit
+ commit="$(git rev-parse HEAD 2>/dev/null)"
+ commit="${commit:-N/A}"
+ substitute="$(printf 'static char sccsid[] __attribute__((used)) = "@(#)Version N/A @Commit: %s";\n' "$commit")"
+ version_file_contents="$(cat "$path" | sed "s|^static.*|$substitute|")"
+ version_file_destination="$__RepoRoot/artifacts/obj/_version.c"
+ current_contents=
+ is_placeholder_file=
+ if [[ -e "$version_file_destination" ]]; then
+ current_contents="$(<"$__RepoRoot/artifacts/obj/_version.c")"
+ # If the current file has the version placeholder this script uses, we can update it
+ # to have the current commit. Otherwise, use the current version file that has the actual product version.
+ is_placeholder_file="$(echo $current_contents | grep "@(#)Version N/A @Commit:")"
+ else
+ # Treat a non-existent file like a file that doesn't exist.
+ is_placeholder_file=1
+ fi
+ if [[ "$is_placeholder_file" && "$version_file_contents" != "$current_contents" ]]; then
+ echo "$version_file_contents" > "$version_file_destination"
+ fi
+ elif [[ ! -e "$__RepoRoot/artifacts/obj/$(basename "$path")" ]]; then
+ cp "$path" "$__RepoRoot/artifacts/obj/"
+ fi
+done
--- /dev/null
+#define RuntimeAssemblyMajorVersion 0
+#define RuntimeAssemblyMinorVersion 0
+#define RuntimeFileMajorVersion 0
+#define RuntimeFileMinorVersion 0
+#define RuntimeFileBuildVersion 0
+#define RuntimeFileRevisionVersion 0
+#define RuntimeProductMajorVersion 0
+#define RuntimeProductMinorVersion 0
+#define RuntimeProductPatchVersion 0
+#define RuntimeProductVersion 0.0.0-dev
"name": "dotnet-stack",
"rids": ["win-x64", "win-x86", "win-arm", "win-arm64", "linux-x64", "linux-musl-arm64", "osx-x64", "linux-arm64", "linux-musl-x64", "linux-arm"]
}
+ {
+ "name": "dotnet-dsrouter",
+ "rids": ["win-x64", "win-x86", "win-arm", "win-arm64", "linux-x64", "linux-musl-arm64", "osx-x64", "linux-arm64", "linux-musl-x64", "linux-arm"]
+ }
]
},
"NugetAssets": {
"dotnet-sos",
"dotnet-trace",
"dotnet-stack",
+ "dotnet-dsrouter",
"Microsoft.Diagnostics.NETCore.Client"
]
}
+++ /dev/null
-@if not defined _echo @echo off
-
-REM This script is responsible for setting up the vs2017 or vs2019 env
-REM All passed arguments are ignored
-REM Script will return with 0 if pass, 1 if there is a failure to find either
-REM vs2017 or vs2019
-
-:: Default to highest Visual Studio version available
-::
-:: For VS2017 and later, multiple instances can be installed on the same box SxS and VS1*0COMNTOOLS
-:: is no longer set as a global environment variable and is instead only set if the user
-:: has launched the Visual Studio Developer Command Prompt.
-::
-:: Following this logic, we will default to the Visual Studio toolset assocated with the active
-:: Developer Command Prompt. Otherwise, we will query VSWhere to locate the later version of
-:: Visual Studio available on the machine. Finally, we will fail the script if not supported
-:: instance can be found.
-
-if defined VisualStudioVersion (
- if not defined __VSVersion echo %__MsgPrefix%Detected Visual Studio %VisualStudioVersion% developer command ^prompt environment
- goto skip_setup
-)
-
-echo %__MsgPrefix%Searching ^for Visual Studio 2017 or later installation
-set _VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
-if exist %_VSWHERE% (
- for /f "usebackq tokens=*" %%i in (`%_VSWHERE% -latest -prerelease -property installationPath`) do set _VSCOMNTOOLS=%%i\Common7\Tools
- goto call_vs
-)
-echo Visual Studio 2017 or later not found
-:call_vs
-if not exist "%_VSCOMNTOOLS%" (
- echo %__MsgPrefix%Error: Visual Studio 2017 or 2019 required.
- echo Please see https://github.com/dotnet/runtime/blob/main/docs/workflow/building/coreclr/windows-instructions.md for build instructions.
- exit /b 1
-)
-echo %__MsgPrefix%"%_VSCOMNTOOLS%\VsDevCmd.bat"
-call "%_VSCOMNTOOLS%\VsDevCmd.bat"
-
-:skip_setup
-
-exit /b 0
+++ /dev/null
-SET (CMAKE_C_FLAGS_INIT "/Wall /FC")
-SET (CMAKE_C_FLAGS_DEBUG_INIT "/Od /Zi")
-SET (CLR_C_FLAGS_CHECKED_INIT "/O1 /Zi")
-SET (CMAKE_C_FLAGS_RELEASE_INIT "/Ox /Zi")
-SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/O2 /Zi")
-
-SET (CMAKE_CXX_FLAGS_INIT "/Wall /FC")
-SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/Od /Zi")
-SET (CLR_CXX_FLAGS_CHECKED_INIT "/O1 /Zi")
-SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/Ox /Zi")
-SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/O2 /Zi")
-
-SET (CLR_DEFINES_DEBUG_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
-SET (CLR_DEFINES_CHECKED_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
-SET (CLR_DEFINES_RELEASE_INIT NDEBUG URTBLDENV_FRIENDLY=Retail)
-SET (CLR_DEFINES_RELWITHDEBINFO_INIT NDEBUG URTBLDENV_FRIENDLY=Retail)
\ No newline at end of file
+++ /dev/null
-# Copyright (c) .NET Foundation and contributors. All rights reserved.
-# Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-function(clr_unknown_arch)
- if (WIN32)
- message(FATAL_ERROR "Only AMD64, ARM64, ARM and I386 are supported")
- elseif(CLR_CROSS_COMPONENTS_BUILD)
- message(FATAL_ERROR "Only AMD64, I386 host are supported for linux cross-architecture component")
- else()
- message(FATAL_ERROR "Only AMD64, ARM64 and ARM are supported")
- endif()
-endfunction()
-
-# Build a list of compiler definitions by putting -D in front of each define.
-function(get_compile_definitions DefinitionName)
- # Get the current list of definitions
- get_directory_property(COMPILE_DEFINITIONS_LIST COMPILE_DEFINITIONS)
-
- foreach(DEFINITION IN LISTS COMPILE_DEFINITIONS_LIST)
- if (${DEFINITION} MATCHES "^\\$<\\$<CONFIG:([^>]+)>:([^>]+)>$")
- # The entries that contain generator expressions must have the -D inside of the
- # expression. So we transform e.g. $<$<CONFIG:Debug>:_DEBUG> to $<$<CONFIG:Debug>:-D_DEBUG>
- set(DEFINITION "$<$<CONFIG:${CMAKE_MATCH_1}>:-D${CMAKE_MATCH_2}>")
- else()
- set(DEFINITION -D${DEFINITION})
- endif()
- list(APPEND DEFINITIONS ${DEFINITION})
- endforeach()
- set(${DefinitionName} ${DEFINITIONS} PARENT_SCOPE)
-endfunction(get_compile_definitions)
-
-# Build a list of include directories
-function(get_include_directories IncludeDirectories)
- get_directory_property(dirs INCLUDE_DIRECTORIES)
- foreach(dir IN LISTS dirs)
-
- if (CLR_CMAKE_PLATFORM_ARCH_ARM AND WIN32)
- list(APPEND INC_DIRECTORIES /I${dir})
- else()
- list(APPEND INC_DIRECTORIES -I${dir})
- endif(CLR_CMAKE_PLATFORM_ARCH_ARM AND WIN32)
-
- endforeach()
- set(${IncludeDirectories} ${INC_DIRECTORIES} PARENT_SCOPE)
-endfunction(get_include_directories)
-
-# Set the passed in RetSources variable to the list of sources with added current source directory
-# to form absolute paths.
-# The parameters after the RetSources are the input files.
-function(convert_to_absolute_path RetSources)
- set(Sources ${ARGN})
- foreach(Source IN LISTS Sources)
- list(APPEND AbsolutePathSources ${CMAKE_CURRENT_SOURCE_DIR}/${Source})
- endforeach()
- set(${RetSources} ${AbsolutePathSources} PARENT_SCOPE)
-endfunction(convert_to_absolute_path)
-
-#Preprocess exports definition file
-function(preprocess_def_file inputFilename outputFilename)
- get_compile_definitions(PREPROCESS_DEFINITIONS)
- get_include_directories(ASM_INCLUDE_DIRECTORIES)
- add_custom_command(
- OUTPUT ${outputFilename}
- COMMAND ${CMAKE_CXX_COMPILER} ${ASM_INCLUDE_DIRECTORIES} /P /EP /TC ${PREPROCESS_DEFINITIONS} /Fi${outputFilename} ${inputFilename}
- DEPENDS ${inputFilename}
- COMMENT "Preprocessing ${inputFilename} - ${CMAKE_CXX_COMPILER} ${ASM_INCLUDE_DIRECTORIES} /P /EP /TC ${PREPROCESS_DEFINITIONS} /Fi${outputFilename} ${inputFilename}"
- )
-
- set_source_files_properties(${outputFilename}
- PROPERTIES GENERATED TRUE)
-endfunction()
-function(generate_exports_file)
- set(INPUT_LIST ${ARGN})
- list(GET INPUT_LIST -1 outputFilename)
- list(REMOVE_AT INPUT_LIST -1)
-
- if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
- set(AWK_SCRIPT eng/generateexportedsymbols.awk)
- else()
- set(AWK_SCRIPT eng/generateversionscript.awk)
- endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
-
- add_custom_command(
- OUTPUT ${outputFilename}
- COMMAND ${AWK} -f ${CMAKE_SOURCE_DIR}/${AWK_SCRIPT} ${INPUT_LIST} >${outputFilename}
- DEPENDS ${INPUT_LIST} ${CMAKE_SOURCE_DIR}/${AWK_SCRIPT}
- COMMENT "Generating exports file ${outputFilename}"
- )
- set_source_files_properties(${outputFilename}
- PROPERTIES GENERATED TRUE)
-endfunction()
-
-function(strip_symbols targetName outputFilename)
- if (CLR_CMAKE_PLATFORM_UNIX)
- if (STRIP_SYMBOLS)
-
- # On the older version of cmake (2.8.12) used on Ubuntu 14.04 the TARGET_FILE
- # generator expression doesn't work correctly returning the wrong path and on
- # the newer cmake versions the LOCATION property isn't supported anymore.
- if (CMAKE_VERSION VERSION_EQUAL 3.0 OR CMAKE_VERSION VERSION_GREATER 3.0)
- set(strip_source_file $<TARGET_FILE:${targetName}>)
- else()
- get_property(strip_source_file TARGET ${targetName} PROPERTY LOCATION)
- endif()
-
- if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
- set(strip_destination_file ${strip_source_file}.dwarf)
-
- add_custom_command(
- TARGET ${targetName}
- POST_BUILD
- VERBATIM
- COMMAND ${DSYMUTIL} --flat --minimize ${strip_source_file}
- COMMAND ${STRIP} -S ${strip_source_file}
- COMMENT Stripping symbols from ${strip_source_file} into file ${strip_destination_file}
- )
- else (CMAKE_SYSTEM_NAME STREQUAL Darwin)
- set(strip_destination_file ${strip_source_file}.dbg)
-
- add_custom_command(
- TARGET ${targetName}
- POST_BUILD
- VERBATIM
- COMMAND ${OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
- COMMAND ${OBJCOPY} --strip-debug ${strip_source_file}
- COMMAND ${OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file}
- COMMENT Stripping symbols from ${strip_source_file} into file ${strip_destination_file}
- )
- endif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
-
- set(${outputFilename} ${strip_destination_file} PARENT_SCOPE)
- endif (STRIP_SYMBOLS)
- endif(CLR_CMAKE_PLATFORM_UNIX)
-endfunction()
-
-function(install_clr targetName)
- list(FIND CLR_CROSS_COMPONENTS_LIST ${targetName} INDEX)
- if (NOT DEFINED CLR_CROSS_COMPONENTS_LIST OR NOT ${INDEX} EQUAL -1)
- strip_symbols(${targetName} strip_destination_file)
- # On the older version of cmake (2.8.12) used on Ubuntu 14.04 the TARGET_FILE
- # generator expression doesn't work correctly returning the wrong path and on
- # the newer cmake versions the LOCATION property isn't supported anymore.
- if(CMAKE_VERSION VERSION_EQUAL 3.0 OR CMAKE_VERSION VERSION_GREATER 3.0)
- set(install_source_file $<TARGET_FILE:${targetName}>)
- else()
- get_property(install_source_file TARGET ${targetName} PROPERTY LOCATION)
- endif()
-
- install(PROGRAMS ${install_source_file} DESTINATION .)
- if(WIN32)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pdb DESTINATION .)
- else()
- install(FILES ${strip_destination_file} DESTINATION .)
- endif()
- endif()
-endfunction()
-
-function(_add_executable)
- add_executable(${ARGV})
- list(FIND CLR_CROSS_COMPONENTS_LIST ${ARGV0} INDEX)
- if (DEFINED CLR_CROSS_COMPONENTS_LIST AND ${INDEX} EQUAL -1)
- set_target_properties(${ARGV0} PROPERTIES EXCLUDE_FROM_ALL 1)
- endif()
-endfunction()
-
-function(_add_library)
- add_library(${ARGV})
- list(FIND CLR_CROSS_COMPONENTS_LIST ${ARGV0} INDEX)
- if (DEFINED CLR_CROSS_COMPONENTS_LIST AND ${INDEX} EQUAL -1)
- set_target_properties(${ARGV0} PROPERTIES EXCLUDE_FROM_ALL 1)
- endif()
-endfunction()
-
-function(add_library_clr)
- if(NOT WIN32)
- _add_library(${ARGV} ${VERSION_FILE_PATH})
- else()
- _add_library(${ARGV})
- endif(NOT WIN32)
-endfunction()
-
-function(add_executable_clr)
- if(NOT WIN32)
- _add_executable(${ARGV} ${VERSION_FILE_PATH})
- else()
- _add_executable(${ARGV})
- endif(NOT WIN32)
-endfunction()
-
-function(_install)
- if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
- install(${ARGV})
- endif()
-endfunction()
-
},
"msbuild-sdks": {
"Microsoft.Build.NoTargets": "2.0.1",
- "Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.21518.1"
+ "Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.21559.3"
}
}
include_directories(inc)
-if (CLR_CMAKE_PLATFORM_UNIX)
+if (CLR_CMAKE_HOST_UNIX)
add_subdirectory(palrt)
add_subdirectory(pal)
-endif(CLR_CMAKE_PLATFORM_UNIX)
+endif(CLR_CMAKE_HOST_UNIX)
add_subdirectory(inc)
add_subdirectory(SOS)
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using Microsoft.Diagnostics.Runtime;
using Microsoft.Diagnostics.Runtime.Utilities;
using Microsoft.FileFormats;
using Microsoft.FileFormats.ELF;
private readonly IDisposable _onChangeEvent;
private Flags _flags;
private PdbFileInfo _pdbFileInfo;
- private ImmutableArray<byte> _buildId;
+ protected ImmutableArray<byte> _buildId;
private PEImage _peImage;
public readonly ServiceProvider ServiceProvider;
{
get
{
- GetPEInfo();
- return (_flags & Flags.IsPEImage) != 0;
+ // For Windows targets, we can always assume that all the modules are PEs.
+ if (Target.OperatingSystem == OSPlatform.Windows)
+ {
+ return true;
+ }
+ else
+ {
+ GetPEInfo();
+ return (_flags & Flags.IsPEImage) != 0;
+ }
}
}
}
}
- public ImmutableArray<byte> BuildId
+ public virtual ImmutableArray<byte> BuildId
{
get
{
if (_buildId.IsDefault)
{
- byte[] id = ModuleService.GetBuildId(ImageBase, ImageSize);
+ byte[] id = ModuleService.GetBuildId(ImageBase);
if (id != null)
{
_buildId = id.ToImmutableArray();
{
if (Target.OperatingSystem == OSPlatform.Windows)
{
- Stream stream = Target.Services.GetService<IMemoryService>().CreateMemoryStream(ImageBase, ImageSize);
+ Stream stream = ModuleService.MemoryService.CreateMemoryStream(ImageBase, ImageSize);
PEFile image = new(new StreamAddressSpace(stream), isDataSourceVirtualAddressSpace: true);
if (image.IsValid())
{
{
try
{
- Stream stream = Target.Services.GetService<IMemoryService>().CreateMemoryStream(ImageBase, ImageSize);
+ Stream stream = ModuleService.MemoryService.CreateMemoryStream(ImageBase, ImageSize);
ElfFile elfFile = new(stream, position: ImageBase, leaveOpen: false, isVirtual: true);
if (elfFile.Header.IsValid)
{
const uint VmProtWrite = 0x02;
internal protected readonly ITarget Target;
+ internal protected IMemoryService RawMemoryService;
private IMemoryService _memoryService;
private ISymbolService _symbolService;
private ReadVirtualCache _versionCache;
private static readonly byte[] s_versionString = Encoding.ASCII.GetBytes("@(#)Version ");
private static readonly int s_versionLength = s_versionString.Length;
- public ModuleService(ITarget target)
+ public ModuleService(ITarget target, IMemoryService rawMemoryService)
{
Debug.Assert(target != null);
Target = target;
+ RawMemoryService = rawMemoryService;
target.OnFlushEvent.Register(() => {
_versionCache?.Clear();
/// <returns>module or null</returns>
IModule IModuleService.GetModuleFromAddress(ulong address)
{
- Debug.Assert((address & ~MemoryService.SignExtensionMask()) == 0);
+ Debug.Assert((address & ~RawMemoryService.SignExtensionMask()) == 0);
IModule[] modules = GetSortedModules();
int min = 0, max = modules.Length - 1;
IModule module = modules[mid];
ulong start = module.ImageBase;
- Debug.Assert((start & ~MemoryService.SignExtensionMask()) == 0);
+ Debug.Assert((start & ~RawMemoryService.SignExtensionMask()) == 0);
ulong end = start + module.ImageSize;
if (address >= start && address < end) {
/// <returns>PEImage instance or null</returns>
private PEImage GetPEInfo(bool isVirtual, ulong address, ulong size, ref PdbFileInfo pdbFileInfo, ref Module.Flags flags)
{
- Stream stream = MemoryService.CreateMemoryStream(address, size);
+ Stream stream = RawMemoryService.CreateMemoryStream(address, size);
try
{
stream.Position = 0;
/// Returns the ELF module build id or the MachO module uuid
/// </summary>
/// <param name="address">module base address</param>
- /// <param name="size">module size</param>
/// <returns>build id or null</returns>
- internal byte[] GetBuildId(ulong address, ulong size)
+ internal byte[] GetBuildId(ulong address)
{
- Debug.Assert(size > 0);
- Stream stream = MemoryService.CreateMemoryStream(address, size);
+ Stream stream = RawMemoryService.CreateMemoryStream();
byte[] buildId = null;
try
{
if (Target.OperatingSystem == OSPlatform.Linux)
{
- var elfFile = new ELFFile(new StreamAddressSpace(stream), 0, true);
+ var elfFile = new ELFFile(new StreamAddressSpace(stream), address, true);
if (elfFile.IsValid())
{
buildId = elfFile.BuildID;
}
else if (Target.OperatingSystem == OSPlatform.OSX)
{
- var machOFile = new MachOFile(new StreamAddressSpace(stream), 0, true);
+ var machOFile = new MachOFile(new StreamAddressSpace(stream), address, true);
if (machOFile.IsValid())
{
buildId = machOFile.Uuid;
/// Get the version string from a Linux or MacOS image
/// </summary>
/// <param name="address">image base</param>
- /// <param name="size">image size</param>
/// <returns>version string or null</returns>
- protected string GetVersionString(ulong address, ulong size)
+ protected string GetVersionString(ulong address)
{
- Stream stream = MemoryService.CreateMemoryStream(address, size);
+ Stream stream = RawMemoryService.CreateMemoryStream();
try
{
if (Target.OperatingSystem == OSPlatform.Linux)
{
- var elfFile = new ELFFile(new StreamAddressSpace(stream), 0, true);
+ var elfFile = new ELFFile(new StreamAddressSpace(stream), address, true);
if (elfFile.IsValid())
{
foreach (ELFProgramHeader programHeader in elfFile.Segments.Select((segment) => segment.Header))
{
- uint flags = MemoryService.PointerSize == 8 ? programHeader.Flags : programHeader.Flags32;
+ uint flags = RawMemoryService.PointerSize == 8 ? programHeader.Flags : programHeader.Flags32;
if (programHeader.Type == ELFProgramHeaderType.Load &&
(flags & (uint)ELFProgramHeaderAttributes.Writable) != 0)
{
}
else if (Target.OperatingSystem == OSPlatform.OSX)
{
- var machOFile = new MachOFile(new StreamAddressSpace(stream), 0, true);
+ var machOFile = new MachOFile(new StreamAddressSpace(stream), address, true);
if (machOFile.IsValid())
{
foreach (MachSegmentLoadCommand loadCommand in machOFile.Segments.Select((segment) => segment.LoadCommand))
(loadCommand.InitProt & VmProtWrite) != 0 &&
loadCommand.SegName.ToString() != "__LINKEDIT")
{
- ulong loadAddress = loadCommand.VMAddress;
+ ulong loadAddress = loadCommand.VMAddress + machOFile.PreferredVMBaseAddress;
long loadSize = (long)loadCommand.VMSize;
- if (SearchVersionString(address + loadAddress, loadSize, out string productVersion))
+ if (SearchVersionString(loadAddress, loadSize, out string productVersion))
{
return productVersion;
}
byte[] buffer = new byte[s_versionString.Length];
if (_versionCache == null) {
- _versionCache = new ReadVirtualCache(MemoryService);
+ // We use the possibly mapped memory service to find the version string in case it isn't in the dump.
+ _versionCache = new ReadVirtualCache(Target.Services.GetService<IMemoryService>());
}
_versionCache.Clear();
else {
return string.Equals(Path.GetFileName(module.FileName), moduleName);
}
- }
+ }
- protected IMemoryService MemoryService => _memoryService ??= Target.Services.GetService<IMemoryService>();
+ internal protected IMemoryService MemoryService => _memoryService ??= Target.Services.GetService<IMemoryService>();
- protected ISymbolService SymbolService => _symbolService ??= Target.Services.GetService<ISymbolService>();
+ internal protected ISymbolService SymbolService => _symbolService ??= Target.Services.GetService<ISymbolService>();
/// <summary>
/// Search memory helper class
using Microsoft.Diagnostics.Runtime;
using System;
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.Diagnostics;
-using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
// This is what clrmd returns for non-PE modules that don't have a timestamp
private const uint InvalidTimeStamp = 0;
- private static readonly Microsoft.Diagnostics.Runtime.VersionInfo EmptyVersionInfo = new (0, 0, 0, 0);
+ private static readonly VersionInfo EmptyVersionInfo = new (0, 0, 0, 0);
private readonly ModuleServiceFromDataReader _moduleService;
private readonly IExportReader _exportReader;
private readonly ModuleInfo _moduleInfo;
public override uint? IndexTimeStamp => _moduleInfo.IndexTimeStamp == InvalidTimeStamp ? null : (uint)_moduleInfo.IndexTimeStamp;
+ public override ImmutableArray<byte> BuildId
+ {
+ get
+ {
+ if (_buildId.IsDefault)
+ {
+ ImmutableArray<byte> buildId = _moduleService._dataReader.GetBuildId(ImageBase);
+ // If the data reader can't get the build id, it returns a empty (instead of default) immutable array.
+ _buildId = buildId.IsDefaultOrEmpty ? base.BuildId : buildId;
+ }
+ return _buildId;
+ }
+ }
+
public override VersionData VersionData
{
get
{
if (_moduleService.Target.OperatingSystem != OSPlatform.Windows && !IsPEImage)
{
- _versionString = _moduleService.GetVersionString(ImageBase, ImageSize);
+ _versionString = _moduleService.GetVersionString(ImageBase);
}
}
return _versionString;
private readonly IDataReader _dataReader;
- public ModuleServiceFromDataReader(ITarget target, IDataReader dataReader)
- : base(target)
+ public ModuleServiceFromDataReader(ITarget target, IMemoryService rawMemoryService, IDataReader dataReader)
+ : base(target, rawMemoryService)
{
_dataReader = dataReader;
}
}
// Add the thread, memory, and module services
+ IMemoryService rawMemoryService = new MemoryServiceFromDataReader(_dataReader);
ServiceProvider.AddServiceFactory<IThreadService>(() => new ThreadServiceFromDataReader(this, _dataReader));
- ServiceProvider.AddServiceFactory<IModuleService>(() => new ModuleServiceFromDataReader(this, _dataReader));
+ ServiceProvider.AddServiceFactory<IModuleService>(() => new ModuleServiceFromDataReader(this, rawMemoryService, _dataReader));
ServiceProvider.AddServiceFactory<IMemoryService>(() => {
- IMemoryService memoryService = new MemoryServiceFromDataReader(_dataReader);
- if (IsDump && Host.HostType == HostType.DotnetDump)
+ IMemoryService memoryService = rawMemoryService;
+ if (IsDump)
{
memoryService = new ImageMappingMemoryService(this, memoryService);
+ // Any dump created for a MacOS target does not have managed assemblies in the module service so
+ // we need to use the metadata mapping memory service to make sure the metadata is available.
+ if (targetOS == OSPlatform.OSX)
+ {
+ memoryService = new MetadataMappingMemoryService(this, memoryService);
+ }
}
return memoryService;
});
return false;
}
+ /// <summary>
+ /// Create a stream for all of memory.
+ /// </summary>
+ /// <param name="memoryService">memory service instance</param>
+ /// <returns>Stream of all of memory</returns>
+ public static Stream CreateMemoryStream(this IMemoryService memoryService)
+ {
+ return new TargetStream(memoryService, 0, long.MaxValue);
+ }
+
/// <summary>
/// Create a stream for the address range.
/// </summary>
/// <param name="memoryService">memory service instance</param>
/// <param name="address">address to read</param>
/// <param name="size">size of stream</param>
- /// <returns></returns>
+ /// <returns>memory range Stream</returns>
public static Stream CreateMemoryStream(this IMemoryService memoryService, ulong address, ulong size)
{
+ Debug.Assert(address != 0);
+ Debug.Assert(size != 0);
return new TargetStream(memoryService, address, size);
}
public TargetStream(IMemoryService memoryService, ulong address, ulong size)
: base()
{
- Debug.Assert(address != 0);
- Debug.Assert(size != 0);
_memoryService = memoryService;
_address = address;
Length = (long)size;
// See the LICENSE file in the project root for more information.
using Microsoft.Diagnostics.DebugServices;
+using Microsoft.FileFormats;
+using Microsoft.FileFormats.ELF;
+using Microsoft.FileFormats.MachO;
+using System;
+using System.Diagnostics;
using System.Diagnostics.Tracing;
+using System.IO;
using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text.RegularExpressions;
namespace Microsoft.Diagnostics.ExtensionCommands
{
[Option(Name = "--verbose", Aliases = new string[] { "-v" }, Help = "Displays more details.")]
public bool Verbose { get; set; }
+ [Option(Name = "--segments", Aliases = new string[] { "-s" }, Help = "Displays the module segments.")]
+ public bool Segment { get; set; }
+
+
+ [Option(Name = "--name", Aliases = new string[] { "-n" }, Help = "RegEx filter on module name (path not included).")]
+ public string ModuleName { get; set; }
+
public IModuleService ModuleService { get; set; }
public override void Invoke()
{
+ Regex regex = ModuleName is not null ? new Regex(ModuleName, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) : null;
ulong totalSize = 0;
+
foreach (IModule module in ModuleService.EnumerateModules().OrderBy((m) => m.ModuleIndex))
{
totalSize += module.ImageSize;
- if (Verbose)
+ if (regex is null || regex.IsMatch(Path.GetFileName(module.FileName)))
{
- WriteLine("{0} {1}", module.ModuleIndex, module.FileName);
- WriteLine(" Address: {0:X16}", module.ImageBase);
- WriteLine(" ImageSize: {0:X8}", module.ImageSize);
- WriteLine(" IsPEImage: {0}", module.IsPEImage);
- WriteLine(" IsManaged: {0}", module.IsManaged);
- WriteLine(" IsFileLayout: {0}", module.IsFileLayout?.ToString() ?? "<unknown>");
- WriteLine(" IndexFileSize: {0}", module.IndexFileSize?.ToString("X8") ?? "<none>");
- WriteLine(" IndexTimeStamp: {0}", module.IndexTimeStamp?.ToString("X8") ?? "<none>");
- WriteLine(" Version: {0}", module.VersionData?.ToString() ?? "<none>");
- string versionString = module.VersionString;
- if (!string.IsNullOrEmpty(versionString)) {
- WriteLine(" {0}", versionString);
+ if (Verbose)
+ {
+ WriteLine("{0} {1}", module.ModuleIndex, module.FileName);
+ WriteLine(" Address: {0:X16}", module.ImageBase);
+ WriteLine(" ImageSize: {0:X8}", module.ImageSize);
+ WriteLine(" IsPEImage: {0}", module.IsPEImage);
+ WriteLine(" IsManaged: {0}", module.IsManaged);
+ WriteLine(" IsFileLayout: {0}", module.IsFileLayout?.ToString() ?? "<unknown>");
+ WriteLine(" IndexFileSize: {0}", module.IndexFileSize?.ToString("X8") ?? "<none>");
+ WriteLine(" IndexTimeStamp: {0}", module.IndexTimeStamp?.ToString("X8") ?? "<none>");
+ WriteLine(" Version: {0}", module.VersionData?.ToString() ?? "<none>");
+ string versionString = module.VersionString;
+ if (!string.IsNullOrEmpty(versionString))
+ {
+ WriteLine(" {0}", versionString);
+ }
+ WriteLine(" PdbInfo: {0}", module.PdbFileInfo?.ToString() ?? "<none>");
+ WriteLine(" BuildId: {0}", !module.BuildId.IsDefaultOrEmpty ? string.Concat(module.BuildId.Select((b) => b.ToString("x2"))) : "<none>");
+ }
+ else
+ {
+ WriteLine("{0:X16} {1:X8} {2}", module.ImageBase, module.ImageSize, module.FileName);
+ }
+ if (Segment)
+ {
+ DisplaySegments(module.ImageBase);
}
- WriteLine(" PdbInfo: {0}", module.PdbFileInfo?.ToString() ?? "<none>");
- WriteLine(" BuildId: {0}", !module.BuildId.IsDefaultOrEmpty ? string.Concat(module.BuildId.Select((b) => b.ToString("x2"))) : "<none>");
}
- else
+ }
+ WriteLine("Total image size: {0}", totalSize);
+ }
+
+ public ITarget Target { get; set; }
+
+ public IMemoryService MemoryService { get; set; }
+
+ void DisplaySegments(ulong address)
+ {
+ try
+ {
+ if (Target.OperatingSystem == OSPlatform.Linux)
+ {
+ Stream stream = MemoryService.CreateMemoryStream();
+ var elfFile = new ELFFile(new StreamAddressSpace(stream), address, true);
+ if (elfFile.IsValid())
+ {
+ foreach (ELFProgramHeader programHeader in elfFile.Segments.Select((segment) => segment.Header))
+ {
+ uint flags = MemoryService.PointerSize == 8 ? programHeader.Flags : programHeader.Flags32;
+ ulong loadAddress = programHeader.VirtualAddress;
+ ulong loadSize = programHeader.VirtualSize;
+ ulong fileOffset = programHeader.FileOffset;
+ string type = programHeader.Type.ToString();
+ WriteLine($" Segment: {loadAddress:X16} {loadSize:X16} {fileOffset:X16} {flags:x2} {type}");
+ }
+ }
+ }
+ else if (Target.OperatingSystem == OSPlatform.OSX)
{
- WriteLine("{0:X16} {1:X8} {2}", module.ImageBase, module.ImageSize, module.FileName);
+ Stream stream = MemoryService.CreateMemoryStream();
+ MachOFile machOFile = new(new StreamAddressSpace(stream), address, true);
+ if (machOFile.IsValid())
+ {
+ WriteLine(" LoadAddress: {0:X16}", machOFile.LoadAddress);
+ WriteLine(" LoadBias: {0:X16}", machOFile.PreferredVMBaseAddress);
+ for (int i = 0; i < machOFile.Segments.Length; i++)
+ {
+ MachSegment segment = machOFile.Segments[i];
+ ulong loadAddress = segment.LoadCommand.VMAddress;
+ ulong loadSize = segment.LoadCommand.VMSize;
+ ulong fileOffset = segment.LoadCommand.FileOffset;
+ uint prot = segment.LoadCommand.InitProt;
+ string name = segment.LoadCommand.SegName.ToString();
+ WriteLine($" Segment {i}: {loadAddress:X16} {loadSize:X16} {fileOffset:X16} {prot:x2} {name}");
+ }
+ }
}
}
- WriteLine("Total image size: {0}", totalSize);
+ catch (Exception ex) when (ex is InvalidVirtualAddressException || ex is BadInputFormatException)
+ {
+ Trace.TraceError($"Exception displaying module segments: {ex}");
+ }
}
}
}
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Diagnostics.NETCore.Client;
// CONSIDER: Might have to deduplicate providers and merge them together.
return _configurations.SelectMany(c => c.GetProviders()).ToList();
}
+
+ public override bool RequestRundown
+ {
+ get => _configurations.Any(c => c.RequestRundown);
+ set => throw new NotSupportedException();
+ }
}
}
public AspNetTriggerSourceConfiguration(float? heartbeatIntervalSeconds = null)
{
+ RequestRundown = false;
_heartbeatIntervalSeconds = heartbeatIntervalSeconds;
}
public sealed class EventPipeProviderSourceConfiguration : MonitoringSourceConfiguration
{
private readonly IEnumerable<EventPipeProvider> _providers;
- private readonly bool _requestRundown;
private readonly int _bufferSizeInMB;
public EventPipeProviderSourceConfiguration(bool requestRundown = true, int bufferSizeInMB = 256, params EventPipeProvider[] providers)
{
_providers = providers;
- _requestRundown = requestRundown;
+ RequestRundown = requestRundown;
_bufferSizeInMB = bufferSizeInMB;
}
return _providers.ToList();
}
- public override bool RequestRundown => _requestRundown;
-
public override int BufferSizeInMB => _bufferSizeInMB;
}
}
{
public sealed class GCDumpSourceConfiguration : MonitoringSourceConfiguration
{
+ public GCDumpSourceConfiguration()
+ {
+ RequestRundown = false;
+ }
+
public override IList<EventPipeProvider> GetProviders()
{
var providers = new List<EventPipeProvider>()
{
public sealed class HttpRequestSourceConfiguration : MonitoringSourceConfiguration
{
+ public HttpRequestSourceConfiguration()
+ {
+ //CONSIDER removing rundown for this scenario.
+ RequestRundown = true;
+ }
+
private const string DiagnosticFilterString =
"Microsoft.AspNetCore/Microsoft.AspNetCore.Hosting.HttpRequestIn.Start@Activity1Start:-" +
"Request.Scheme" +
/// </summary>
public LoggingSourceConfiguration(LogLevel level, LogMessageType messageType, IDictionary<string, LogLevel?> filterSpecs, bool useAppFilters)
{
+ RequestRundown = false;
_filterSpecs = ToFilterSpecsString(filterSpecs, useAppFilters);
_keywords = (long)ToKeywords(messageType);
_level = ToEventLevel(level);
public MetricSourceConfiguration(float metricIntervalSeconds, IEnumerable<string> customProviderNames)
{
+ RequestRundown = false;
if (customProviderNames == null)
{
throw new ArgumentNullException(nameof(customProviderNames));
public abstract IList<EventPipeProvider> GetProviders();
- public virtual bool RequestRundown => true;
+ public virtual bool RequestRundown { get; set; } = true;
public virtual int BufferSizeInMB => 256;
}
// See the LICENSE file in the project root for more information.
using Microsoft.Diagnostics.NETCore.Client;
+using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
public override int BufferSizeInMB => 1;
- public override bool RequestRundown => false;
+ public override bool RequestRundown
+ {
+ get => false;
+ set => throw new NotSupportedException();
+ }
}
}
ValidateResponseMessage(response, nameof(WriteDump));
}
+ /// <summary>
+ /// Trigger a core dump generation.
+ /// </summary>
+ /// <param name="dumpType">Type of the dump to be generated</param>
+ /// <param name="dumpPath">Full path to the dump to be generated. By default it is /tmp/coredump.{pid}</param>
+ /// <param name="flags">logging and crash report flags. On runtimes less than 6.0, only LoggingEnabled is supported.</param>
+ public void WriteDump(DumpType dumpType, string dumpPath, WriteDumpFlags flags)
+ {
+ IpcMessage request = CreateWriteDumpMessage2(dumpType, dumpPath, flags);
+ IpcMessage response = IpcClient.SendMessage(_endpoint, request);
+ if (!ValidateResponseMessage(response, nameof(WriteDump), ValidateResponseOptions.UnknownCommandReturnsFalse))
+ {
+ if ((flags & ~WriteDumpFlags.LoggingEnabled) != 0)
+ {
+ throw new ArgumentException($"Only {nameof(WriteDumpFlags.LoggingEnabled)} flag is supported by this runtime version", nameof(flags));
+ }
+ WriteDump(dumpType, dumpPath, logDumpGeneration: (flags & WriteDumpFlags.LoggingEnabled) != 0);
+ }
+ }
+
/// <summary>
/// Trigger a core dump generation.
/// </summary>
/// <param name="dumpPath">Full path to the dump to be generated. By default it is /tmp/coredump.{pid}</param>
/// <param name="logDumpGeneration">When set to true, display the dump generation debug log to the console.</param>
/// <param name="token">The token to monitor for cancellation requests.</param>
- internal async Task WriteDumpAsync(DumpType dumpType, string dumpPath, bool logDumpGeneration, CancellationToken token)
+ public async Task WriteDumpAsync(DumpType dumpType, string dumpPath, bool logDumpGeneration, CancellationToken token)
{
IpcMessage request = CreateWriteDumpMessage(dumpType, dumpPath, logDumpGeneration);
IpcMessage response = await IpcClient.SendMessageAsync(_endpoint, request, token).ConfigureAwait(false);
ValidateResponseMessage(response, nameof(WriteDumpAsync));
}
+ /// <summary>
+ /// Trigger a core dump generation.
+ /// </summary>
+ /// <param name="dumpType">Type of the dump to be generated</param>
+ /// <param name="dumpPath">Full path to the dump to be generated. By default it is /tmp/coredump.{pid}</param>
+ /// <param name="flags">logging and crash report flags. On runtimes less than 6.0, only LoggingEnabled is supported.</param>
+ /// <param name="token">The token to monitor for cancellation requests.</param>
+ public async Task WriteDumpAsync(DumpType dumpType, string dumpPath, WriteDumpFlags flags, CancellationToken token)
+ {
+ IpcMessage request = CreateWriteDumpMessage2(dumpType, dumpPath, flags);
+ IpcMessage response = await IpcClient.SendMessageAsync(_endpoint, request, token).ConfigureAwait(false);
+ if (!ValidateResponseMessage(response, nameof(WriteDumpAsync), ValidateResponseOptions.UnknownCommandReturnsFalse))
+ {
+ if ((flags & ~WriteDumpFlags.LoggingEnabled) != 0)
+ {
+ throw new ArgumentException($"Only {nameof(WriteDumpFlags.LoggingEnabled)} flag is supported by this runtime version", nameof(flags));
+ }
+ await WriteDumpAsync(dumpType, dumpPath, logDumpGeneration: (flags & WriteDumpFlags.LoggingEnabled) != 0, token);
+ }
+ }
+
/// <summary>
/// Attach a profiler.
/// </summary>
Guid guidVal = (Guid)((object)obj);
writer.Write(guidVal.ToByteArray());
}
+ else if (typeof(T) == typeof(byte[]))
+ {
+ byte[] byteArray = (byte[])((object)obj);
+ uint length = byteArray == null ? 0U : (uint)byteArray.Length;
+ writer.Write(length);
+
+ if (length > 0)
+ {
+ writer.Write(byteArray);
+ }
+ }
else
{
throw new ArgumentException($"Type {obj.GetType()} is not supported in SerializePayloadArgument, please add it.");
return new IpcMessage(DiagnosticsServerCommandSet.Dump, (byte)DumpCommandId.GenerateCoreDump, payload);
}
+ private static IpcMessage CreateWriteDumpMessage2(DumpType dumpType, string dumpPath, WriteDumpFlags flags)
+ {
+ if (string.IsNullOrEmpty(dumpPath))
+ throw new ArgumentNullException($"{nameof(dumpPath)} required");
+
+ byte[] payload = SerializePayload(dumpPath, (uint)dumpType, (uint)flags);
+ return new IpcMessage(DiagnosticsServerCommandSet.Dump, (byte)DumpCommandId.GenerateCoreDump2, payload);
+ }
+
private static ProcessInfo GetProcessInfoFromResponse(IpcResponse response, string operationName)
{
ValidateResponseMessage(response.Message, operationName);
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace Microsoft.Diagnostics.NETCore.Client
+{
+ public enum WriteDumpFlags
+ {
+ None = 0x00,
+ LoggingEnabled = 0x01,
+ VerboseLoggingEnabled = 0x02,
+ CrashReportEnabled = 0x04
+ }
+}
\ No newline at end of file
internal enum DumpCommandId : byte
{
GenerateCoreDump = 0x01,
+ GenerateCoreDump2 = 0x02,
}
internal enum ProfilerCommandId : byte
PipeDirection.InOut,
PipeOptions.Asynchronous,
TokenImpersonationLevel.Impersonation);
- await namedPipe.ConnectAsync(token).ConfigureAwait(false);
+
+ // Pass non-infinite timeout in order to cause internal connection algorithm
+ // to check the CancellationToken periodically. Otherwise, if the named pipe
+ // is waited using WaitNamedPipe with an infinite timeout, then the
+ // CancellationToken cannot be observed.
+ await namedPipe.ConnectAsync(int.MaxValue, token).ConfigureAwait(false);
+
return namedPipe;
}
else if (config.Transport == IpcEndpointConfig.TransportType.UnixDomainSocket)
-if(CLR_CMAKE_PLATFORM_UNIX)
+if(CLR_CMAKE_HOST_UNIX)
include_directories(${ROOT_DIR}/src/pal/inc)
include_directories(${ROOT_DIR}/src/pal/inc/rt)
add_subdirectory(lldbplugin)
-endif(CLR_CMAKE_PLATFORM_UNIX)
+endif(CLR_CMAKE_HOST_UNIX)
# lldbplugin doesn't build with these options
if(WIN32)
message(STATUS "CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
- include_directories("$ENV{ProgramFiles(x86)}/Windows Kits/10/Include/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
message(STATUS "VSInstallDir: $ENV{VSInstallDir}")
include_directories("$ENV{VSInstallDir}/DIA SDK/include")
add_subdirectory(SOS.Extensions)
add_subdirectory(Strike)
-if(CLR_CMAKE_PLATFORM_UNIX)
+if(CLR_CMAKE_HOST_UNIX)
add_compile_options(-fPIC)
# Include the dummy c++ include files
# This prevents inclusion of standard C compiler headers
add_compile_options(-nostdinc)
-endif(CLR_CMAKE_PLATFORM_UNIX)
+endif(CLR_CMAKE_HOST_UNIX)
IntPtr self)
{
Trace.TraceInformation("HostServices.DestroyTarget #{0}", _target != null ? _target.Id : "<none>");
- if (_target != null)
+ try
+ {
+ if (_target != null)
+ {
+ DestroyTarget(_target);
+ }
+ }
+ catch (Exception ex)
{
- DestroyTarget(_target);
+ Trace.TraceError(ex.ToString());
}
}
IntPtr self)
{
Trace.TraceInformation("HostServices.Uninitialize");
- DestroyTarget(self);
-
- if (DebuggerServices != null)
+ try
{
- DebuggerServices.Release();
- DebuggerServices = null;
- }
+ DestroyTarget(self);
+
+ if (DebuggerServices != null)
+ {
+ DebuggerServices.Release();
+ DebuggerServices = null;
+ }
- // Send shutdown event on exit
- OnShutdownEvent.Fire();
+ // Send shutdown event on exit
+ OnShutdownEvent.Fire();
- // Release the host services wrapper
- Release();
+ // Release the host services wrapper
+ Release();
- // Clear HostService instance
- Instance = null;
+ // Clear HostService instance
+ Instance = null;
+ }
+ catch (Exception ex)
+ {
+ Trace.TraceError(ex.ToString());
+ }
}
#endregion
{
if (_moduleService.Target.OperatingSystem != OSPlatform.Windows && !IsPEImage)
{
- _versionString = _moduleService.GetVersionString(ImageBase, ImageSize);
+ _versionString = _moduleService.GetVersionString(ImageBase);
}
}
}
private readonly DebuggerServices _debuggerServices;
- internal ModuleServiceFromDebuggerServices(ITarget target, DebuggerServices debuggerServices)
- : base(target)
+ internal ModuleServiceFromDebuggerServices(ITarget target, IMemoryService rawMemoryService, DebuggerServices debuggerServices)
+ : base(target, rawMemoryService)
{
Debug.Assert(debuggerServices != null);
_debuggerServices = debuggerServices;
}
// Add the thread, memory, and module services
- ServiceProvider.AddServiceFactory<IModuleService>(() => new ModuleServiceFromDebuggerServices(this, debuggerServices));
+ IMemoryService rawMemoryService = new MemoryServiceFromDebuggerServices(this, debuggerServices);
+ ServiceProvider.AddServiceFactory<IModuleService>(() => new ModuleServiceFromDebuggerServices(this, rawMemoryService, debuggerServices));
ServiceProvider.AddServiceFactory<IThreadService>(() => new ThreadServiceFromDebuggerServices(this, debuggerServices));
ServiceProvider.AddServiceFactory<IMemoryService>(() => {
- IMemoryService memoryService = new MemoryServiceFromDebuggerServices(this, debuggerServices);
Debug.Assert(Host.HostType != HostType.DotnetDump);
+ IMemoryService memoryService = rawMemoryService;
if (IsDump && Host.HostType == HostType.Lldb)
{
// This is a special memory service that maps the managed assemblies' metadata into the address
// space. The lldb debugger returns zero's (instead of failing the memory read) for missing pages
// in core dumps that older (< 5.0) createdumps generate so it needs this special metadata mapping
// memory service. dotnet-dump needs this logic for clrstack -i (uses ICorDebug data targets).
- memoryService = new MetadataMappingMemoryService(this, memoryService);
+ return new MetadataMappingMemoryService(this, memoryService);
}
return memoryService;
});
private void Flush()
{
// TODO: there is a better way to flush _corDebugProcess with ICorDebugProcess4::ProcessStateChanged(FLUSH_ALL)
- if (_corDebugProcess == IntPtr.Zero)
+ if (_corDebugProcess != IntPtr.Zero)
{
COMHelper.Release(_corDebugProcess);
_corDebugProcess = IntPtr.Zero;
}
// TODO: there is a better way to flush _clrDataProcess with ICLRDataProcess::Flush()
- if (_clrDataProcess == IntPtr.Zero)
+ if (_clrDataProcess != IntPtr.Zero)
{
COMHelper.Release(_clrDataProcess);
_clrDataProcess = IntPtr.Zero;
{
try
{
- Stream stream = MemoryService.CreateMemoryStream(address, size);
KeyGenerator generator = null;
if (config == RuntimeConfiguration.UnixCore)
{
- var elfFile = new ELFFile(new StreamAddressSpace(stream), 0, true);
+ Stream stream = MemoryService.CreateMemoryStream();
+ var elfFile = new ELFFile(new StreamAddressSpace(stream), address, true);
generator = new ELFFileKeyGenerator(Tracer.Instance, elfFile, moduleFilePath);
}
else if (config == RuntimeConfiguration.OSXCore)
{
- var machOFile = new MachOFile(new StreamAddressSpace(stream), 0, true);
+ Stream stream = MemoryService.CreateMemoryStream();
+ var machOFile = new MachOFile(new StreamAddressSpace(stream), address, true);
generator = new MachOFileKeyGenerator(Tracer.Instance, machOFile, moduleFilePath);
}
else if (config == RuntimeConfiguration.WindowsCore || config == RuntimeConfiguration.WindowsDesktop)
{
+ Stream stream = MemoryService.CreateMemoryStream(address, size);
var peFile = new PEFile(new StreamAddressSpace(stream), true);
generator = new PEFileKeyGenerator(Tracer.Instance, peFile, moduleFilePath);
}
int moduleIndexSize,
IntPtr moduleIndex)
{
- try
+ if (_symbolService.IsSymbolStoreEnabled)
{
- KeyTypeFlags flags = specialKeys ? KeyTypeFlags.DacDbiKeys : KeyTypeFlags.IdentityKey;
- byte[] id = new byte[moduleIndexSize];
- Marshal.Copy(moduleIndex, id, 0, moduleIndexSize);
-
- IEnumerable<SymbolStoreKey> keys = null;
- switch (config)
+ try
{
- case RuntimeConfiguration.UnixCore:
- keys = ELFFileKeyGenerator.GetKeys(flags, moduleFilePath, id, symbolFile: false, symbolFileName: null);
- break;
+ KeyTypeFlags flags = specialKeys ? KeyTypeFlags.DacDbiKeys : KeyTypeFlags.IdentityKey;
+ byte[] id = new byte[moduleIndexSize];
+ Marshal.Copy(moduleIndex, id, 0, moduleIndexSize);
- case RuntimeConfiguration.OSXCore:
- keys = MachOFileKeyGenerator.GetKeys(flags, moduleFilePath, id, symbolFile: false, symbolFileName: null);
- break;
-
- case RuntimeConfiguration.WindowsCore:
- case RuntimeConfiguration.WindowsDesktop:
- uint timeStamp = BitConverter.ToUInt32(id, 0);
- uint fileSize = BitConverter.ToUInt32(id, 4);
- SymbolStoreKey key = PEFileKeyGenerator.GetKey(moduleFilePath, timeStamp, fileSize);
- keys = new SymbolStoreKey[] { key };
- break;
+ IEnumerable<SymbolStoreKey> keys = null;
+ switch (config)
+ {
+ case RuntimeConfiguration.UnixCore:
+ keys = ELFFileKeyGenerator.GetKeys(flags, moduleFilePath, id, symbolFile: false, symbolFileName: null);
+ break;
+
+ case RuntimeConfiguration.OSXCore:
+ keys = MachOFileKeyGenerator.GetKeys(flags, moduleFilePath, id, symbolFile: false, symbolFileName: null);
+ break;
+
+ case RuntimeConfiguration.WindowsCore:
+ case RuntimeConfiguration.WindowsDesktop:
+ uint timeStamp = BitConverter.ToUInt32(id, 0);
+ uint fileSize = BitConverter.ToUInt32(id, 4);
+ SymbolStoreKey key = PEFileKeyGenerator.GetKey(moduleFilePath, timeStamp, fileSize);
+ keys = new SymbolStoreKey[] { key };
+ break;
+
+ default:
+ Trace.TraceError("LoadNativeSymbolsFromIndex: unsupported platform {0}", config);
+ return;
+ }
+ foreach (SymbolStoreKey key in keys)
+ {
+ string moduleFileName = Path.GetFileName(key.FullPathName);
+ Trace.TraceInformation("{0} {1}", key.FullPathName, key.Index);
- default:
- Trace.TraceError("LoadNativeSymbolsFromIndex: unsupported platform {0}", config);
- return;
+ string downloadFilePath = _symbolService.DownloadFile(key);
+ if (downloadFilePath != null)
+ {
+ Trace.TraceInformation("{0}: {1}", moduleFileName, downloadFilePath);
+ callback(parameter, moduleFileName, downloadFilePath);
+ }
+ }
}
- foreach (SymbolStoreKey key in keys)
+ catch (Exception ex) when (ex is BadInputFormatException || ex is InvalidVirtualAddressException || ex is TaskCanceledException)
{
- string moduleFileName = Path.GetFileName(key.FullPathName);
- Trace.TraceInformation("{0} {1}", key.FullPathName, key.Index);
-
- string downloadFilePath = _symbolService.DownloadFile(key);
- if (downloadFilePath != null)
- {
- Trace.TraceInformation("{0}: {1}", moduleFileName, downloadFilePath);
- callback(parameter, moduleFileName, downloadFilePath);
- }
+ Trace.TraceError("{0} - {1}", ex.Message, moduleFilePath);
}
}
- catch (Exception ex) when (ex is BadInputFormatException || ex is InvalidVirtualAddressException || ex is TaskCanceledException)
- {
- Trace.TraceError("{0} - {1}", ex.Message, moduleFilePath);
- }
}
/// <summary>
<TargetPath>$(SymbolsDir)</TargetPath>
</ZipSymbolFiles>
- <ZipSymbolFiles Include="$(ArtifactsBinDir)Windows_NT.x64.$(Configuration)\sos.pdb">
+ <ZipSymbolFiles Include="$(ArtifactsBinDir)Windows_NT.x64.$(Configuration)\PDB\sos.pdb">
<TargetPath>$(SymbolsDir)\win-x64</TargetPath>
</ZipSymbolFiles>
- <ZipSymbolFiles Include="$(ArtifactsBinDir)Windows_NT.x86.$(Configuration)\sos.pdb">
+ <ZipSymbolFiles Include="$(ArtifactsBinDir)Windows_NT.x86.$(Configuration)\PDB\sos.pdb">
<TargetPath>$(SymbolsDir)\win-x86</TargetPath>
</ZipSymbolFiles>
- <ZipSymbolFiles Include="$(ArtifactsBinDir)Windows_NT.arm.$(Configuration)\sos.pdb">
+ <ZipSymbolFiles Include="$(ArtifactsBinDir)Windows_NT.arm.$(Configuration)\PDB\sos.pdb">
<TargetPath>$(SymbolsDir)\win-arm</TargetPath>
</ZipSymbolFiles>
- <ZipSymbolFiles Include="$(ArtifactsBinDir)Windows_NT.arm64.$(Configuration)\sos.pdb">
+ <ZipSymbolFiles Include="$(ArtifactsBinDir)Windows_NT.arm64.$(Configuration)\PDB\sos.pdb">
<TargetPath>$(SymbolsDir)\win-arm64</TargetPath>
</ZipSymbolFiles>
</ItemGroup>
<PackagePath>$(SOSPackagePathPrefix)</PackagePath>
</None>
- <None Include="$(ArtifactsBinDir)\Windows_NT.x64.$(Configuration)\sos.pdb" Pack="true" Visible="false">
+ <None Include="$(ArtifactsBinDir)\Windows_NT.x64.$(Configuration)\PDB\sos.pdb" Pack="true" Visible="false">
<PackagePath>$(SOSPackagePathPrefix)/win-x64</PackagePath>
</None>
- <None Include="$(ArtifactsBinDir)\Windows_NT.x86.$(Configuration)\sos.pdb" Pack="true" Visible="false">
+ <None Include="$(ArtifactsBinDir)\Windows_NT.x86.$(Configuration)\PDB\sos.pdb" Pack="true" Visible="false">
<PackagePath>$(SOSPackagePathPrefix)/win-x86</PackagePath>
</None>
- <None Include="$(ArtifactsBinDir)\Windows_NT.arm.$(Configuration)\sos.pdb" Pack="true" Visible="false">
+ <None Include="$(ArtifactsBinDir)\Windows_NT.arm.$(Configuration)\PDB\sos.pdb" Pack="true" Visible="false">
<PackagePath>$(SOSPackagePathPrefix)/win-arm</PackagePath>
</None>
- <None Include="$(ArtifactsBinDir)\Windows_NT.arm64.$(Configuration)\sos.pdb" Pack="true" Visible="false">
+ <None Include="$(ArtifactsBinDir)\Windows_NT.arm64.$(Configuration)\PDB\sos.pdb" Pack="true" Visible="false">
<PackagePath>$(SOSPackagePathPrefix)/win-arm64</PackagePath>
</None>
}
// Using the dotnet-dump analyze tool if the path exists in the config file.
- // TODO: dotnet-dump currently doesn't support macho core dumps that the MacOS createdump generates
- if (information.TestConfiguration.DotNetDumpPath() != null && OS.Kind != OSKind.OSX)
+ if (information.TestConfiguration.DotNetDumpPath() != null)
{
// Don't test dotnet-dump on triage dumps when running on desktop CLR.
if (information.TestConfiguration.IsNETCore || information.DumpType != SOSRunner.DumpType.Triage)
Assert.NotNull(parameters);
Assert.NotNull(parameters.ExceptionType);
Assert.NotNull(parameters.OSVersion);
- Assert.Equal(parameters.SystemManufacturer, "apple");
+ Assert.Equal("apple", (string)parameters.SystemManufacturer);
}
}
catch (Exception ex)
# For more information: http://www.cmake.org/Wiki/CMake_RPATH_handling.
if (CORECLR_SET_RPATH)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
- if(CLR_CMAKE_PLATFORM_DARWIN)
+ if(CLR_CMAKE_HOST_OSX)
set(CMAKE_INSTALL_RPATH "@loader_path")
else()
set(CMAKE_INSTALL_RPATH "\$ORIGIN")
- endif(CLR_CMAKE_PLATFORM_DARWIN)
+ endif(CLR_CMAKE_HOST_OSX)
endif (CORECLR_SET_RPATH)
-if(CLR_CMAKE_PLATFORM_ARCH_AMD64)
+if(CLR_CMAKE_HOST_ARCH_AMD64)
add_definitions(-DSOS_TARGET_AMD64=1)
add_definitions(-D_TARGET_WIN64_=1)
add_definitions(-DDBG_TARGET_64BIT)
remove_definitions(-D_TARGET_ARM64_=1)
add_definitions(-D_TARGET_AMD64_)
add_definitions(-DDBG_TARGET_AMD64)
-elseif(CLR_CMAKE_PLATFORM_ARCH_I386)
+elseif(CLR_CMAKE_HOST_ARCH_I386)
add_definitions(-DSOS_TARGET_X86=1)
add_definitions(-D_TARGET_X86_=1)
add_definitions(-DDBG_TARGET_32BIT)
if(WIN32)
add_definitions(-DSOS_TARGET_ARM=1)
endif(WIN32)
-elseif(CLR_CMAKE_PLATFORM_ARCH_ARM)
+elseif(CLR_CMAKE_HOST_ARCH_ARM)
add_definitions(-DSOS_TARGET_ARM=1)
add_definitions(-D_TARGET_WIN32_=1)
add_definitions(-D_TARGET_ARM_=1)
add_definitions(-DDBG_TARGET_32BIT)
-elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
+elseif(CLR_CMAKE_HOST_ARCH_ARM64)
add_definitions(-DSOS_TARGET_ARM64=1)
add_definitions(-D_TARGET_WIN64_=1)
add_definitions(-DDBG_TARGET_64BIT)
add_definitions(-DDBG_TARGET_WIN64=1)
-elseif(CLR_CMAKE_PLATFORM_ARCH_MIPS64)
+elseif(CLR_CMAKE_HOST_ARCH_MIPS64)
add_definitions(-DSOS_TARGET_MIPS64=1)
add_definitions(-D_TARGET_WIN64_=1)
add_definitions(-DDBG_TARGET_64BIT)
add_definitions(-DFX_VER_INTERNALNAME_STR=SOS.dll)
#Preprocess exports definition file
- preprocess_def_file(${CMAKE_CURRENT_SOURCE_DIR}/sos.def ${CMAKE_CURRENT_BINARY_DIR}/sos.def)
+ preprocess_file(${CMAKE_CURRENT_SOURCE_DIR}/sos.def ${CMAKE_CURRENT_BINARY_DIR}/sos.def)
list(APPEND SOS_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/sos.def)
set(SOS_LIBRARY
ntdll.lib
)
- if(NOT CLR_CMAKE_PLATFORM_ARCH_ARM64)
+ if(NOT CLR_CMAKE_HOST_ARCH_ARM64)
list(APPEND
SOS_LIBRARY
mscoree.lib)
- endif(NOT CLR_CMAKE_PLATFORM_ARCH_ARM64)
+ endif(NOT CLR_CMAKE_HOST_ARCH_ARM64)
else(WIN32)
add_definitions(-DFEATURE_ENABLE_HARDWARE_EXCEPTIONS)
endif(WIN32)
-if(CLR_CMAKE_PLATFORM_ARCH_AMD64)
+if(CLR_CMAKE_HOST_ARCH_AMD64)
set(SOS_SOURCES_ARCH
disasmX86.cpp
)
disasmARM64.cpp
)
endif(WIN32)
-elseif(CLR_CMAKE_PLATFORM_ARCH_I386)
+elseif(CLR_CMAKE_HOST_ARCH_I386)
set(SOS_SOURCES_ARCH
disasmX86.cpp
)
disasmARM.cpp
)
endif(WIN32)
-elseif(CLR_CMAKE_PLATFORM_ARCH_ARM)
+elseif(CLR_CMAKE_HOST_ARCH_ARM)
set(SOS_SOURCES_ARCH
disasmARM.cpp
)
-elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
+elseif(CLR_CMAKE_HOST_ARCH_ARM64)
set(SOS_SOURCES_ARCH
disasmARM64.cpp
)
list(APPEND SOS_SOURCES ${SOS_SOURCES_ARCH})
-if(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD OR CLR_CMAKE_PLATFORM_NETBSD)
+if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS)
# Add linker exports file option
set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE})
-endif(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD OR CLR_CMAKE_PLATFORM_NETBSD)
+endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS)
-if(CLR_CMAKE_PLATFORM_DARWIN)
+if(CLR_CMAKE_HOST_OSX)
# Add linker exports file option
set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE})
-endif(CLR_CMAKE_PLATFORM_DARWIN)
+endif(CLR_CMAKE_HOST_OSX)
add_library_clr(sos SHARED ${SOS_SOURCES})
-if(CLR_CMAKE_PLATFORM_UNIX)
+if(CLR_CMAKE_HOST_UNIX)
add_custom_target(sos_exports DEPENDS ${EXPORTS_FILE})
add_dependencies(sos sos_exports)
set_property(TARGET sos APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION})
set_property(TARGET sos APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE})
-endif(CLR_CMAKE_PLATFORM_UNIX)
+endif(CLR_CMAKE_HOST_UNIX)
target_link_libraries(sos ${SOS_LIBRARY})
# add the install targets
-install_clr(sos)
+install_clr(TARGETS sos DESTINATIONS .)
if(NOT WIN32)
install(FILES sosdocsunix.txt DESTINATION .)
}
}
-extern bool g_symbolStoreInitialized;
-
/**********************************************************************\
* Attempt to download the runtime modules (runtime, DAC and DBI)
\**********************************************************************/
void Runtime::LoadRuntimeModules()
{
HRESULT hr = InitializeSymbolService();
- if (SUCCEEDED(hr) && g_symbolStoreInitialized)
+ if (SUCCEEDED(hr))
{
if (m_runtimeInfo != nullptr)
{
IXCLRDataProcess* m_clrDataProcess;
ICorDebugProcess* m_pCorDebugProcess;
- Runtime::Runtime(ITarget* target, RuntimeConfiguration configuration, ULONG index, ULONG64 address, ULONG64 size, RuntimeInfo* runtimeInfo);
+ Runtime(ITarget* target, RuntimeConfiguration configuration, ULONG index, ULONG64 address, ULONG64 size, RuntimeInfo* runtimeInfo);
- virtual Runtime::~Runtime();
+ virtual ~Runtime();
void LoadRuntimeModules();
#define IfFailRet(EXPR) do { Status = (EXPR); if(FAILED(Status)) { return (Status); } } while (0)
#endif
-bool g_symbolStoreInitialized = false;
-
#ifndef FEATURE_PAL
HMODULE g_hmoduleSymBinder = nullptr;
ISymUnmanagedBinder3 *g_pSymBinder = nullptr;
\**********************************************************************/
HRESULT InitializeSymbolService()
{
- if (!g_symbolStoreInitialized)
+ static bool initialized = false;
+ if (!initialized)
{
ISymbolService* symbolService = GetSymbolService();
if (symbolService == nullptr) {
return E_NOINTERFACE;
}
- g_symbolStoreInitialized = symbolService->IsSymbolStoreEnabled();
+ initialized = true;
#ifndef FEATURE_PAL
- // When SOS is hosted on dotnet-dump, the ExtensionApis are not set so
+ // When SOS is hosted on dotnet-dump on Windows, the ExtensionApis are not set so
// the expression evaluation function needs to be supplied.
if (GetExpression == nullptr)
{
}
#endif
OnUnloadTask::Register([]() {
+ initialized = false;
DisableSymbolStore();
});
}
return E_FAIL;
}
}
- g_symbolStoreInitialized = true;
return S_OK;
}
\**********************************************************************/
HRESULT LoadNativeSymbols(bool runtimeOnly)
{
- if (g_symbolStoreInitialized)
+ ISymbolService* symbolService = GetSymbolService();
+ if (symbolService != nullptr)
{
- return g_ExtServices2->LoadNativeSymbols(runtimeOnly, LoadNativeSymbolsCallback);
+ if (symbolService->IsSymbolStoreEnabled())
+ {
+ return g_ExtServices2->LoadNativeSymbols(runtimeOnly, LoadNativeSymbolsCallback);
+ }
}
return E_FAIL;
}
\**********************************************************************/
void DisplaySymbolStore()
{
- if (g_symbolStoreInitialized)
+ ISymbolService* symbolService = GetSymbolService();
+ if (symbolService != nullptr)
{
- GetSymbolService()->DisplaySymbolStore([] (const char* message) {
+ symbolService->DisplaySymbolStore([] (const char* message) {
ExtOut(message);
ExtOut("\n");
});
\**********************************************************************/
void DisableSymbolStore()
{
- if (g_symbolStoreInitialized)
+ ISymbolService* symbolService = GetSymbolService();
+ if (symbolService != nullptr)
{
- g_symbolStoreInitialized = false;
- GetSymbolService()->DisableSymbolStore();
+ symbolService->DisableSymbolStore();
}
}
{
HRESULT Status = S_OK;
IfFailRet(InitializeSymbolService());
-
return GetSymbolService()->GetMetadataLocator(imagePath, imageTimestamp, imageSize, mvid, mdRva, flags, bufferSize, buffer, dataSize);
}
ExtOut("LoadSymbols GetClrModuleImages FAILED 0x%08x\n", hr);
return hr;
}
- if (!HasPortablePDB(moduleBase))
+ if (GetSymbolService() == nullptr || !HasPortablePDB(moduleBase))
{
hr = LoadSymbolsForWindowsPDB(pMD, moduleBase, pModuleName, FALSE);
if (SUCCEEDED(hr))
}
#ifndef FEATURE_PAL
- // TODO: in-memory windows PDB not supported
- if (!HasPortablePDB(moduleData.LoadedPEAddress))
+ if (GetSymbolService() == nullptr || !HasPortablePDB(moduleData.LoadedPEAddress))
{
+ // TODO: in-memory windows PDB not supported
hr = LoadSymbolsForWindowsPDB(pMD, moduleData.LoadedPEAddress, pModuleName, moduleData.IsFileLayout);
if (SUCCEEDED(hr))
{
dbgutil.cpp
)
-if(NOT DEFINED CLR_CMAKE_PLATFORM_DARWIN)
+if(NOT DEFINED CLR_CMAKE_HOST_OSX)
list(APPEND DBGUTIL_SOURCES
elfreader.cpp
)
-endif(NOT DEFINED CLR_CMAKE_PLATFORM_DARWIN)
+endif(NOT DEFINED CLR_CMAKE_HOST_OSX)
-if(CLR_CMAKE_PLATFORM_ALPINE_LINUX)
+if(CLR_CMAKE_HOST_ALPINE_LINUX)
add_definitions(-DTARGET_ALPINE_LINUX)
-endif(CLR_CMAKE_PLATFORM_ALPINE_LINUX)
+endif(CLR_CMAKE_HOST_ALPINE_LINUX)
-if(CLR_CMAKE_PLATFORM_UNIX)
+if(CLR_CMAKE_HOST_UNIX)
add_definitions(-DHOST_UNIX)
add_compile_options(-fPIC)
-else(CLR_CMAKE_PLATFORM_UNIX)
+else(CLR_CMAKE_HOST_UNIX)
add_definitions(-DHOST_WINDOWS)
-endif(CLR_CMAKE_PLATFORM_UNIX)
+endif(CLR_CMAKE_HOST_UNIX)
-_add_library(dbgutil STATIC ${DBGUTIL_SOURCES})
+add_library(dbgutil STATIC ${DBGUTIL_SOURCES})
add_definitions(-DHOST_IS_WINDOWS_OS)
endif(WIN32)
-if(CLR_CMAKE_PLATFORM_UNIX)
+if(CLR_CMAKE_HOST_UNIX)
add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
+endif(CLR_CMAKE_HOST_UNIX)
set(DEBUGSHIM_SOURCES
debugshim.cpp
)
-_add_library(debugshim STATIC ${DEBUGSHIM_SOURCES})
+add_library(debugshim STATIC ${DEBUGSHIM_SOURCES})
extensions.cpp
)
-if(WIN32 AND NOT CLR_CMAKE_PLATFORM_ARCH_ARM64)
+if(WIN32 AND NOT CLR_CMAKE_HOST_ARCH_ARM64)
list(APPEND SOURCES
hostdesktop.cpp
)
-endif(WIN32 AND NOT CLR_CMAKE_PLATFORM_ARCH_ARM64)
+endif(WIN32 AND NOT CLR_CMAKE_HOST_ARCH_ARM64)
-if(CLR_CMAKE_PLATFORM_UNIX)
+if(CLR_CMAKE_HOST_UNIX)
add_definitions(-DHOST_UNIX)
add_compile_options(-fPIC)
-else(CLR_CMAKE_PLATFORM_UNIX)
+else(CLR_CMAKE_HOST_UNIX)
add_definitions(-DHOST_WINDOWS)
-endif(CLR_CMAKE_PLATFORM_UNIX)
+endif(CLR_CMAKE_HOST_UNIX)
-_add_library(extensions STATIC ${SOURCES})
+add_library(extensions STATIC ${SOURCES})
# For more information: http://www.cmake.org/Wiki/CMake_RPATH_handling.
if (CORECLR_SET_RPATH)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
- if(CLR_CMAKE_PLATFORM_DARWIN)
+ if(CLR_CMAKE_HOST_OSX)
set(CMAKE_INSTALL_RPATH "@loader_path")
else()
set(CMAKE_INSTALL_RPATH "\$ORIGIN")
- endif(CLR_CMAKE_PLATFORM_DARWIN)
+ endif(CLR_CMAKE_HOST_OSX)
endif (CORECLR_SET_RPATH)
add_definitions(-DPAL_STDCPP_COMPAT)
-set(ENABLE_LLDBPLUGIN ${CLR_CMAKE_PLATFORM_UNIX} CACHE BOOL "Enable building the SOS plugin for LLDB.")
-set(REQUIRE_LLDBPLUGIN ${CLR_CMAKE_PLATFORM_LINUX} CACHE BOOL "Require building the SOS plugin for LLDB.")
+set(ENABLE_LLDBPLUGIN ${CLR_CMAKE_HOST_UNIX} CACHE BOOL "Enable building the SOS plugin for LLDB.")
+set(REQUIRE_LLDBPLUGIN ${CLR_CMAKE_HOST_LINUX} CACHE BOOL "Require building the SOS plugin for LLDB.")
if(SKIP_LLDBPLUGIN)
set(REQUIRE_LLDBPLUGIN false)
endif()
-if(CLR_CMAKE_PLATFORM_ARCH_AMD64)
+if(CLR_CMAKE_HOST_ARCH_AMD64)
add_definitions(-D_TARGET_AMD64_=1)
add_definitions(-DDBG_TARGET_64BIT=1)
add_definitions(-DDBG_TARGET_AMD64=1)
add_definitions(-DDBG_TARGET_WIN64=1)
add_definitions(-DBIT64)
-elseif(CLR_CMAKE_PLATFORM_ARCH_I386)
+elseif(CLR_CMAKE_HOST_ARCH_I386)
add_definitions(-D_TARGET_X86_=1)
add_definitions(-DDBG_TARGET_32BIT=1)
add_definitions(-DDBG_TARGET_X86=1)
-elseif(CLR_CMAKE_PLATFORM_ARCH_ARM)
+elseif(CLR_CMAKE_HOST_ARCH_ARM)
add_definitions(-D_TARGET_ARM_=1)
add_definitions(-DDBG_TARGET_32BIT=1)
add_definitions(-DDBG_TARGET_ARM=1)
-elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
+elseif(CLR_CMAKE_HOST_ARCH_ARM64)
add_definitions(-D_TARGET_ARM64_=1)
add_definitions(-DDBG_TARGET_64BIT=1)
add_definitions(-DDBG_TARGET_ARM64=1)
add_definitions(-DDBG_TARGET_WIN64=1)
add_definitions(-DBIT64)
SET(REQUIRE_LLDBPLUGIN false)
-elseif(CLR_CMAKE_PLATFORM_ARCH_MIPS64)
+elseif(CLR_CMAKE_HOST_ARCH_MIPS64)
add_definitions(-D_TARGET_MIPS64_=1)
add_definitions(-DDBG_TARGET_64BIT=1)
add_definitions(-DDBG_TARGET_MIPS64=1)
set(LLDB_LIB "$ENV{LLDB_LIB}")
else()
# Check for LLDB library
- if(CLR_CMAKE_PLATFORM_DARWIN)
+ if(CLR_CMAKE_HOST_OSX)
find_library(LLDB_LIB NAMES LLDB lldb lldb-6.0 lldb-5.0 lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATHS "${WITH_LLDB_LIBS}" PATH_SUFFIXES llvm NO_DEFAULT_PATH)
find_library(LLDB_LIB NAMES LLDB lldb lldb-6.0 lldb-5.0 lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATH_SUFFIXES llvm)
if(LLDB_LIB STREQUAL LLDB_LIB-NOTFOUND)
target_link_libraries(sosplugin ${LIBRARIES})
# add the install targets
-install_clr(sosplugin)
+install_clr(TARGETS sosplugin DESTINATIONS .)
#include <string.h>
#include <string>
#include <dlfcn.h>
+#if defined(__APPLE__)
+#include <mach-o/loader.h>
+#endif
#include "sosplugin.h"
#include "arrayholder.h"
ULONG64
LLDBServices::GetModuleSize(
+ ULONG64 baseAddress,
/* const */ lldb::SBModule& module)
{
ULONG64 size = 0;
-
+#if defined(__APPLE__)
+ mach_header_64 header;
+ ULONG read;
+ HRESULT hr = ReadVirtual(baseAddress, &header, sizeof(mach_header_64), &read) == S_OK;
+ if (SUCCEEDED(hr))
+ {
+ // Since MachO segments are not contiguous the image size is just the headers/commands
+ size = sizeof(mach_header_64) + header.sizeofcmds;
+ }
+#else
// Find the first section with an valid base address
int numSections = module.GetNumSections();
for (int si = 0; si < numSections; si++)
size += section.GetByteSize();
}
}
+#endif
// For core dumps lldb doesn't return the section sizes when it
// doesn't have access to the actual module file, but SOS (like
// the SymbolReader code) still needs a non-zero module size.
path.append("/");
path.append(filename);
- int moduleSize = GetModuleSize(module);
+ int moduleSize = GetModuleSize(moduleAddress, module);
callback(&module, path.c_str(), moduleAddress, moduleSize);
}
{
return E_INVALIDARG;
}
+ ULONG64 moduleBase = GetModuleBase(target, module);
if (pBase)
{
- ULONG64 moduleBase = GetModuleBase(target, module);
if (moduleBase == UINT64_MAX)
{
return E_INVALIDARG;
}
if (pSize)
{
- *pSize = GetModuleSize(module);
+ *pSize = GetModuleSize(moduleBase, module);
}
if (pTimestamp)
{
ULONG m_cacheSize;
ULONG64 GetModuleBase(lldb::SBTarget& target, lldb::SBModule& module);
- ULONG64 GetModuleSize(lldb::SBModule& module);
+ ULONG64 GetModuleSize(ULONG64 baseAddress, lldb::SBModule& module);
ULONG64 GetExpression(lldb::SBFrame& frame, lldb::SBError& error, PCSTR exp);
void GetContextFromFrame(lldb::SBFrame& frame, DT_CONTEXT *dtcontext);
DWORD_PTR GetRegister(lldb::SBFrame& frame, const char *name);
target_link_libraries(runcommand ${RUNCOMMAND_LIBRARY})
# add the install targets
-install_clr(runcommand)
+install_clr(TARGETS runcommand DESTINATIONS .)
<OutputType>Exe</OutputType>
<IsShipping>true</IsShipping>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
+ <!-- Tools always ship with stable versions to allow for seamless CLI upgrade experiences. -->
+ <PreReleaseVersionLabel></PreReleaseVersionLabel>
</PropertyGroup>
<Choose>
private string _metricsEventSourceSessionId;
private int _maxTimeSeries;
private int _maxHistograms;
+ private TimeSpan _duration;
class ProviderEventState
{
string diagnosticPort,
bool resumeRuntime,
int maxHistograms,
- int maxTimeSeries)
+ int maxTimeSeries,
+ TimeSpan duration)
{
try
{
_renderer = new ConsoleWriter(useAnsi);
_diagnosticsClient = holder.Client;
_resumeRuntime = resumeRuntime;
+ _duration = duration;
int ret = await Start();
ProcessLauncher.Launcher.Cleanup();
return ret;
string diagnosticPort,
bool resumeRuntime,
int maxHistograms,
- int maxTimeSeries)
+ int maxTimeSeries,
+ TimeSpan duration)
{
try
{
_maxTimeSeries = maxTimeSeries;
_output = output;
_diagnosticsClient = holder.Client;
+ _duration = duration;
if (_output.Length == 0)
{
_console.Error.WriteLine("Output cannot be an empty string");
});
monitorTask.Start();
+ var shouldStopAfterDuration = _duration != default(TimeSpan);
+ Stopwatch durationStopwatch = null;
+
+ if (shouldStopAfterDuration)
+ {
+ durationStopwatch = Stopwatch.StartNew();
+ }
while(!_shouldExit.Task.Wait(250))
{
_pauseCmdSet = false;
}
}
+
+ if (shouldStopAfterDuration && durationStopwatch.Elapsed >= _duration)
+ {
+ durationStopwatch.Stop();
+ break;
+ }
}
+
StopMonitor();
return _shouldExit.Task;
}
private string JsonEscape(string input)
{
+ if (input is null)
+ {
+ return string.Empty;
+ }
+
int offset = input.IndexOfAny(s_escapeChars);
if(offset == -1)
{
string port,
bool resumeRuntime,
int maxHistograms,
- int maxTimeSeries);
+ int maxTimeSeries,
+ TimeSpan duration);
delegate Task<int> MonitorDelegate(
CancellationToken ct,
List<string> counter_list,
string port,
bool resumeRuntime,
int maxHistograms,
- int maxTimeSeries);
+ int maxTimeSeries,
+ TimeSpan duration);
private static Command MonitorCommand() =>
new Command(
DiagnosticPortOption(),
ResumeRuntimeOption(),
MaxHistogramOption(),
- MaxTimeSeriesOption()
+ MaxTimeSeriesOption(),
+ DurationOption()
};
private static Command CollectCommand() =>
DiagnosticPortOption(),
ResumeRuntimeOption(),
MaxHistogramOption(),
- MaxTimeSeriesOption()
+ MaxTimeSeriesOption(),
+ DurationOption()
};
private static Option NameOption() =>
Argument = new Argument<int>(name: "maxTimeSeries", getDefaultValue: () => 1000)
};
+ private static Option DurationOption() =>
+ new Option(
+ alias: "--duration",
+ description: @"When specified, will run for the given timespan and then automatically stop. Provided in the form of dd:hh:mm:ss.")
+ {
+ Argument = new Argument<TimeSpan>(name: "duration-timespan", getDefaultValue: () => default)
+ };
+
private static readonly string[] s_SupportedRuntimeVersions = new[] { "3.0", "3.1", "5.0" };
public static int List(IConsole console, string runtimeVersion)
var currentColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
- Console.WriteLine("WARNING: dotnet-dsrouter is an experimental development tool not intended for production environments." + Environment.NewLine);
+ Console.WriteLine("WARNING: dotnet-dsrouter is a development tool not intended for production environments." + Environment.NewLine);
Console.ForegroundColor = currentColor;
var parser = new CommandLineBuilder()
<Description>.NET Performance Diagnostic Server Router Tool</Description>
<PackageTags>Diagnostic</PackageTags>
<PackageReleaseNotes>$(Description)</PackageReleaseNotes>
- <IsShipping>false</IsShipping>
</PropertyGroup>
<ItemGroup>
{
}
- public int Collect(IConsole console, int processId, string output, bool diag, DumpTypeOption type, string name)
+ public int Collect(IConsole console, int processId, string output, bool diag, bool crashreport, DumpTypeOption type, string name)
{
Console.WriteLine(name);
if (name != null)
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
+ if (crashreport)
+ {
+ Console.WriteLine("Crash reports not supported on Windows.");
+ return 0;
+ }
+
// Get the process
Process process = Process.GetProcessById(processId);
break;
}
+ WriteDumpFlags flags = WriteDumpFlags.None;
+ if (diag)
+ {
+ flags |= WriteDumpFlags.LoggingEnabled;
+ }
+ if (crashreport)
+ {
+ flags |= WriteDumpFlags.CrashReportEnabled;
+ }
// Send the command to the runtime to initiate the core dump
- client.WriteDump(dumpType, output, diag);
+ client.WriteDump(dumpType, output, flags);
}
}
catch (Exception ex) when
new Command( name: "collect", description: "Capture dumps from a process")
{
// Handler
- CommandHandler.Create<IConsole, int, string, bool, Dumper.DumpTypeOption, string>(new Dumper().Collect),
+ CommandHandler.Create<IConsole, int, string, bool, bool, Dumper.DumpTypeOption, string>(new Dumper().Collect),
// Options
- ProcessIdOption(), OutputOption(), DiagnosticLoggingOption(), TypeOption(), ProcessNameOption()
+ ProcessIdOption(), OutputOption(), DiagnosticLoggingOption(), CrashReportOption(), TypeOption(), ProcessNameOption()
};
private static Option ProcessIdOption() =>
Argument = new Argument<bool>(name: "diag")
};
+ private static Option CrashReportOption() =>
+ new Option(
+ alias: "--crashreport",
+ description: "Enable crash report generation.")
+ {
+ Argument = new Argument<bool>(name: "crashreport")
+ };
+
private static Option TypeOption() =>
new Option(
alias: "--type",
}
curIdx += 1;
}
- AddKeyValueToArgumentDict(argumentDict, argument, keyStart, keyEnd, valStart, valEnd);
+ if(valStart > valEnd)
+ {
+ valEnd = curIdx;
+ }
+ if (keyStart < keyEnd)
+ {
+ AddKeyValueToArgumentDict(argumentDict, argument, keyStart, keyEnd, valStart, valEnd);
+ }
return argumentDict;
}
private static void AddKeyValueToArgumentDict(Dictionary<string, string> argumentDict, string argument, int keyStart, int keyEnd, int valStart, int valEnd)
{
string key = argument.Substring(keyStart, keyEnd - keyStart);
- string val = argument.Substring(valStart);
+ string val = argument.Substring(valStart, valEnd - valStart);
if (val.StartsWith("\"") && val.EndsWith("\""))
{
val = val.Substring(1, val.Length - 2);
-if(CLR_CMAKE_PLATFORM_UNIX)
+if(CLR_CMAKE_HOST_UNIX)
include_directories(${ROOT_DIR}/src/pal/inc)
include_directories(${ROOT_DIR}/src/pal/inc/rt)
-endif(CLR_CMAKE_PLATFORM_UNIX)
+endif(CLR_CMAKE_HOST_UNIX)
set( CORGUIDS_IDL_SOURCES
cordebug.idl
endif(FEATURE_JIT_PITCHING)
# Compile *_i.cpp to lib
-_add_library(corguids ${CORGUIDS_SOURCES})
+add_library(corguids ${CORGUIDS_SOURCES})
#ifndef PAL_STDCPP_COMPAT
-#if _WIN64 || _MSC_VER >= 1400
typedef __int64 time_t;
-#else
-typedef long time_t;
-#endif
#define _TIME_T_DEFINED
#endif // !PAL_STDCPP_COMPAT
message(FATAL_ERROR "Only AMD64, I386 host for cross-architecture component is supported")
endif()
else()
- if(CLR_CMAKE_PLATFORM_ARCH_AMD64)
+ if(CLR_CMAKE_HOST_ARCH_AMD64)
set(PAL_CMAKE_PLATFORM_ARCH_AMD64 1)
- elseif(CLR_CMAKE_PLATFORM_ARCH_ARM)
+ elseif(CLR_CMAKE_HOST_ARCH_ARM)
set(PAL_CMAKE_PLATFORM_ARCH_ARM 1)
- elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
+ elseif(CLR_CMAKE_HOST_ARCH_ARM64)
set(PAL_CMAKE_PLATFORM_ARCH_ARM64 1)
- elseif(CLR_CMAKE_PLATFORM_ARCH_I386)
+ elseif(CLR_CMAKE_HOST_ARCH_I386)
set(PAL_CMAKE_PLATFORM_ARCH_I386 1)
- elseif(CLR_CMAKE_PLATFORM_ARCH_MIPS64)
+ elseif(CLR_CMAKE_HOST_ARCH_MIPS64)
set(PAL_CMAKE_PLATFORM_ARCH_MIPS64 1)
else()
message(FATAL_ERROR "Only ARM, AMD64, ARM64, MIPS64 and I386 is supported")
)
endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
-if(PAL_CMAKE_PLATFORM_ARCH_AMD64 AND CMAKE_SYSTEM_NAME STREQUAL Linux AND NOT CLR_CMAKE_PLATFORM_ALPINE_LINUX)
+if(PAL_CMAKE_PLATFORM_ARCH_AMD64 AND CMAKE_SYSTEM_NAME STREQUAL Linux AND NOT CLR_CMAKE_HOST_ALPINE_LINUX)
# Currently the _xstate is not available on Alpine Linux
add_definitions(-DXSTATE_SUPPORTED)
-endif(PAL_CMAKE_PLATFORM_ARCH_AMD64 AND CMAKE_SYSTEM_NAME STREQUAL Linux AND NOT CLR_CMAKE_PLATFORM_ALPINE_LINUX)
+endif(PAL_CMAKE_PLATFORM_ARCH_AMD64 AND CMAKE_SYSTEM_NAME STREQUAL Linux AND NOT CLR_CMAKE_HOST_ALPINE_LINUX)
-if(CLR_CMAKE_PLATFORM_ALPINE_LINUX)
+if(CLR_CMAKE_HOST_ALPINE_LINUX)
# Setting RLIMIT_NOFILE breaks debugging of coreclr on Alpine Linux for some reason
add_definitions(-DDONT_SET_RLIMIT_NOFILE)
# On Alpine Linux, we need to ensure that the reported stack range for the primary thread is
# larger than the initial committed stack size.
add_definitions(-DENSURE_PRIMARY_STACK_SIZE)
-endif(CLR_CMAKE_PLATFORM_ALPINE_LINUX)
+endif(CLR_CMAKE_HOST_ALPINE_LINUX)
# turn off capability to remove unused functions (which was enabled in debug build with sanitizers)
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,--no-gc-sections")
thread/thread.cpp
)
-_add_library(coreclrpal
+add_library(coreclrpal
STATIC
${SOURCES}
${ARCH_SOURCES}
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
# On Android, we don't need to link with gcc_s, pthread and rt
- if(NOT CLR_CMAKE_PLATFORM_ANDROID)
+ if(NOT CLR_CMAKE_HOST_ANDROID)
target_link_libraries(coreclrpal
gcc_s
pthread
)
endif()
- if(CLR_CMAKE_PLATFORM_ANDROID)
+ if(CLR_CMAKE_HOST_ANDROID)
find_library(LZMA NAMES lzma)
if(LZMA STREQUAL LZMA-NOTFOUND)
}" HAVE_FULLY_FEATURED_PTHREAD_MUTEXES)
set(CMAKE_REQUIRED_LIBRARIES)
-if(NOT CLR_CMAKE_PLATFORM_ARCH_ARM AND NOT CLR_CMAKE_PLATFORM_ARCH_ARM64)
+if(NOT CLR_CMAKE_HOST_ARCH_ARM AND NOT CLR_CMAKE_HOST_ARCH_ARM64)
set(CMAKE_REQUIRED_LIBRARIES pthread)
check_cxx_source_runs("
// This test case verifies the pthread process-shared robust mutex's cross-process abandon detection. The parent process starts
PERF_ENTRY(time);
ENTRY( "time( tloc=%p )\n",tloc );
- result = time(tloc);
+ time_t t;
+ result = time(&t);
+ if (tloc != NULL)
+ {
+ *tloc = t;
+ }
LOGEXIT( "time returning %#lx\n",result );
PERF_EXIT(time);
variant.cpp
)
-_add_library(palrt
+add_library(palrt
STATIC
${PALRT_SOURCES}
)
[SkippableTheory, MemberData(nameof(GetConfigurations))]
public void ModuleTests(TestHost host)
{
+ if (OS.Kind == OSKind.Windows)
+ {
+ throw new SkipTestException("Test unstable on Windows. Issue: https://github.com/dotnet/diagnostics/issues/2709");
+ }
var moduleService = host.Target.Services.GetService<IModuleService>();
Assert.NotNull(moduleService);
[SkippableTheory, MemberData(nameof(GetConfigurations))]
public void RuntimeTests(TestHost host)
{
+ if (OS.Kind == OSKind.Windows)
+ {
+ throw new SkipTestException("Test unstable on Windows. Issue: https://github.com/dotnet/diagnostics/issues/2709");
+ }
// The current Linux test assets are not alpine/musl
if (OS.IsAlpine)
{
/// <param name="result">resulting object</param>
public static void GetValue(Type type, string valueString, ref object result)
{
+ valueString = valueString.Trim();
if (type == typeof(string))
{
result = valueString ?? "";
if (nullableType != null && memberValue == null)
{
- memberValue = "";
+ memberValue = string.Empty;
}
else if (memberType == typeof(string))
{
- memberValue ??= "";
+ memberValue ??= string.Empty;
}
else if (memberValue is ImmutableArray<byte> buildId)
{
memberType = typeof(string);
- memberValue = !buildId.IsDefaultOrEmpty ? string.Concat(buildId.Select((b) => b.ToString("x2"))) : "";
+ memberValue = !buildId.IsDefaultOrEmpty ? string.Concat(buildId.Select((b) => b.ToString("x2"))) : string.Empty;
}
else if (!memberType.IsPrimitive && !memberType.IsEnum)
{
memberType = typeof(string);
- memberValue = memberValue?.ToString() ?? "";
+ memberValue = memberValue?.ToString() ?? string.Empty;
}
object testDataValue = testData.Value.GetValue(memberType);
- Trace.TraceInformation($"CompareMembers {testData.Key}: {memberValue} == {testDataValue}");
+ Trace.TraceInformation($"CompareMembers {testData.Key}: '{memberValue}' == '{testDataValue}'");
Assert.Equal(memberValue, testDataValue);
}
}
Assert.True(providerThree.Arguments["FilterAndPayloadSpecs"] == "QuotedValue:-\r\nQuoted/Value:-A=B;C=D;");
}
+ [Fact]
+ public void ProvidersWithComplexFilters_CorrectlyParse()
+ {
+ string providersToParse = @"MyProvider:::A=B;C=D";
+ List<EventPipeProvider> parsedProviders = Extensions.ToProviders(providersToParse);
+ Assert.Single(parsedProviders);
+ EventPipeProvider providerOne = parsedProviders[0];
+ Assert.Equal("MyProvider", providerOne.Name);
+ Assert.Equal(2, providerOne.Arguments.Count);
+ Assert.Equal("B", providerOne.Arguments["A"]);
+ Assert.Equal("D", providerOne.Arguments["C"]);
+
+ providersToParse = @"MyProvider:::A=B;C=""D"",MyProvider2:::A=1;B=2;";
+ parsedProviders = Extensions.ToProviders(providersToParse);
+ Assert.Equal(2, parsedProviders.Count);
+ providerOne = parsedProviders[0];
+ EventPipeProvider providerTwo = parsedProviders[1];
+ Assert.Equal("MyProvider", providerOne.Name);
+ Assert.Equal("MyProvider2", providerTwo.Name);
+ Assert.Equal(2, providerOne.Arguments.Count);
+ Assert.Equal("B", providerOne.Arguments["A"]);
+ Assert.Equal("D", providerOne.Arguments["C"]);
+ Assert.Equal(2, providerTwo.Arguments.Count);
+ Assert.Equal("1", providerTwo.Arguments["A"]);
+ Assert.Equal("2", providerTwo.Arguments["B"]);
+
+ providersToParse = @"MyProvider:::A=""B;C=D"",MyProvider2:::A=""spaced words"";C=1285;D=Spaced Words 2";
+ parsedProviders = Extensions.ToProviders(providersToParse);
+ Assert.Equal(2, parsedProviders.Count);
+ providerOne = parsedProviders[0];
+ providerTwo = parsedProviders[1];
+ Assert.Equal("MyProvider", providerOne.Name);
+ Assert.Equal("MyProvider2", providerTwo.Name);
+ Assert.Equal(1, providerOne.Arguments.Count);
+ Assert.Equal(3, providerTwo.Arguments.Count);
+ Assert.Equal("B;C=D", providerOne.Arguments["A"]);
+ Assert.Equal("spaced words", providerTwo.Arguments["A"]);
+ Assert.Equal("Spaced Words 2", providerTwo.Arguments["D"]);
+ Assert.Equal("1285", providerTwo.Arguments["C"]);
+ }
+
[Theory]
[InlineData("ProviderOne:0x1:Verbose")]
[InlineData("ProviderOne:0x1:verbose")]