summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Robinson <arobins@microsoft.com>2018-08-16 11:21:51 -0700
committerGitHub <noreply@github.com>2018-08-16 11:21:51 -0700
commitf0f42d4c0fc3cfd782b89171840e2590604392cd (patch)
treec89ed0ffe7ba540d952cefd89f267e1912aedecf
parent72e9b8d589f114776e3f42058d721058b77133b9 (diff)
downloadcoreclr-f0f42d4c0fc3cfd782b89171840e2590604392cd.tar.gz
coreclr-f0f42d4c0fc3cfd782b89171840e2590604392cd.tar.bz2
coreclr-f0f42d4c0fc3cfd782b89171840e2590604392cd.zip
Build-test.sh handles native test assets (#19430)
* Respect Windows script argument to skip package building. * Bring build.sh logic closer to build.cmd with respect to passing CMAKE flags for building tests * Make cmake gen script find override file without using script arguments * build-test.sh can now build native test projects Remove compileoptions.cmake and push contents into configurecompiler.cmake which contains compiler configuration from repo root CMakeLists.txt
-rw-r--r--CMakeLists.txt413
-rwxr-xr-xbuild-test.sh185
-rwxr-xr-xbuild.sh21
-rw-r--r--compileoptions.cmake146
-rw-r--r--configurecompiler.cmake554
-rwxr-xr-xsrc/pal/tools/gen-buildsys-clang.sh10
-rw-r--r--tests/CMakeLists.txt12
-rw-r--r--tests/src/Interop/CMakeLists.txt10
-rw-r--r--tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.cpp2
-rw-r--r--tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.h16
-rw-r--r--tests/src/JIT/Directed/StructABI/CMakeLists.txt6
11 files changed, 736 insertions, 639 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a39d1aef36..82c19a9cba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -143,415 +143,10 @@ else (WIN32)
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 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)
- set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
- 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(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)
- 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}")
-
- # 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
-#
-# For example:
-# ./build-native.sh cmakeargs "-DCLR_ADDITIONAL_COMPILER_OPTIONS=<...>" cmakeargs "-DCLR_ADDITIONAL_LINKER_FLAGS=<...>"
-#
-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)
- add_definitions(-D_AMD64_)
- add_definitions(-D_WIN64)
- add_definitions(-DAMD64)
- add_definitions(-DBIT64=1)
-elseif (CLR_CMAKE_PLATFORM_ARCH_I386)
- add_definitions(-D_X86_)
-elseif (CLR_CMAKE_PLATFORM_ARCH_ARM)
- add_definitions(-D_ARM_)
- add_definitions(-DARM)
-elseif (CLR_CMAKE_PLATFORM_ARCH_ARM64)
- add_definitions(-D_ARM64_)
- add_definitions(-DARM64)
- add_definitions(-D_WIN64)
- add_definitions(-DBIT64=1)
-else ()
- 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)
- 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)
-else ()
- clr_unknown_arch()
-endif ()
-
-#--------------------------------------
-# Compile Options
-#--------------------------------------
-include(compileoptions.cmake)
+#----------------------------------------------------
+# Configure compiler settings for environment
+#----------------------------------------------------
+include(configurecompiler.cmake)
#----------------------------------------------------
# Cross target Component build specific configuration
diff --git a/build-test.sh b/build-test.sh
index b661ebaef9..1c4797d487 100755
--- a/build-test.sh
+++ b/build-test.sh
@@ -152,7 +152,7 @@ generate_layout()
# ===
# =========================================================================================
- build_Tests_internal "Restore_Packages" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
+ build_MSBuild_projects "Restore_Packages" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
if [ -n "$__UpdateInvalidPackagesArg" ]; then
__up=-updateinvalidpackageversion
@@ -172,7 +172,7 @@ generate_layout()
mkdir -p $CORE_ROOT
- build_Tests_internal "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "Creating test overlay" "-testOverlay"
+ build_MSBuild_projects "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "Creating test overlay" "-testOverlay"
chmod +x $__BinDir/corerun
chmod +x $__BinDir/crossgen
@@ -193,7 +193,7 @@ generate_testhost()
echo "${__MsgPrefix}Creating test overlay..."
mkdir -p $TEST_HOST
- build_Tests_internal "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "-testHost"
+ build_MSBuild_projects "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "-testHost"
}
@@ -210,16 +210,27 @@ build_Tests()
fi
fi
- __CMakeBinDir="${__TestBinDir}"
+ export __CMakeBinDir="${__TestBinDir}"
+ if [ ! -d "${__TestIntermediatesDir}" ]; then
+ mkdir -p ${__TestIntermediatesDir}
+ fi
- if [ -z "$__TestIntermediateDir" ]; then
- __TestIntermediateDir="tests/obj/${__BuildOS}.${__BuildArch}.${__BuildType}"
+ __NativeTestIntermediatesDir="${__TestIntermediatesDir}/Native"
+ if [ ! -d "${__NativeTestIntermediatesDir}" ]; then
+ mkdir -p ${__NativeTestIntermediatesDir}
+ fi
+
+ __ManagedTestIntermediatesDir="${__TestIntermediatesDir}/Managed"
+ if [ ! -d "${__ManagedTestIntermediatesDir}" ]; then
+ mkdir -p ${__ManagedTestIntermediatesDir}
fi
echo "__BuildOS: ${__BuildOS}"
echo "__BuildArch: ${__BuildArch}"
echo "__BuildType: ${__BuildType}"
- echo "__TestIntermediateDir: ${__TestIntermediateDir}"
+ echo "__TestIntermediatesDir: ${__TestIntermediatesDir}"
+ echo "__NativeTestIntermediatesDir: ${__NativeTestIntermediatesDir}"
+ echo "__ManagedTestIntermediatesDir: ${__ManagedTestIntermediatesDir}"
if [ ! -f "$__TestBinDir" ]; then
echo "Creating TestBinDir: ${__TestBinDir}"
@@ -238,15 +249,26 @@ build_Tests()
# ===
# =========================================================================================
- build_Tests_internal "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
+ if [ ${__SkipRestorePackages} != 1 ]; then
+ build_MSBuild_projects "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
+ fi
if [ -n "$__BuildAgainstPackagesArg" ]; then
- build_Tests_internal "Tests_GenerateRuntimeLayout" "${__ProjectDir}/tests/runtest.proj" "Restore product binaries (run tests)" "-BinPlaceRef" "-BinPlaceProduct" "-CopyCrossgenToProduct"
+ build_MSBuild_projects "Tests_GenerateRuntimeLayout" "${__ProjectDir}/tests/runtest.proj" "Restore product binaries (run tests)" "-BinPlaceRef" "-BinPlaceProduct" "-CopyCrossgenToProduct"
+ fi
+
+ if [ $__SkipNative != 1 ]; then
+ build_native_projects "$__BuildArch" "${__NativeTestIntermediatesDir}"
+
+ if [ $? -ne 0 ]; then
+ echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
+ exit 1
+ fi
fi
echo "Starting the Managed Tests Build..."
- build_Tests_internal "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up"
+ build_MSBuild_projects "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up"
if [ $? -ne 0 ]; then
echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
@@ -254,12 +276,7 @@ build_Tests()
else
echo "Checking the Managed Tests Build..."
- if [ -n __priority1 ]; then
- __Priority=1
- else
- __Priority=0
- fi
- build_Tests_internal "Check_Test_Build" "${__ProjectDir}/tests/runtest.proj" "Check Test Build" "/t:CheckTestBuild /p:CLRTestPriorityToBuild=$__Priority"
+ build_MSBuild_projects "Check_Test_Build" "${__ProjectDir}/tests/runtest.proj" "Check Test Build" "-ExtraParameters:/t:CheckTestBuild"
if [ $? -ne 0 ]; then
echo "${__MsgPrefix}Error: Check Test Build failed."
@@ -276,7 +293,7 @@ build_Tests()
if [ ! -f $__XUnitWrapperBuiltMarker ]; then
- build_Tests_internal "Tests_XunitWrapper" "$__ProjectDir/tests/runtest.proj" "Test Xunit Wrapper" "-BuildWrappers" "-MsBuildEventLogging= " "-TargetsWindows=false"
+ build_MSBuild_projects "Tests_XunitWrapper" "$__ProjectDir/tests/runtest.proj" "Test Xunit Wrapper" "-BuildWrappers" "-MsBuildEventLogging= " "-TargetsWindows=false"
if [ $? -ne 0 ]; then
echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
@@ -301,11 +318,11 @@ build_Tests()
if [ $__ZipTests -ne 0 ]; then
echo "${__MsgPrefix}ZIP tests packages..."
- build_Tests_internal "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" "Prep test binaries for Helix publishing" " "
+ build_MSBuild_projects "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" "Prep test binaries for Helix publishing" " "
fi
}
-build_Tests_internal()
+build_MSBuild_projects()
{
subDirectoryName=$1
shift
@@ -404,6 +421,80 @@ build_Tests_internal()
fi
}
+build_native_projects()
+{
+ platformArch="$1"
+ intermediatesForBuild="$2"
+
+ extraCmakeArguments="-DCLR_CMAKE_TARGET_OS=${__BuildOS} -DCLR_CMAKE_HOST_ARCH=${platformArch}"
+ message="native tests assets"
+
+ # All set to commence the build
+ echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
+
+ generator=""
+ buildFile="Makefile"
+ buildTool="make"
+ if [ $__UseNinja == 1 ]; then
+ generator="ninja"
+ buildFile="build.ninja"
+ if ! buildTool=$(command -v ninja || command -v ninja-build); then
+ echo "Unable to locate ninja!" 1>&2
+ exit 1
+ fi
+ fi
+
+ if [ $__SkipConfigure == 0 ]; then
+ # if msbuild is not supported, then set __SkipGenerateVersion to 1
+ if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
+ # Drop version.cpp file
+ __versionSourceFile="$intermediatesForBuild/version.cpp"
+ if [ $__SkipGenerateVersion == 0 ]; then
+ pwd
+ "$__ProjectRoot/run.sh" build -Project=$__ProjectDir/build.proj -generateHeaderUnix -NativeVersionSourceFile=$__versionSourceFile -MsBuildEventLogging="/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log" $__RunArgs $__UnprocessedBuildArgs
+ else
+ # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
+ __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
+ if [ -e $__versionSourceFile ]; then
+ read existingVersionSourceLine < $__versionSourceFile
+ fi
+ if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
+ echo $__versionSourceLine > $__versionSourceFile
+ fi
+ fi
+
+ pushd "$intermediatesForBuild"
+ # Regenerate the CMake solution
+ echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__TestDir\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
+ "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__TestDir" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $generator "$extraCmakeArguments" "$__cmakeargs"
+ popd
+ fi
+
+ if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
+ echo "Failed to generate $message build project!"
+ exit 1
+ fi
+
+ # Build
+ if [ $__ConfigureOnly == 1 ]; then
+ echo "Finish configuration & skipping $message build."
+ return
+ fi
+
+ pushd "$intermediatesForBuild"
+
+ echo "Executing $buildTool install -j $__NumProc"
+
+ $buildTool install -j $__NumProc
+ if [ $? != 0 ]; then
+ echo "Failed to build $message."
+ exit 1
+ fi
+
+ popd
+ echo "Native tests build success!"
+}
+
usage()
{
echo "Usage: $0 [BuildArch] [BuildType] [verbose] [coverage] [cross] [clangx.y] [ninja] [runtests] [bindir]"
@@ -420,9 +511,11 @@ usage()
echo "portablebuild - Use portable build."
echo "verbose - optional argument to enable verbose build output."
echo "rebuild - if tests have already been built - rebuild them"
+ echo "skipnative: skip the native tests build"
echo "generatelayoutonly - only pull down dependencies and build coreroot"
echo "generatetesthostonly - only pull down dependencies and build coreroot and the CoreFX testhost"
echo "buildagainstpackages - pull down and build using packages."
+ echo "skiprestorepackages - skip package restore"
echo "runtests - run tests after building them"
echo "ziptests - zips CoreCLR tests & Core_Root for a Helix run"
echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
@@ -435,8 +528,6 @@ usage()
# Obtain the location of the bash script to figure out where the root of the repo is.
__ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-# $__ProjectRoot/build.sh $1 $2
-
# Use uname to determine what the CPU is.
CPUName=$(uname -p)
@@ -531,12 +622,17 @@ __MSBCleanBuildArgs=
__UseNinja=0
__VerboseBuild=0
__SkipRestore=""
+__SkipNative=1 # [REMOVE] Temporarily default to skip native
+__SkipConfigure=0
+__SkipGenerateVersion=0
+__ConfigureOnly=0
__CrossBuild=0
__ClangMajorVersion=0
__ClangMinorVersion=0
__NuGetPath="$__PackagesDir/NuGet.exe"
__HostDistroRid=""
__BuildAgainstPackagesArg=
+__SkipRestorePackages=0
__DistroRid=""
__cmakeargs=""
__PortableLinux=0
@@ -672,6 +768,15 @@ while :; do
__RebuildTests=1
;;
+ skipnative|-skipnative)
+ __SkipNative=1
+ ;;
+
+ # [REMOVE] Enable native build - the temporary default is to skip native
+ --skipnative)
+ __SkipNative=0
+ ;;
+
ziptests)
__ZipTests=1
;;
@@ -685,6 +790,9 @@ while :; do
buildagainstpackages)
__BuildAgainstPackagesArg=1
;;
+ skiprestorepackages)
+ __SkipRestorePackages=1
+ ;;
bindir)
if [ -n "$2" ]; then
@@ -717,6 +825,18 @@ while :; do
shift
done
+# 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.
+if [ `uname` = "FreeBSD" ]; then
+ __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
+elif [ `uname` = "NetBSD" ]; then
+ __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
+elif [ `uname` = "Darwin" ]; then
+ __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
+else
+ __NumProc=$(nproc --all)
+fi
__RunArgs=("-BuildArch=$__BuildArch" "-BuildType=$__BuildType" "-BuildOS=$__BuildOS")
@@ -737,7 +857,6 @@ if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
fi
fi
-
# Set dependent variables
__LogsDir="$__RootBinDir/Logs"
@@ -778,25 +897,6 @@ if [ -z "$HOME" ]; then
echo "HOME not defined; setting it to $HOME"
fi
-# Specify path to be set for CMAKE_INSTALL_PREFIX.
-# This is where all built CoreClr libraries will copied to.
-export __CMakeBinDir="$__BinDir"
-if [ [ ! -d "$__BinDir" ] || [ ! -d "$__BinDir/bin" ] ]; then
- if [ [ -z "$__GenerateLayoutOnly" ] && [ -z "$__GenerateTestHostOnly" ] ]; then
-
- echo "Cannot find build directory for the CoreCLR native tests."
- echo "Please make sure native tests are built before building managed tests."
- echo "Example use: './build.sh $__BuildArch $__BuildType' without -skiptests switch"
- else
- echo "Cannot find build directory for the CoreCLR Product."
- echo "Please make sure CoreCLR and native tests are built before building managed tests."
- echo "Example use: './build.sh $__BuildArch $__BuildType' "
- fi
- exit 1
-fi
-
-
-
# Configure environment if we are doing a cross compile.
if [ $__CrossBuild == 1 ]; then
export CROSSCOMPILE=1
@@ -813,7 +913,6 @@ initTargetDistroRid
__CoreClrVersion=1.1.0
__sharedFxDir=$__BuildToolsDir/dotnetcli/shared/Microsoft.NETCore.App/$__CoreClrVersion/
-
if [[ (-z "$__GenerateLayoutOnly") && (-z "$__GenerateTestHostOnly") ]]; then
echo "Building Tests..."
build_Tests
@@ -821,7 +920,7 @@ else
echo "Generating test layout..."
generate_layout
if [ ! -z "$__GenerateTestHostOnly" ]; then
- echo "Generating test host..."
+ echo "Generating test host..."
generate_testhost
fi
fi
diff --git a/build.sh b/build.sh
index bf349a882e..d66c9c6b03 100755
--- a/build.sh
+++ b/build.sh
@@ -306,8 +306,8 @@ build_native()
pushd "$intermediatesForBuild"
# Regenerate the CMake solution
- echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator $extraCmakeArguments $__cmakeargs"
- "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator "$extraCmakeArguments" "$__cmakeargs"
+ echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
+ "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $generator "$extraCmakeArguments" "$__cmakeargs"
popd
fi
@@ -359,7 +359,6 @@ build_cross_arch_component()
export __CMakeBinDir="$__CrossComponentBinDir"
export CROSSCOMPONENT=1
- __IncludeTests=
if [ $CROSSCOMPILE == 1 ]; then
TARGET_ROOTFS="$ROOTFS_DIR"
@@ -619,7 +618,6 @@ esac
__BuildType=Debug
__CodeCoverage=
-__IncludeTests=Include_Tests
__IgnoreWarnings=0
# Set the various build properties here so that CMake and MSBuild can pick them up
@@ -644,6 +642,7 @@ __SkipCoreCLR=0
__SkipMSCorLib=0
__SkipRestoreOptData=0
__SkipCrossgen=0
+__SkipTests=0
__CrossBuild=0
__ClangMajorVersion=0
__ClangMinorVersion=0
@@ -837,14 +836,11 @@ while :; do
__SkipCrossgen=1
;;
- includetests|-includetests)
- ;;
-
skiptests|-skiptests)
- __IncludeTests=
+ __SkipTests=1
;;
- skipnuget|-skipnuget)
+ skipnuget|-skipnuget|skipbuildpackages|-skipbuildpackages)
__SkipNuget=1
;;
@@ -1009,6 +1005,13 @@ generate_event_logging
# Build the coreclr (native) components.
__ExtraCmakeArgs="-DCLR_CMAKE_TARGET_OS=$__BuildOS -DCLR_CMAKE_PACKAGES_DIR=$__PackagesDir -DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_VERSION=$__PgoOptDataVersion -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize"
+
+# [TODO] Remove this when the `build-test.sh` script properly builds and deploys test assets.
+if [ $__SkipTests != 1 ]; then
+ echo "Adding CMake flags to build native tests for $__BuildOS.$__BuildArch.$__BuildType"
+ __ExtraCmakeArgs="$__ExtraCmakeArgs -DCLR_CMAKE_BUILD_TESTS=ON"
+fi
+
build_native $__SkipCoreCLR "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs" "CoreCLR component"
# Build cross-architecture components
diff --git a/compileoptions.cmake b/compileoptions.cmake
deleted file mode 100644
index a6047d9190..0000000000
--- a/compileoptions.cmake
+++ /dev/null
@@ -1,146 +0,0 @@
-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)
- 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 (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)
diff --git a/configurecompiler.cmake b/configurecompiler.cmake
new file mode 100644
index 0000000000..cd738882e7
--- /dev/null
+++ b/configurecompiler.cmake
@@ -0,0 +1,554 @@
+#----------------------------------------
+# 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 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)
+ set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
+ 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(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)
+ 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}")
+
+ # 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
+#
+# For example:
+# ./build-native.sh cmakeargs "-DCLR_ADDITIONAL_COMPILER_OPTIONS=<...>" cmakeargs "-DCLR_ADDITIONAL_LINKER_FLAGS=<...>"
+#
+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)
+ add_definitions(-D_AMD64_)
+ add_definitions(-D_WIN64)
+ add_definitions(-DAMD64)
+ add_definitions(-DBIT64=1)
+elseif (CLR_CMAKE_PLATFORM_ARCH_I386)
+ add_definitions(-D_X86_)
+elseif (CLR_CMAKE_PLATFORM_ARCH_ARM)
+ add_definitions(-D_ARM_)
+ add_definitions(-DARM)
+elseif (CLR_CMAKE_PLATFORM_ARCH_ARM64)
+ add_definitions(-D_ARM64_)
+ add_definitions(-DARM64)
+ add_definitions(-D_WIN64)
+ add_definitions(-DBIT64=1)
+else ()
+ 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)
+ 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)
+else ()
+ clr_unknown_arch()
+endif ()
+
+#--------------------------------------
+# Compile Options
+#--------------------------------------
+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)
+ 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 (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)
diff --git a/src/pal/tools/gen-buildsys-clang.sh b/src/pal/tools/gen-buildsys-clang.sh
index b5726c82e3..32a217f301 100755
--- a/src/pal/tools/gen-buildsys-clang.sh
+++ b/src/pal/tools/gen-buildsys-clang.sh
@@ -53,10 +53,6 @@ for i in "${@:5}"; do
echo "Code coverage is turned on for this build."
code_coverage=ON
;;
- INCLUDE_TESTS)
- echo "Including tests directory in build."
- build_tests=ON
- ;;
NINJA)
generator=Ninja
;;
@@ -166,9 +162,12 @@ else
overridefile=clang-compiler-override.txt
fi
+# Determine the current script directory
+__currentScriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
cmake \
-G "$generator" \
- "-DCMAKE_USER_MAKE_RULES_OVERRIDE=$1/src/pal/tools/$overridefile" \
+ "-DCMAKE_USER_MAKE_RULES_OVERRIDE=${__currentScriptDir}/$overridefile" \
"-DCMAKE_AR=$llvm_ar" \
"-DCMAKE_LINKER=$llvm_link" \
"-DCMAKE_NM=$llvm_nm" \
@@ -176,7 +175,6 @@ cmake \
"-DCMAKE_BUILD_TYPE=$buildtype" \
"-DCMAKE_EXPORT_COMPILE_COMMANDS=1 " \
"-DCLR_CMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \
- "-DCLR_CMAKE_BUILD_TESTS=$build_tests" \
$cmake_extra_defines \
$__UnprocessedCMakeArgs \
"$1"
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 44e9e536b4..388ce6d5d8 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,15 +1,9 @@
# Require at least version 2.8.12 of CMake
cmake_minimum_required(VERSION 2.8.12)
-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(CLR_CMAKE_TARGET_ARCH ${CLR_CMAKE_HOST_ARCH})
+# Include global configure settings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../configure.cmake)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../configurecompiler.cmake)
set(INC_PLATFORM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/Common/Platform)
if (WIN32)
diff --git a/tests/src/Interop/CMakeLists.txt b/tests/src/Interop/CMakeLists.txt
index 2e89dce877..0787ae0655 100644
--- a/tests/src/Interop/CMakeLists.txt
+++ b/tests/src/Interop/CMakeLists.txt
@@ -1,10 +1,8 @@
if(WIN32)
- if((CLR_CMAKE_HOST_ARCH STREQUAL arm) OR (CLR_CMAKE_HOST_ARCH STREQUAL arm64))
- list(APPEND LINK_LIBRARIES_ADDITIONAL
- ole32.lib
- advapi32.lib
- )
- endif()
+ list(APPEND LINK_LIBRARIES_ADDITIONAL
+ ole32.lib
+ advapi32.lib
+ )
endif(WIN32)
# Consumed by native test assets
diff --git a/tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.cpp b/tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.cpp
index e690a7c25c..abf8798e0c 100644
--- a/tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.cpp
+++ b/tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.cpp
@@ -167,7 +167,7 @@ extern "C" DLL_EXPORT BOOL NATIVEAPI MarshalStructAsParam_AsSeqByValOut3(CharSet
}
extern "C" DLL_EXPORT BOOL NATIVEAPI MarshalStructAsParam_AsSeqByRefOut3(CharSetAnsiSequential* str1)
{
- TP_CoTaskMemFree((void*)(str1->f1));
+ CoTaskMemFree((void*)(str1->f1));
str1->f1 = CoStrDup("change string");
str1->f2 = 'n';
return TRUE;
diff --git a/tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.h b/tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.h
index 22ad037a6a..6f8136b7ea 100644
--- a/tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.h
+++ b/tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.h
@@ -4,7 +4,7 @@
inline char* CoStrDup(const char* str)
{
size_t size = strlen(str) + 1;
- char* dup = (char *)TP_CoTaskMemAlloc(size);
+ char* dup = (char *)CoTaskMemAlloc(size);
if (dup != nullptr)
{
strcpy_s(dup, size, str);
@@ -294,10 +294,10 @@ void ChangeCharSetUnicodeSequential(CharSetUnicodeSequential* p)
LPCWSTR strSource = u"change string";
#endif
size_t len = wcslen(strSource);
- LPCWSTR temp = (LPCWSTR)TP_CoTaskMemAlloc(sizeof(WCHAR)*(len+1));
+ LPCWSTR temp = (LPCWSTR)CoTaskMemAlloc(sizeof(WCHAR)*(len+1));
if(temp != NULL)
{
- wcscpy_s((WCHAR*)temp, (len+1)*sizeof(WCHAR), strSource);
+ wcscpy_s((WCHAR*)temp, (len+1), strSource);
p->f1 = temp;
p->f2 = L'n';
}
@@ -405,7 +405,7 @@ void ChangeS3(S3* p)
{
p->flag = false;
- /*TP_CoTaskMemFree((void *)p->str);*/
+ /*CoTaskMemFree((void *)p->str);*/
p->str = CoStrDup("change string");
for(int i = 1;i<257;i++)
@@ -505,8 +505,8 @@ bool IsCorrectStringStructSequentialAnsi(StringStructSequentialAnsi* str)
void ChangeStringStructSequentialAnsi(StringStructSequentialAnsi* str)
{
- char* newFirst = (char*)TP_CoTaskMemAlloc(sizeof(char)*513);
- char* newLast = (char*)TP_CoTaskMemAlloc(sizeof(char)*513);
+ char* newFirst = (char*)CoTaskMemAlloc(sizeof(char)*513);
+ char* newLast = (char*)CoTaskMemAlloc(sizeof(char)*513);
for (int i = 0; i < 512; ++i)
{
newFirst[i] = 'b';
@@ -558,8 +558,8 @@ bool IsCorrectStringStructSequentialUnicode(StringStructSequentialUnicode* str)
void ChangeStringStructSequentialUnicode(StringStructSequentialUnicode* str)
{
- WCHAR* newFirst = (WCHAR*)TP_CoTaskMemAlloc(sizeof(WCHAR)*257);
- WCHAR* newLast = (WCHAR*)TP_CoTaskMemAlloc(sizeof(WCHAR)*257);
+ WCHAR* newFirst = (WCHAR*)CoTaskMemAlloc(sizeof(WCHAR)*257);
+ WCHAR* newLast = (WCHAR*)CoTaskMemAlloc(sizeof(WCHAR)*257);
for (int i = 0; i < 256; ++i)
{
newFirst[i] = L'b';
diff --git a/tests/src/JIT/Directed/StructABI/CMakeLists.txt b/tests/src/JIT/Directed/StructABI/CMakeLists.txt
index 3fbe54c3d4..b4952d5850 100644
--- a/tests/src/JIT/Directed/StructABI/CMakeLists.txt
+++ b/tests/src/JIT/Directed/StructABI/CMakeLists.txt
@@ -2,8 +2,10 @@ cmake_minimum_required (VERSION 2.6)
project (StructABILib)
include_directories(${INC_PLATFORM_DIR})
-if(!WIN32)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
+if(WIN32)
+ add_compile_options(/TC) # compile all files as C
+else()
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
endif()
# add the executable