Unify some cmake function definitions (#33716)
authorAdeel Mujahid <adeelbm@outlook.com>
Sat, 21 Mar 2020 02:45:42 +0000 (04:45 +0200)
committerGitHub <noreply@github.com>
Sat, 21 Mar 2020 02:45:42 +0000 (19:45 -0700)
* Unify some cmake function definitions

* Address CR feedback

* Make installers /Zc:strictStrings compatible

* Make installer /Gz compatible

* Remove skip-strip internal implementation

* Use CLR_CMAKE_TARGET_DARWIN

* Establish iOS to Darwin relationship

* Simplify iOS conditions

50 files changed:
eng/native/build-commons.sh
eng/native/configurecompiler.cmake [new file with mode: 0644]
eng/native/configureoptimization.cmake [new file with mode: 0644]
eng/native/configureplatform.cmake
eng/native/configuretools.cmake
eng/native/functions.cmake
eng/native/sanitizerblacklist.txt [new file with mode: 0644]
src/coreclr/CMakeLists.txt
src/coreclr/configurecompiler.cmake [deleted file]
src/coreclr/configureoptimization.cmake [deleted file]
src/coreclr/sanitizerblacklist.txt [deleted file]
src/coreclr/src/debug/createdump/CMakeLists.txt
src/coreclr/src/dlls/clretwrc/CMakeLists.txt
src/coreclr/src/dlls/dbgshim/CMakeLists.txt
src/coreclr/src/dlls/mscordac/CMakeLists.txt
src/coreclr/src/dlls/mscordbi/CMakeLists.txt
src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt
src/coreclr/src/dlls/mscorrc/CMakeLists.txt
src/coreclr/src/jit/standalone/CMakeLists.txt
src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt
src/coreclr/src/tools/crossgen/CMakeLists.txt
src/coreclr/tests/CMakeLists.txt
src/installer/corehost/CMakeLists.txt
src/installer/corehost/cli/apphost/apphost.windows.cpp
src/installer/corehost/cli/hostmisc/pal.h
src/installer/corehost/cli/hostmisc/pal.unix.cpp
src/installer/corehost/cli/hostmisc/pal.windows.cpp
src/installer/corehost/cli/hostmisc/trace.h
src/installer/corehost/cli/hostmisc/utils.cpp
src/installer/corehost/cli/hostmisc/utils.h
src/installer/corehost/cli/hostpolicy/hostpolicy.cpp
src/installer/corehost/cli/ijwhost/AMD64/asmhelpers.asm [deleted file]
src/installer/corehost/cli/ijwhost/AMD64/asmmacros.inc [deleted file]
src/installer/corehost/cli/ijwhost/AMD64/bootstrap_thunk.cpp [deleted file]
src/installer/corehost/cli/ijwhost/AMD64/bootstrap_thunk.h [deleted file]
src/installer/corehost/cli/ijwhost/CMakeLists.txt
src/installer/corehost/cli/ijwhost/amd64/asmhelpers.asm [new file with mode: 0644]
src/installer/corehost/cli/ijwhost/amd64/asmmacros.inc [new file with mode: 0644]
src/installer/corehost/cli/ijwhost/amd64/bootstrap_thunk.cpp [new file with mode: 0644]
src/installer/corehost/cli/ijwhost/amd64/bootstrap_thunk.h [new file with mode: 0644]
src/installer/corehost/cli/ijwhost/arm/bootstrap_thunk.h
src/installer/corehost/cli/ijwhost/arm64/bootstrap_thunk.h
src/installer/corehost/cli/ijwhost/i386/bootstrap_thunk.h
src/installer/corehost/cli/ijwhost/ijwthunk.cpp
src/installer/corehost/cli/nethost/nethost.cpp
src/installer/corehost/cli/redirected_error_writer.cpp
src/installer/corehost/cli/redirected_error_writer.h
src/installer/functions.cmake [deleted file]
src/installer/settings.cmake [deleted file]
src/libraries/Native/Unix/CMakeLists.txt

index c65f99a936b6aee6639a9e07ac64e50b820f315d..6cc187e7ab2bb9454c2ba6757a837518abe75c5e 100755 (executable)
@@ -337,7 +337,6 @@ while :; do
             ;;
 
         stripsymbols|-stripsymbols)
-            __CMakeArgs="-DSTRIP_SYMBOLS=true $__CMakeArgs"
             ;;
 
         verbose|-verbose)
diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake
new file mode 100644 (file)
index 0000000..6ce429b
--- /dev/null
@@ -0,0 +1,586 @@
+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)
+
+cmake_policy(SET CMP0083 NEW)
+
+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(MSVC)
+    add_compile_options(/Zi /FC /Zc:strictStrings)
+elseif (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 "")
+
+add_compile_definitions("$<$<OR:$<CONFIG:DEBUG>,$<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_link_options(/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
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/MANIFEST:NO>)
+  # can handle addresses larger than 2 gigabytes
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/LARGEADDRESSAWARE>)
+  #Compatible with Data Execution Prevention
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/NXCOMPAT>)
+  #Use address space layout randomization
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/DYNAMICBASE>)
+  #shrink pdb size
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/PDBCOMPRESS>)
+
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/DEBUG>)
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/IGNORE:4197,4013,4254,4070,4221>)
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/SUBSYSTEM:WINDOWS,${WINDOWS_SUBSYSTEM_VERSION}>)
+
+  set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4221")
+
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:/DEBUG>)
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:/PDBCOMPRESS>)
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:/STACK:1572864>)
+
+  # Debug build specific flags
+  add_link_options($<$<AND:$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>,$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>>:/NOVCFEATURE>)
+
+  # Checked build specific flags
+  add_link_options($<$<CONFIG:CHECKED>:/INCREMENTAL:NO>) # prevent "warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:REF' specification"
+  add_link_options($<$<CONFIG:CHECKED>:/OPT:REF>)
+  add_link_options($<$<CONFIG:CHECKED>:/OPT:NOICF>)
+
+  # Release build specific flags
+  add_link_options($<$<CONFIG:RELEASE>:/LTCG>)
+  add_link_options($<$<CONFIG:RELEASE>:/OPT:REF>)
+  add_link_options($<$<CONFIG:RELEASE>:/OPT:ICF>)
+  set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")
+
+  # ReleaseWithDebugInfo build specific flags
+  add_link_options($<$<CONFIG:RELWITHDEBINFO>:/LTCG>)
+  add_link_options($<$<CONFIG:RELWITHDEBINFO>:/OPT:REF>)
+  add_link_options($<$<CONFIG:RELWITHDEBINFO>:/OPT:ICF>)
+  set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
+
+  # Force uCRT to be dynamically linked for Release build
+  add_link_options("$<$<CONFIG:RELEASE>:/NODEFAULTLIB:libucrt.lib;/DEFAULTLIB:ucrt.lib>")
+
+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_definitions("$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>:${CLR_SANITIZE_CXX_OPTIONS};-fdata-sections;--ffunction-sections;-O1>")
+      add_link_options($<$<AND:$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>,$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>>:${CLR_SANITIZE_LINK_OPTIONS}>)
+
+      # -Wl and --gc-sections: drop unused sections\functions (similar to Windows /Gy function-level-linking)
+      add_link_options("$<$<AND:$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>,$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>>:${CLR_SANITIZE_LINK_OPTIONS};-Wl,--gc-sections>")
+    endif ()
+  endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
+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)
+    add_link_options(${CLR_ADDITIONAL_LINKER_FLAGS})
+endif(CLR_CMAKE_HOST_UNIX)
+
+if(CLR_CMAKE_HOST_LINUX)
+  add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
+  add_link_options(-Wl,--build-id=sha1 -Wl,-z,relro,-z,now)
+endif(CLR_CMAKE_HOST_LINUX)
+if(CLR_CMAKE_HOST_FREEBSD)
+  add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
+  add_link_options(-fuse-ld=lld LINKER:--build-id=sha1)
+endif(CLR_CMAKE_HOST_FREEBSD)
+
+#------------------------------------
+# Definitions (for platform)
+#-----------------------------------
+if (CLR_CMAKE_HOST_ARCH_AMD64)
+  add_definitions(-DHOST_AMD64)
+  add_definitions(-DHOST_64BIT)
+elseif (CLR_CMAKE_HOST_ARCH_I386)
+  add_definitions(-DHOST_X86)
+elseif (CLR_CMAKE_HOST_ARCH_ARM)
+  add_definitions(-DHOST_ARM)
+elseif (CLR_CMAKE_HOST_ARCH_ARM64)
+  add_definitions(-DHOST_ARM64)
+  add_definitions(-DHOST_64BIT)
+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")
+    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_DARWIN)
+    message("Detected OSX x86_64")
+  endif(CLR_CMAKE_HOST_DARWIN)
+
+  if(CLR_CMAKE_HOST_FREEBSD)
+    message("Detected FreeBSD amd64")
+  endif(CLR_CMAKE_HOST_FREEBSD)
+
+  if(CLR_CMAKE_HOST_NETBSD)
+    message("Detected NetBSD amd64")
+  endif(CLR_CMAKE_HOST_NETBSD)
+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)
+
+# Architecture specific files folder name
+if (CLR_CMAKE_TARGET_ARCH_AMD64)
+    set(ARCH_SOURCES_DIR amd64)
+    add_definitions(-DTARGET_AMD64)
+    add_definitions(-DTARGET_64BIT)
+elseif (CLR_CMAKE_TARGET_ARCH_ARM64)
+    set(ARCH_SOURCES_DIR arm64)
+    add_definitions(-DTARGET_ARM64)
+    add_definitions(-DTARGET_64BIT)
+elseif (CLR_CMAKE_TARGET_ARCH_ARM)
+    set(ARCH_SOURCES_DIR arm)
+    add_definitions(-DTARGET_ARM)
+elseif (CLR_CMAKE_TARGET_ARCH_I386)
+    set(ARCH_SOURCES_DIR i386)
+    add_definitions(-DTARGET_X86)
+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_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()
+    check_cxx_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_DARWIN)
+
+  # 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)
+
+  #These seem to indicate real issues
+  add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-invalid-offsetof>)
+
+  if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+    # 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)
+    # 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)
+
+    # 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)
+  else()
+    add_compile_options(-Wno-unused-but-set-variable)
+    add_compile_options(-Wno-unknown-pragmas)
+    add_compile_options(-Wno-uninitialized)
+    add_compile_options(-Wno-strict-aliasing)
+    add_compile_options(-Wno-array-bounds)
+    check_cxx_compiler_flag(-Wclass-memaccess COMPILER_SUPPORTS_W_CLASS_MEMACCESS)
+    if (COMPILER_SUPPORTS_W_CLASS_MEMACCESS)
+      add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>)
+    endif()
+    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()
+
+  # 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)
+
+  # We mark the function which needs exporting with DLLEXPORT
+  add_compile_options(-fvisibility=hidden)
+
+  # Specify the minimum supported version of macOS
+  if(CLR_CMAKE_HOST_DARWIN)
+    set(MACOS_VERSION_MIN_FLAGS -mmacosx-version-min=10.12)
+    add_compile_options(${MACOS_VERSION_MIN_FLAGS})
+    add_link_options(${MACOS_VERSION_MIN_FLAGS})
+  endif(CLR_CMAKE_HOST_DARWIN)
+endif(CLR_CMAKE_HOST_UNIX)
+
+if(CLR_CMAKE_TARGET_UNIX)
+  add_definitions(-DTARGET_UNIX)
+  # Contracts are disabled on UNIX.
+  add_definitions(-DDISABLE_CONTRACTS)
+  if(CLR_CMAKE_TARGET_DARWIN)
+    add_definitions(-DTARGET_DARWIN)
+  endif(CLR_CMAKE_TARGET_DARWIN)
+  if(CLR_CMAKE_TARGET_FREEBSD)
+    add_definitions(-DTARGET_FREEBSD)
+  endif(CLR_CMAKE_TARGET_FREEBSD)
+  if(CLR_CMAKE_TARGET_LINUX)
+    add_definitions(-DTARGET_LINUX)
+  endif(CLR_CMAKE_TARGET_LINUX)
+  if(CLR_CMAKE_TARGET_NETBSD)
+    add_definitions(-DTARGET_NETBSD)
+  endif(CLR_CMAKE_TARGET_NETBSD)
+  if(CLR_CMAKE_TARGET_ANDROID)
+    add_definitions(-DTARGET_ANDROID)
+  endif()
+else(CLR_CMAKE_TARGET_UNIX)
+  add_definitions(-DTARGET_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
+
+  # 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
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /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)
+
+  # Disable Warnings:
+  # 4291: Delete not defined for new, c++ exception may cause leak.
+  # 4302: Truncation from '%$S' to '%$S'.
+  # 4311: Pointer truncation from '%$S' to '%$S'.
+  # 4312: '<function-style-cast>' : conversion from '%$S' to '%$S' of greater size.
+  # 4477: Format string '%$S' requires an argument of type '%$S', but variadic argument %d has type '%$S'.
+  add_compile_options(/wd4291 /wd4302 /wd4311 /wd4312 /wd4477)
+
+  # Treat Warnings as Errors:
+  # 4007: 'main' : must be __cdecl.
+  # 4013: 'function' undefined - assuming extern returning int.
+  # 4102: "'%$S' : unreferenced label".
+  # 4551: Function call missing argument list.
+  # 4700: Local used w/o being initialized.
+  # 4806: Unsafe operation involving type 'bool'.
+  add_compile_options(/we4007 /we4013 /we4102 /we4551 /we4700 /we4806)
+
+  # Set Warning Level 3:
+  # 4092: Sizeof returns 'unsigned long'.
+  # 4121: Structure is sensitive to alignment.
+  # 4125: Decimal digit in octal sequence.
+  # 4130: Logical operation on address of string constant.
+  # 4132: Const object should be initialized.
+  # 4212: Function declaration used ellipsis.
+  # 4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX.
+  add_compile_options(/w34092 /w34121 /w34125 /w34130 /w34132 /w34212 /w34530)
+
+  # Set Warning Level 4:
+  # 4177: Pragma data_seg s/b at global scope.
+  add_compile_options(/w44177)
+
+  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_HOST_ARCH_I386)
+    add_compile_options(/Gz)
+  endif (CLR_CMAKE_HOST_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_HOST_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_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")
+
+  # 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:$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>,$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>:/MT>)
+  add_compile_options($<$<AND:$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>,$<NOT:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>>:/MTd>)
+
+  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)
+
+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_link_options(--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_BUILD_TOOL STREQUAL nmake)
+  set(CMAKE_RC_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
+endif(CMAKE_BUILD_TOOL STREQUAL nmake)
+
+# Ensure other tools are present
+if (CLR_CMAKE_HOST_WIN32)
+    if(CLR_CMAKE_HOST_ARCH_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
+      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)
+    elseif(CLR_CMAKE_HOST_ARCH_ARM64)
+
+      # 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 ARM64 build.")
+      else()
+              message("Using Windows SDK version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
+      endif()
+
+      # 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)
+    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()
+
+else (CLR_CMAKE_HOST_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()
+endif(CLR_CMAKE_HOST_WIN32)
diff --git a/eng/native/configureoptimization.cmake b/eng/native/configureoptimization.cmake
new file mode 100644 (file)
index 0000000..548a858
--- /dev/null
@@ -0,0 +1,11 @@
+if(CLR_CMAKE_HOST_WIN32)
+    add_compile_options($<$<CONFIG:Debug>:/Od>)
+    add_compile_options($<$<CONFIG:Checked>:/O1>)
+    add_compile_options($<$<CONFIG:Release>:/Ox>)
+    add_compile_options($<$<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()
index 4fccb81a0c714a7edc41e6a0fa6316c35d35d400..5c5accd7d1f666b248c237c35bd4c227d7ff1cd4 100644 (file)
@@ -91,6 +91,7 @@ endif(CLR_CMAKE_HOST_OS STREQUAL Darwin)
 if(CLR_CMAKE_HOST_OS STREQUAL iOS)
     set(CLR_CMAKE_HOST_UNIX 1)
     set(CLR_CMAKE_HOST_IOS 1)
+    set(CLR_CMAKE_HOST_DARWIN 1)
     if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
         set(CLR_CMAKE_HOST_UNIX_AMD64 1)
     elseif(CMAKE_OSX_ARCHITECTURES MATCHES "armv7")
@@ -255,6 +256,7 @@ endif(CLR_CMAKE_TARGET_OS STREQUAL Darwin)
 if(CLR_CMAKE_TARGET_OS STREQUAL iOS)
     set(CLR_CMAKE_TARGET_UNIX 1)
     set(CLR_CMAKE_TARGET_IOS 1)
+    set(CLR_CMAKE_TARGET_DARWIN 1)
 endif(CLR_CMAKE_TARGET_OS STREQUAL iOS)
 
 if(CLR_CMAKE_TARGET_OS STREQUAL FreeBSD)
index b91237da89bfb707e559381e4b46ff7ae04f64f7..4c0f9694fd72da90328f177fe114efd59c12e306 100644 (file)
@@ -47,7 +47,7 @@ if(NOT WIN32)
     locate_toolchain_exec(ranlib CMAKE_RANLIB)
   endif()
 
-  if(NOT CLR_CMAKE_TARGET_DARWIN AND NOT CLR_CMAKE_TARGET_IOS)
+  if(NOT CLR_CMAKE_TARGET_DARWIN)
     locate_toolchain_exec(objdump CMAKE_OBJDUMP)
 
     if(CMAKE_SYSTEM_NAME STREQUAL Android)
@@ -60,5 +60,5 @@ if(NOT WIN32)
     endif()
 
     locate_toolchain_exec(objcopy CMAKE_OBJCOPY)
-  endif()
+  endif(NOT CLR_CMAKE_TARGET_DARWIN)
 endif()
index cc806fed2634336c8364dcfc75412470253bbcda..c3766202f8fd40aef355eafb68a4bf11d3876c88 100644 (file)
@@ -124,7 +124,7 @@ function(preprocess_compile_asm)
   set(oneValueArgs OUTPUT_OBJECTS)
   set(multiValueArgs ASM_FILES)
   cmake_parse_arguments(PARSE_ARGV 0 COMPILE_ASM "${options}" "${oneValueArgs}" "${multiValueArgs}")
-  
+
   get_include_directories_asm(ASM_INCLUDE_DIRECTORIES)
 
   set (ASSEMBLED_OBJECTS "")
@@ -250,48 +250,62 @@ function(target_precompile_header)
   endif(MSVC)
 endfunction()
 
-function(strip_symbols targetName outputFilename skipStrip)
+function(strip_symbols targetName outputFilename)
   if (CLR_CMAKE_HOST_UNIX)
-    if (STRIP_SYMBOLS)
-      set(strip_source_file $<TARGET_FILE:${targetName}>)
-
-      if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
-        set(strip_destination_file ${strip_source_file}.dwarf)
-
-        if(NOT ${skipStrip})
-            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}
-            )
-        endif()
-      else (CMAKE_SYSTEM_NAME STREQUAL Darwin)
-        set(strip_destination_file ${strip_source_file}.dbg)
-
-        if(NOT ${skipStrip})
-            add_custom_command(
-            TARGET ${targetName}
-            POST_BUILD
-            VERBATIM
-            COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
-            COMMAND ${CMAKE_OBJCOPY} --strip-debug ${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()
-      endif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
+    set(strip_source_file $<TARGET_FILE:${targetName}>)
 
-      set(${outputFilename} ${strip_destination_file} PARENT_SCOPE)
-    endif (STRIP_SYMBOLS)
+    if (CLR_CMAKE_TARGET_DARWIN)
+      set(strip_destination_file ${strip_source_file}.dwarf)
+
+      # 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()
+
+      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 (CLR_CMAKE_TARGET_DARWIN)
+      set(strip_destination_file ${strip_source_file}.dbg)
+
+      add_custom_command(
+        TARGET ${targetName}
+        POST_BUILD
+        VERBATIM
+        COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
+        COMMAND ${CMAKE_OBJCOPY} --strip-debug ${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_DARWIN)
+
+    set(${outputFilename} ${strip_destination_file} PARENT_SCOPE)
   endif(CLR_CMAKE_HOST_UNIX)
 endfunction()
 
-# install_clr(TARGETS TARGETS targetName [targetName2 ...] [DESTINATION destination] [SKIP_STRIP])
+function(install_symbols targetName destination_path)
+  strip_symbols(${targetName} strip_destination_file)
+
+  if(CLR_CMAKE_TARGET_WIN32)
+    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pdb DESTINATION ${destination_path}/PDB)
+  else()
+    install(FILES ${strip_destination_file} DESTINATION ${destination_path})
+  endif()
+endfunction()
+
+# install_clr(TARGETS TARGETS targetName [targetName2 ...] [DESTINATION destination])
 function(install_clr)
-  set(options SKIP_STRIP)
   set(oneValueArgs DESTINATION)
   set(multiValueArgs TARGETS)
   cmake_parse_arguments(PARSE_ARGV 0 INSTALL_CLR "${options}" "${oneValueArgs}" "${multiValueArgs}")
@@ -307,21 +321,12 @@ function(install_clr)
   foreach(targetName ${INSTALL_CLR_TARGETS})
     list(FIND CLR_CROSS_COMPONENTS_LIST ${targetName} INDEX)
     if (NOT DEFINED CLR_CROSS_COMPONENTS_LIST OR NOT ${INDEX} EQUAL -1)
-        if("${INSTALL_CLR_SKIP_STRIP}" STREQUAL "")
-            set(INSTALL_CLR_SKIP_STRIP FALSE)
-        endif()
-        strip_symbols(${targetName} strip_destination_file ${INSTALL_CLR_SKIP_STRIP})
+        install_symbols(${targetName} ${INSTALL_CLR_DESTINATION})
 
         # 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 ${INSTALL_CLR_DESTINATION})
-        if(WIN32)
-            # We can't use the $<TARGET_PDB_FILE> generator expression here since
-            # the generator expression isn't supported on resource DLLs.
-            install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pdb DESTINATION ${INSTALL_CLR_DESTINATION}/PDB)
-        else()
-            install(FILES ${strip_destination_file} DESTINATION ${INSTALL_CLR_DESTINATION})
-        endif()
+
         if(CLR_CMAKE_PGO_INSTRUMENT)
             if(WIN32)
                 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pgd DESTINATION ${INSTALL_CLR_DESTINATION}/PGD OPTIONAL)
@@ -339,6 +344,11 @@ endfunction()
 # - creating executable pages from anonymous memory,
 # - making read-only-after-relocations (RELRO) data pages writable again.
 function(disable_pax_mprotect targetName)
+  # 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}
diff --git a/eng/native/sanitizerblacklist.txt b/eng/native/sanitizerblacklist.txt
new file mode 100644 (file)
index 0000000..ec33139
--- /dev/null
@@ -0,0 +1,14 @@
+# 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/src/vm/jithelpers.cpp:6491:9
+# 4 0x7f0252bbceb2  (<unknown module>)
+fun:_Z20JIT_InitPInvokeFrameP16InlinedCallFramePv
+
index 0e75f4473640dd89865282ee935dea8fd3955c6b..d15455365dae6024212fdedf2a7e795c0eef8b9c 100644 (file)
@@ -5,13 +5,17 @@ cmake_policy(SET CMP0042 NEW)
 # Set the project name
 project(CoreCLR)
 
-include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake)
+include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake)
 
 if (CLR_CMAKE_HOST_WIN32)
   message(STATUS "VS_PLATFORM_TOOLSET is ${CMAKE_VS_PLATFORM_TOOLSET}")
   message(STATUS "VS_PLATFORM_NAME is ${CMAKE_VS_PLATFORM_NAME}")
 endif (CLR_CMAKE_HOST_WIN32)
 
+if(MSVC)
+  set(CMAKE_CXX_STANDARD_LIBRARIES "") # do not link against standard win32 libs i.e. kernel32, uuid, user32, etc.
+endif (MSVC)
+
 # Set commonly used directory names
 set(CLR_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(VM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/vm)
@@ -31,93 +35,6 @@ endif(CORECLR_SET_RPATH)
 
 OPTION(CLR_CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF)
 
-# Ensure other tools are present
-if (CLR_CMAKE_HOST_WIN32)
-    if(CLR_CMAKE_HOST_ARCH_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
-      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)
-    elseif(CLR_CMAKE_HOST_ARCH_ARM64)
-
-      # 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 ARM64 build.")
-      else()
-             message("Using Windows SDK version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
-      endif()
-
-      # 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)
-    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()
-
-else (CLR_CMAKE_HOST_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 (CLR_CMAKE_HOST_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()
-
-    endif()
-endif(CLR_CMAKE_HOST_WIN32)
-
-if(CLR_CMAKE_TARGET_ANDROID)
-  add_definitions(-DTARGET_ANDROID)
-endif()
-
-#----------------------------------------------------
-# Configure compiler settings for environment
-#----------------------------------------------------
-include(configurecompiler.cmake)
-
 #----------------------------------------------------
 # Cross target Component build specific configuration
 #----------------------------------------------------
diff --git a/src/coreclr/configurecompiler.cmake b/src/coreclr/configurecompiler.cmake
deleted file mode 100644 (file)
index c460aad..0000000
+++ /dev/null
@@ -1,525 +0,0 @@
-# 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)
-
-cmake_policy(SET CMP0083 NEW)
-
-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(MSVC)
-    add_compile_options(/Zi /FC /Zc:strictStrings)
-elseif (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 "")
-
-add_compile_definitions("$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>:DEBUG;_DEBUG;_DBG;URTBLDENV_FRIENDLY=Checked;BUILDENV_CHECKED=1>")
-add_compile_definitions("$<$<OR:$<CONFIG:RELEASE>,$<CONFIG:RELWITHDEBINFO>>:NDEBUG;URTBLDENV_FRIENDLY=Retail>")
-
-set(CMAKE_CXX_STANDARD_LIBRARIES "") # do not link against standard win32 libs i.e. kernel32, uuid, user32, etc.
-
-if (MSVC)
-  add_link_options(/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
-  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/MANIFEST:NO>)
-  # can handle addresses larger than 2 gigabytes
-  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/LARGEADDRESSAWARE>)
-  #Compatible with Data Execution Prevention
-  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/NXCOMPAT>)
-  #Use address space layout randomization
-  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/DYNAMICBASE>)
-  #shrink pdb size
-  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/PDBCOMPRESS>)
-
-  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/DEBUG>)
-  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/IGNORE:4197,4013,4254,4070,4221>)
-  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/SUBSYSTEM:WINDOWS,${WINDOWS_SUBSYSTEM_VERSION}>)
-
-  set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4221")
-
-  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:/DEBUG>)
-  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:/PDBCOMPRESS>)
-  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:/STACK:1572864>)
-
-  # Debug build specific flags
-  add_link_options($<$<AND:$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>,$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>>:/NOVCFEATURE>)
-
-  # Checked build specific flags
-  add_link_options($<$<CONFIG:CHECKED>:/INCREMENTAL:NO>) # prevent "warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:REF' specification"
-  add_link_options($<$<CONFIG:CHECKED>:/OPT:REF>)
-  add_link_options($<$<CONFIG:CHECKED>:/OPT:NOICF>)
-
-  # Release build specific flags
-  add_link_options($<$<CONFIG:RELEASE>:/LTCG>)
-  add_link_options($<$<CONFIG:RELEASE>:/OPT:REF>)
-  add_link_options($<$<CONFIG:RELEASE>:/OPT:ICF>)
-  set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")
-
-  # ReleaseWithDebugInfo build specific flags
-  add_link_options($<$<CONFIG:RELWITHDEBINFO>:/LTCG>)
-  add_link_options($<$<CONFIG:RELWITHDEBINFO>:/OPT:REF>)
-  add_link_options($<$<CONFIG:RELWITHDEBINFO>:/OPT:ICF>)
-  set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
-
-  # Force uCRT to be dynamically linked for Release build
-  add_link_options("$<$<CONFIG:RELEASE>:/NODEFAULTLIB:libucrt.lib;/DEFAULTLIB:ucrt.lib>")
-
-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_definitions("$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>:${CLR_SANITIZE_CXX_OPTIONS};-fdata-sections;--ffunction-sections;-O1>")
-      add_link_options($<$<AND:$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>,$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>>:${CLR_SANITIZE_LINK_OPTIONS}>)
-
-      # -Wl and --gc-sections: drop unused sections\functions (similar to Windows /Gy function-level-linking)
-      add_link_options("$<$<AND:$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>,$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>>:${CLR_SANITIZE_LINK_OPTIONS};-Wl,--gc-sections>")
-    endif ()
-  endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
-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)
-    add_link_options(${CLR_ADDITIONAL_LINKER_FLAGS})
-endif(CLR_CMAKE_HOST_UNIX)
-
-if(CLR_CMAKE_HOST_LINUX)
-  add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
-  add_link_options(-Wl,--build-id=sha1 -Wl,-z,relro,-z,now)
-endif(CLR_CMAKE_HOST_LINUX)
-if(CLR_CMAKE_HOST_FREEBSD)
-  add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
-  add_link_options(-fuse-ld=lld LINKER:--build-id=sha1)
-endif(CLR_CMAKE_HOST_FREEBSD)
-
-#------------------------------------
-# Definitions (for platform)
-#-----------------------------------
-if (CLR_CMAKE_HOST_ARCH_AMD64)
-  add_definitions(-DHOST_AMD64)
-  add_definitions(-DHOST_64BIT)
-elseif (CLR_CMAKE_HOST_ARCH_I386)
-  add_definitions(-DHOST_X86)
-elseif (CLR_CMAKE_HOST_ARCH_ARM)
-  add_definitions(-DHOST_ARM)
-elseif (CLR_CMAKE_HOST_ARCH_ARM64)
-  add_definitions(-DHOST_ARM64)
-  add_definitions(-DHOST_64BIT)
-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")
-    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_DARWIN)
-    message("Detected OSX x86_64")
-  endif(CLR_CMAKE_HOST_DARWIN)
-
-  if(CLR_CMAKE_HOST_FREEBSD)
-    message("Detected FreeBSD amd64")
-  endif(CLR_CMAKE_HOST_FREEBSD)
-
-  if(CLR_CMAKE_HOST_NETBSD)
-    message("Detected NetBSD amd64")
-  endif(CLR_CMAKE_HOST_NETBSD)
-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)
-
-# Architecture specific files folder name
-if (CLR_CMAKE_TARGET_ARCH_AMD64)
-    set(ARCH_SOURCES_DIR amd64)
-    add_definitions(-DTARGET_AMD64)
-    add_definitions(-DTARGET_64BIT)
-elseif (CLR_CMAKE_TARGET_ARCH_ARM64)
-    set(ARCH_SOURCES_DIR arm64)
-    add_definitions(-DTARGET_ARM64)
-    add_definitions(-DTARGET_64BIT)
-elseif (CLR_CMAKE_TARGET_ARCH_ARM)
-    set(ARCH_SOURCES_DIR arm)
-    add_definitions(-DTARGET_ARM)
-elseif (CLR_CMAKE_TARGET_ARCH_I386)
-    set(ARCH_SOURCES_DIR i386)
-    add_definitions(-DTARGET_X86)
-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_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()
-    check_cxx_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_DARWIN)
-
-  # 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)
-
-  #These seem to indicate real issues
-  add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-invalid-offsetof>)
-
-  if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-    # 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)
-    # 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)
-
-    # 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)
-  else()
-    add_compile_options(-Wno-unused-but-set-variable)
-    add_compile_options(-Wno-unknown-pragmas)
-    add_compile_options(-Wno-uninitialized)
-    add_compile_options(-Wno-strict-aliasing)
-    add_compile_options(-Wno-array-bounds)
-    check_cxx_compiler_flag(-Wclass-memaccess COMPILER_SUPPORTS_W_CLASS_MEMACCESS)
-    if (COMPILER_SUPPORTS_W_CLASS_MEMACCESS)
-      add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>)
-    endif()
-    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()
-
-  # 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)
-
-  # We mark the function which needs exporting with DLLEXPORT
-  add_compile_options(-fvisibility=hidden)
-
-  # Specify the minimum supported version of macOS
-  if(CLR_CMAKE_HOST_DARWIN)
-    set(MACOS_VERSION_MIN_FLAGS -mmacosx-version-min=10.12)
-    add_compile_options(${MACOS_VERSION_MIN_FLAGS})
-    add_link_options(${MACOS_VERSION_MIN_FLAGS})
-  endif(CLR_CMAKE_HOST_DARWIN)
-endif(CLR_CMAKE_HOST_UNIX)
-
-if(CLR_CMAKE_TARGET_UNIX)
-  add_definitions(-DTARGET_UNIX)
-  # Contracts are disabled on UNIX.
-  add_definitions(-DDISABLE_CONTRACTS)
-  if(CLR_CMAKE_TARGET_DARWIN)
-    add_definitions(-DTARGET_DARWIN)
-  endif(CLR_CMAKE_TARGET_DARWIN)
-  if(CLR_CMAKE_TARGET_FREEBSD)
-    add_definitions(-DTARGET_FREEBSD)
-  endif(CLR_CMAKE_TARGET_FREEBSD)
-  if(CLR_CMAKE_TARGET_LINUX)
-    add_definitions(-DTARGET_LINUX)
-  endif(CLR_CMAKE_TARGET_LINUX)
-  if(CLR_CMAKE_TARGET_NETBSD)
-    add_definitions(-DTARGET_NETBSD)
-  endif(CLR_CMAKE_TARGET_NETBSD)
-else(CLR_CMAKE_TARGET_UNIX)
-  add_definitions(-DTARGET_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
-
-  # 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
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /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)
-
-  # Disable Warnings:
-  # 4291: Delete not defined for new, c++ exception may cause leak.
-  # 4302: Truncation from '%$S' to '%$S'.
-  # 4311: Pointer truncation from '%$S' to '%$S'.
-  # 4312: '<function-style-cast>' : conversion from '%$S' to '%$S' of greater size.
-  # 4477: Format string '%$S' requires an argument of type '%$S', but variadic argument %d has type '%$S'.
-  add_compile_options(/wd4291 /wd4302 /wd4311 /wd4312 /wd4477)
-
-  # Treat Warnings as Errors:
-  # 4007: 'main' : must be __cdecl.
-  # 4013: 'function' undefined - assuming extern returning int.
-  # 4102: "'%$S' : unreferenced label".
-  # 4551: Function call missing argument list.
-  # 4700: Local used w/o being initialized.
-  # 4806: Unsafe operation involving type 'bool'.
-  add_compile_options(/we4007 /we4013 /we4102 /we4551 /we4700 /we4806)
-
-  # Set Warning Level 3:
-  # 4092: Sizeof returns 'unsigned long'.
-  # 4121: Structure is sensitive to alignment.
-  # 4125: Decimal digit in octal sequence.
-  # 4130: Logical operation on address of string constant.
-  # 4132: Const object should be initialized.
-  # 4212: Function declaration used ellipsis.
-  # 4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX.
-  add_compile_options(/w34092 /w34121 /w34125 /w34130 /w34132 /w34212 /w34530)
-
-  # Set Warning Level 4:
-  # 4177: Pragma data_seg s/b at global scope.
-  add_compile_options(/w44177)
-
-  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_HOST_ARCH_I386)
-    add_compile_options(/Gz)
-  endif (CLR_CMAKE_HOST_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_HOST_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_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")
-
-  # 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:$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>,$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>:/MT>)
-  add_compile_options($<$<AND:$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>,$<NOT:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>>:/MTd>)
-
-  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)
-
-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_link_options(--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_BUILD_TOOL STREQUAL nmake)
-  set(CMAKE_RC_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
-endif(CMAKE_BUILD_TOOL STREQUAL nmake)
diff --git a/src/coreclr/configureoptimization.cmake b/src/coreclr/configureoptimization.cmake
deleted file mode 100644 (file)
index 548a858..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-if(CLR_CMAKE_HOST_WIN32)
-    add_compile_options($<$<CONFIG:Debug>:/Od>)
-    add_compile_options($<$<CONFIG:Checked>:/O1>)
-    add_compile_options($<$<CONFIG:Release>:/Ox>)
-    add_compile_options($<$<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()
diff --git a/src/coreclr/sanitizerblacklist.txt b/src/coreclr/sanitizerblacklist.txt
deleted file mode 100644 (file)
index ec33139..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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/src/vm/jithelpers.cpp:6491:9
-# 4 0x7f0252bbceb2  (<unknown module>)
-fun:_Z20JIT_InitPInvokeFrameP16InlinedCallFramePv
-
index e110566cb5088ed0c1e7d28c0c4d2ad474c3e13b..d29eda513855fd1fe9cb5c56204422896c609c51 100644 (file)
@@ -52,4 +52,4 @@ target_link_libraries(createdump
 add_dependencies(createdump mscordaccore)
 
 install_clr(TARGETS createdump)
-install_clr(TARGETS createdump DESTINATION sharedFramework SKIP_STRIP)
+install_clr(TARGETS createdump DESTINATION sharedFramework)
index 771dc494eed512c3d8d8f4b5688cdf49321b75ed..7ef540fa3c827466442d735630dcc3801b66efa5 100644 (file)
@@ -21,6 +21,6 @@ add_library_clr(clretwrc SHARED
 
 # add the install targets
 install_clr(TARGETS clretwrc)
-install_clr(TARGETS clretwrc DESTINATION sharedFramework SKIP_STRIP)
+install_clr(TARGETS clretwrc DESTINATION sharedFramework)
 
 add_dependencies(clretwrc eventing_headers)
index 5367d774f371cc47e7471101e4414925591686b4..52c1f76b92fd8e72fa5fb47a64d06b76f297a084 100644 (file)
@@ -84,4 +84,4 @@ target_link_libraries(dbgshim ${DBGSHIM_LIBRARIES})
 
 # add the install targets
 install_clr(TARGETS dbgshim)
-install_clr(TARGETS dbgshim DESTINATION sharedFramework SKIP_STRIP)
+install_clr(TARGETS dbgshim DESTINATION sharedFramework)
index f1fe14ce386868128b8a2ab875809867eb818302..aa3c6e815471a7e7a84e0906dd4e93b7a48e7864 100644 (file)
@@ -189,7 +189,7 @@ target_link_libraries(mscordaccore PRIVATE ${COREDAC_LIBRARIES})
 
 # add the install targets
 install_clr(TARGETS mscordaccore)
-install_clr(TARGETS mscordaccore DESTINATION sharedFramework SKIP_STRIP)
+install_clr(TARGETS mscordaccore DESTINATION sharedFramework)
 
 if(CLR_CMAKE_HOST_WIN32)
     set(LONG_NAME_HOST_ARCH ${CLR_CMAKE_HOST_ARCH})
index 304d7761e618ba879c8d9a3246a3a23a2939cc1f..073ea9d7016aa4be0b538f31993a89ba362a8d47 100644 (file)
@@ -119,4 +119,4 @@ endif(CLR_CMAKE_HOST_WIN32)
 
 # add the install targets
 install_clr(TARGETS mscordbi)
-install_clr(TARGETS mscordbi DESTINATION sharedFramework SKIP_STRIP)
+install_clr(TARGETS mscordbi DESTINATION sharedFramework)
index 0517bb50df32183dcbbc40ca44ca3a3ed15f3edf..8b5365f49a1b1c7bfeb59d7d474f87bede0585cf 100644 (file)
@@ -214,7 +214,7 @@ endif(CLR_CMAKE_TARGET_WIN32)
 
 # add the install targets
 install_clr(TARGETS coreclr)
-install_clr(TARGETS coreclr DESTINATION sharedFramework SKIP_STRIP)
+install_clr(TARGETS coreclr DESTINATION sharedFramework)
 
 # Enable profile guided optimization
 add_pgo(coreclr)
index d61e9ae9fb7c6b8860d46e9312137e74a2b9400f..ab6a5a231094daad529af0a23d6f77d75b31e57c 100644 (file)
@@ -16,7 +16,7 @@ if(CLR_CMAKE_HOST_WIN32)
     )
 
     install_clr(TARGETS mscorrc)
-    install_clr(TARGETS mscorrc DESTINATION sharedFramework SKIP_STRIP)
+    install_clr(TARGETS mscorrc DESTINATION sharedFramework)
 else()
     build_resources(${CMAKE_CURRENT_SOURCE_DIR}/include.rc mscorrc TARGET_CPP_FILE)
 
index b5cb1bc28fe222a8d6e209459a1073609fee3d67..fa10b2ab591e72c2a07793b9f77b11dbfea04add 100644 (file)
@@ -11,7 +11,7 @@ endif(FEATURE_READYTORUN)
 add_jit(clrjit)
 
 # add the install targets
-install_clr(TARGETS clrjit DESTINATION sharedFramework SKIP_STRIP)
+install_clr(TARGETS clrjit DESTINATION sharedFramework)
 
 # Enable profile guided optimization
 add_pgo(clrjit)
index 346630302eb21c849578d3274d265c2fb10345a3..874a457db28792ee97085b5ea3bcfca029e63132 100644 (file)
@@ -72,4 +72,4 @@ set_target_properties(coreclrtraceptprovider PROPERTIES LINKER_LANGUAGE CXX)
 _install(TARGETS eventprovider DESTINATION lib)
 # Install the static coreclrtraceptprovider library
 install_clr(TARGETS coreclrtraceptprovider)
-install_clr(TARGETS coreclrtraceptprovider DESTINATION sharedFramework SKIP_STRIP)
+install_clr(TARGETS coreclrtraceptprovider DESTINATION sharedFramework)
index 32130c9a9cc167316463153b6e9b2cc7c2def8a6..f8cd5b0bf12de1ef3a6cc256a769916cb525d758 100644 (file)
@@ -82,4 +82,4 @@ add_subdirectory(../../vm/crossgen ../../vm/crossgen)
 
 # add the install targets
 install_clr(TARGETS crossgen)
-install_clr(TARGETS crossgen DESTINATION sharedFramework SKIP_STRIP)
+install_clr(TARGETS crossgen DESTINATION sharedFramework)
index 1ea31cdd8a0357c5d8a253ccd4c3dc402b7c126d..3b82b26e4547608de29c18fd808c23fe0d8fefdf 100644 (file)
@@ -3,15 +3,13 @@ cmake_minimum_required(VERSION 3.14.2)
 cmake_policy(SET CMP0042 NEW)
 project(Tests)
 
-include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake)
+include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake)
 
 set(INC_PLATFORM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/Common/Platform)
 if (CLR_CMAKE_TARGET_WIN32)
     add_definitions(-DWINDOWS)
 endif()
 
-# Include global configure settings
-include(${CMAKE_CURRENT_SOURCE_DIR}/../configurecompiler.cmake)
 # Compile options
 
 if (CLR_CMAKE_HOST_WIN32)
index 7d1854cee4266a9b9ef48a29af6345114f3db8e7..63abbbe5d41e720d7c1daa414c0ef4d037008590 100644 (file)
@@ -2,7 +2,10 @@ cmake_minimum_required(VERSION 3.14.2)
 
 project(corehost)
 
-include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake)
-include(../settings.cmake)
-include(../functions.cmake)
+include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake)
+
+if(MSVC)
+    add_compile_options(/W1)
+endif()
+
 add_subdirectory(cli)
index 7902430b210f15315f130ac0579be246ac994116..7d0212d6b0ab9e015578173301f33670d8e6c389 100644 (file)
@@ -12,7 +12,7 @@ namespace
 {
     pal::string_t g_buffered_errors;
 
-    void buffering_trace_writer(const pal::char_t* message)
+    void __cdecl buffering_trace_writer(const pal::char_t* message)
     {
         // Add to buffer for later use.
         g_buffered_errors.append(message).append(_X("\n"));
index 5e71932f1772bf8ed5e847563ffbab600c095957..c9adc99a95f39690bde99fd007176464f19960ec 100644 (file)
@@ -68,7 +68,7 @@
 #define LIB_PREFIX
 #define MAKE_LIBNAME(NAME) (_X(NAME) _X(".dll"))
 #define FALLBACK_HOST_RID _X("win10")
-#elif defined(__APPLE__)
+#elif defined(TARGET_DARWIN)
 #define LIB_PREFIX _X("lib")
 #define MAKE_LIBNAME(NAME) (LIB_PREFIX _X(NAME) _X(".dylib"))
 #define FALLBACK_HOST_RID _X("osx.10.12")
@@ -176,7 +176,7 @@ namespace pal
 
     #define __cdecl    /* nothing */
     #define __stdcall  /* nothing */
-    #if !defined(__FreeBSD__)
+    #if !defined(TARGET_FREEBSD)
         #define __fastcall /* nothing */
     #else
         #include <sys/types.h>
index 789d18bdb2e63e1b709bdde39fc799740561b2d5..e3cfb3901506a102fbc5c2303744f240e2747eca 100644 (file)
 #include <ctime>
 #include <pwd.h>
 
-#if defined(__APPLE__)
+#if defined(TARGET_DARWIN)
 #include <mach-o/dyld.h>
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #endif
 
-#if defined(__LINUX__)
+#if defined(TARGET_LINUX)
 #define symlinkEntrypointExecutable "/proc/self/exe"
-#elif !defined(__APPLE__)
+#elif !defined(TARGET_DARWIN)
 #define symlinkEntrypointExecutable "/proc/curproc/exe"
 #endif
 
@@ -162,7 +162,7 @@ bool pal::get_loaded_library(
     /*out*/ pal::string_t *path)
 {
     pal::string_t library_name_local;
-#if defined(__APPLE__)
+#if defined(TARGET_DARWIN)
     if (!pal::is_path_rooted(library_name))
         library_name_local.append("@rpath/");
 #endif
@@ -467,7 +467,7 @@ bool pal::get_default_installation_dir(pal::string_t* recv)
     }
     //  ***************************
 
-#if defined(__APPLE__)
+#if defined(TARGET_DARWIN)
      recv->assign(_X("/usr/local/share/dotnet"));
 #else
      recv->assign(_X("/usr/share/dotnet"));
@@ -491,7 +491,7 @@ pal::string_t trim_quotes(pal::string_t stringToCleanup)
     return stringToCleanup;
 }
 
-#if defined(__APPLE__)
+#if defined(TARGET_DARWIN)
 pal::string_t pal::get_current_os_rid_platform()
 {
     pal::string_t ridOS;
@@ -531,7 +531,7 @@ pal::string_t pal::get_current_os_rid_platform()
 
     return ridOS;
 }
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
 // On FreeBSD get major verion. Minors should be compatible
 pal::string_t pal::get_current_os_rid_platform()
 {
@@ -679,7 +679,7 @@ pal::string_t pal::get_current_os_rid_platform()
 }
 #endif
 
-#if defined(__APPLE__)
+#if defined(TARGET_DARWIN)
 bool pal::get_own_executable_path(pal::string_t* recv)
 {
     uint32_t path_length = 0;
@@ -694,7 +694,7 @@ bool pal::get_own_executable_path(pal::string_t* recv)
     }
     return false;
 }
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
 bool pal::get_own_executable_path(pal::string_t* recv)
 {
     int mib[4];
@@ -903,7 +903,7 @@ bool pal::is_running_in_wow64()
 
 bool pal::are_paths_equal_with_normalized_casing(const string_t& path1, const string_t& path2)
 {
-#if defined(__APPLE__)
+#if defined(TARGET_DARWIN)
     // On Mac, paths are case-insensitive
     return (strcasecmp(path1.c_str(), path2.c_str()) == 0);
 #else
index 1e0ff1d985b49138772c19b7ad3abc187c343bc6..0cb6d2f91d9e92b9547521e7b0fecb9d67cd217c 100644 (file)
@@ -226,10 +226,10 @@ void pal::unload_library(dll_t library)
 static
 bool get_wow_mode_program_files(pal::string_t* recv)
 {
-#if defined(_TARGET_AMD64_)
-    pal::char_t* env_key = _X("ProgramFiles(x86)");
+#if defined(TARGET_AMD64)
+    const pal::char_t* env_key = _X("ProgramFiles(x86)");
 #else
-    pal::char_t* env_key = _X("ProgramFiles");
+    const pal::char_t* env_key = _X("ProgramFiles");
 #endif
 
     return get_file_path_from_env(env_key,recv);
@@ -274,7 +274,7 @@ bool pal::get_default_installation_dir(pal::string_t* recv)
     }
     //  ***************************
 
-    pal::char_t* program_files_dir;
+    const pal::char_t* program_files_dir;
     if (pal::is_running_in_wow64())
     {
         program_files_dir = _X("ProgramFiles(x86)");
@@ -296,7 +296,7 @@ bool pal::get_default_installation_dir(pal::string_t* recv)
 
 namespace
 {
-    void get_dotnet_install_location_registry_path(HKEY * key_hive, pal::string_t * sub_key, pal::char_t ** value)
+    void get_dotnet_install_location_registry_path(HKEY * key_hive, pal::string_t * sub_key, const pal::char_t ** value)
     {
         *key_hive = HKEY_LOCAL_MACHINE;
         // The registry search occurs in the 32-bit registry in all cases.
@@ -322,12 +322,12 @@ namespace
 
 bool pal::get_dotnet_self_registered_config_location(pal::string_t* recv)
 {
-#if !defined(_TARGET_AMD64_) && !defined(_TARGET_X86_)
+#if !defined(TARGET_AMD64) && !defined(TARGET_X86)
     return false;
 #else
     HKEY key_hive;
     pal::string_t sub_key;
-    pal::char_t* value;
+    const pal::char_t* value;
     get_dotnet_install_location_registry_path(&key_hive, &sub_key, &value);
 
     *recv = (key_hive == HKEY_CURRENT_USER ? _X("HKCU\\") : _X("HKLM\\")) + sub_key + _X("\\") + value;
@@ -337,7 +337,7 @@ bool pal::get_dotnet_self_registered_config_location(pal::string_t* recv)
 
 bool pal::get_dotnet_self_registered_dir(pal::string_t* recv)
 {
-#if !defined(_TARGET_AMD64_) && !defined(_TARGET_X86_)
+#if !defined(TARGET_AMD64) && !defined(TARGET_X86)
     //  Self-registered SDK installation directory is only supported for x64 and x86 architectures.
     return false;
 #else
@@ -354,7 +354,7 @@ bool pal::get_dotnet_self_registered_dir(pal::string_t* recv)
 
     HKEY hkeyHive;
     pal::string_t sub_key;
-    pal::char_t* value;
+    const pal::char_t* value;
     get_dotnet_install_location_registry_path(&hkeyHive, &sub_key, &value);
 
     // Must use RegOpenKeyEx to be able to specify KEY_WOW64_32KEY to access the 32-bit registry in all cases.
index 37f69a51f677dad8af4daaa21a356618cad95c57..0f9a176ba24369d4e1113d389d2d25947ea3b2d6 100644 (file)
@@ -20,7 +20,7 @@ namespace trace
     void println();
     void flush();
 
-    typedef void (*error_writer_fn)(const pal::char_t* message);
+    typedef void (__cdecl *error_writer_fn)(const pal::char_t* message);
 
     // Sets a callback which is called whenever error is to be written
     // The setting is per-thread (thread local). If no error writer is set for a given thread
index f176729505d6fb224ca6e9b7560023fbb95ba02b..4e0d8ab3170659e266debf84e84f39dddc7be55d 100644 (file)
@@ -187,13 +187,13 @@ pal::string_t get_replaced_char(const pal::string_t& path, pal::char_t match, pa
 
 const pal::char_t* get_arch()
 {
-#if defined(_TARGET_AMD64_)
+#if defined(TARGET_AMD64)
     return _X("x64");
-#elif defined(_TARGET_X86_)
+#elif defined(TARGET_X86)
     return _X("x86");
-#elif defined(_TARGET_ARM_)
+#elif defined(TARGET_ARM)
     return _X("arm");
-#elif defined(_TARGET_ARM64_)
+#elif defined(TARGET_ARM64)
     return _X("arm64");
 #else
 #error "Unknown target"
index 020b45b71802147db041d833dc1f1f7a073c92c0..c9afbb68466c12096a215531473deb6c1db3de78 100644 (file)
@@ -11,7 +11,7 @@
 #define _STRINGIFY(s) _X(s)
 #if defined(_WIN32)
 #define DOTNET_CORE_INSTALL_PREREQUISITES_URL _X("https://go.microsoft.com/fwlink/?linkid=798306")
-#elif defined(__APPLE__)
+#elif defined(TARGET_DARWIN)
 #define DOTNET_CORE_INSTALL_PREREQUISITES_URL _X("https://go.microsoft.com/fwlink/?linkid=2063366")
 #else
 #define DOTNET_CORE_INSTALL_PREREQUISITES_URL _X("https://go.microsoft.com/fwlink/?linkid=2063370")
@@ -61,7 +61,7 @@ bool test_only_getenv(const pal::char_t* name, pal::string_t* recv);
 class propagate_error_writer_t
 {
 public:
-    typedef trace::error_writer_fn(*set_error_writer_fn)(trace::error_writer_fn error_writer);
+    typedef trace::error_writer_fn(__cdecl *set_error_writer_fn)(trace::error_writer_fn error_writer);
 
 private:
     set_error_writer_fn m_set_error_writer;
index b248e27b50a121feca4ee3fe960ae6d76b20c908..5c7d766a87ddf72ad8035cc96c82c428c967b732 100644 (file)
@@ -44,7 +44,7 @@ namespace
     std::atomic<bool> g_context_initializing(false);
     std::condition_variable g_context_initializing_cv;
 
-    int create_coreclr()
+    int HOSTPOLICY_CALLTYPE create_coreclr()
     {
         int rc;
         {
@@ -266,7 +266,7 @@ int run_app_for_context(
     return exit_code;
 }
 
-int run_app(const int argc, const pal::char_t *argv[])
+int HOSTPOLICY_CALLTYPE run_app(const int argc, const pal::char_t *argv[])
 {
     const std::shared_ptr<hostpolicy_context_t> context = get_hostpolicy_context(/*require_runtime*/ true);
     if (context == nullptr)
@@ -439,7 +439,7 @@ int corehost_libhost_init(const hostpolicy_init_t &hostpolicy_init, const pal::s
 
 namespace
 {
-    int get_delegate(coreclr_delegate_type type, void **delegate)
+    int HOSTPOLICY_CALLTYPE get_delegate(coreclr_delegate_type type, void **delegate)
     {
         if (delegate == nullptr)
             return StatusCode::InvalidArgFailure;
@@ -492,7 +492,7 @@ namespace
         }
     }
 
-    int get_property(const pal::char_t *key, const pal::char_t **value)
+    int HOSTPOLICY_CALLTYPE get_property(const pal::char_t *key, const pal::char_t **value)
     {
         if (key == nullptr)
             return StatusCode::InvalidArgFailure;
@@ -507,7 +507,7 @@ namespace
         return StatusCode::Success;
     }
 
-    int set_property(const pal::char_t *key, const pal::char_t *value)
+    int HOSTPOLICY_CALLTYPE set_property(const pal::char_t *key, const pal::char_t *value)
     {
         if (key == nullptr)
             return StatusCode::InvalidArgFailure;
@@ -531,7 +531,7 @@ namespace
         return StatusCode::Success;
     }
 
-    int get_properties(size_t * count, const pal::char_t **keys, const pal::char_t **values)
+    int HOSTPOLICY_CALLTYPE get_properties(size_t * count, const pal::char_t **keys, const pal::char_t **values)
     {
         if (count == nullptr)
             return StatusCode::InvalidArgFailure;
diff --git a/src/installer/corehost/cli/ijwhost/AMD64/asmhelpers.asm b/src/installer/corehost/cli/ijwhost/AMD64/asmhelpers.asm
deleted file mode 100644 (file)
index fd377b0..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-; 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.
-
-include AsmMacros.inc
-
-extern  start_runtime_and_get_target_address:proc
-
-; Stack setup at time of call to start_runtime_and_get_target_address
-;   32-byte scratch space
-;   xmm0 (saved incoming arg)
-;   xmm1 (saved incoming arg)
-;   xmm2 (saved incoming arg)
-;   xmm3 (saved incoming arg)
-;   8-byte padding
-;   return address
-;   rcx (saved incoming arg)    <- 16-byte aligned scratch space of caller
-;   rdx (saved incoming arg)
-;   r8  (saved incoming arg)
-;   r9  (saved incoming arg)
-
-SIZEOF_SCRATCH_SPACE                equ 20h
-SIZEOF_FP_ARG_SPILL                 equ 10h*4   ; == 40h
-SIZEOF_PADDING                      equ 8h
-
-SIZEOF_ALLOC_STACK                  equ SIZEOF_SCRATCH_SPACE + SIZEOF_FP_ARG_SPILL + SIZEOF_PADDING
-
-SIZEOF_RET_ADDR                     equ 8h
-
-; rcx, rdx, r8, r9 need preserving, in the scratch area
-SIZEOF_INCOMING_ARG_SPILL           equ 8h*4    ; == 20h
-
-; xmm0 - xmm3 need preserving.
-OFFSETOF_SCRATCH_SPACE              equ 0h
-OFFSETOF_FP_ARG_SPILL               equ OFFSETOF_SCRATCH_SPACE + SIZEOF_SCRATCH_SPACE
-OFFSETOF_PADDING                    equ OFFSETOF_FP_ARG_SPILL + SIZEOF_FP_ARG_SPILL
-OFFSETOF_RET_ADDR                   equ OFFSETOF_PADDING + SIZEOF_PADDING
-OFFSETOF_INCOMING_ARG_SPILL         equ OFFSETOF_RET_ADDR + SIZEOF_RET_ADDR
-
-NESTED_ENTRY start_runtime_thunk_stub, _TEXT
-    ; Allocate the stack space
-    alloc_stack     SIZEOF_ALLOC_STACK
-
-    ; Save the incoming floating point arguments
-    save_xmm128     xmm0,    0h + OFFSETOF_FP_ARG_SPILL
-    save_xmm128     xmm1,   10h + OFFSETOF_FP_ARG_SPILL
-    save_xmm128     xmm2,   20h + OFFSETOF_FP_ARG_SPILL
-    save_xmm128     xmm3,   30h + OFFSETOF_FP_ARG_SPILL
-
-    ; Save the incoming arguments into the scratch area
-    save_reg        rcx,     0h + OFFSETOF_INCOMING_ARG_SPILL
-    save_reg        rdx,     8h + OFFSETOF_INCOMING_ARG_SPILL
-    save_reg        r8,     10h + OFFSETOF_INCOMING_ARG_SPILL
-    save_reg        r9,     18h + OFFSETOF_INCOMING_ARG_SPILL
-
-    END_PROLOGUE
-
-    ; Secret arg is in r10.
-    mov             rcx,    r10
-
-    ; Call helper func.
-    call            start_runtime_and_get_target_address
-
-    ; Restore the incoming floating point arguments
-    movdqa          xmm0,   [rsp +  0h + OFFSETOF_FP_ARG_SPILL]
-    movdqa          xmm1,   [rsp + 10h + OFFSETOF_FP_ARG_SPILL]
-    movdqa          xmm2,   [rsp + 20h + OFFSETOF_FP_ARG_SPILL]
-    movdqa          xmm3,   [rsp + 30h + OFFSETOF_FP_ARG_SPILL]
-
-    ; Restore the incoming arguments
-    mov             rcx,    [rsp +  0h + OFFSETOF_INCOMING_ARG_SPILL]
-    mov             rdx,    [rsp +  8h + OFFSETOF_INCOMING_ARG_SPILL]
-    mov             r8,     [rsp + 10h + OFFSETOF_INCOMING_ARG_SPILL]
-    mov             r9,     [rsp + 18h + OFFSETOF_INCOMING_ARG_SPILL]
-
-    ; Restore the stack
-    add             rsp,    SIZEOF_ALLOC_STACK
-
-    ; Jump to the target
-    TAILJMP_RAX
-NESTED_END start_runtime_thunk_stub, _TEXT
-
-;LEAF_ENTRY start_runtime_thunk_stubSample, _TEXT
-;    mov             r10,    1234567812345678h
-;    mov             r11,    1234123412341234h
-;    jmp             r11
-;LEAF_END start_runtime_thunk_stubSample, _TEXT
-
-    end
-
diff --git a/src/installer/corehost/cli/ijwhost/AMD64/asmmacros.inc b/src/installer/corehost/cli/ijwhost/AMD64/asmmacros.inc
deleted file mode 100644 (file)
index 73378b8..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-; 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.
-
-;
-; Define macros to build unwind data for prologues.
-;
-
-push_reg macro Reg
-
-        push    Reg
-        .pushreg Reg
-
-        endm
-
-push_eflags macro
-
-        pushfq
-        .allocstack 8
-
-        endm
-
-alloc_stack macro Size
-
-        sub     rsp, Size
-        .allocstack Size
-
-        endm
-
-save_reg macro Reg, Offset
-
-        mov     Offset[rsp], Reg
-        .savereg Reg, Offset
-
-        endm
-
-save_xmm macro Reg, Offset
-
-        movq    Offset[rsp], Reg
-        .savexmm Reg, Offset
-
-        endm
-
-save_xmm128 macro Reg, Offset
-
-        movdqa  Offset[rsp], Reg
-        .savexmm128 Reg, Offset
-
-        endm
-
-push_frame macro Code
-
-        .pushframe Code
-
-        endm
-
-set_frame macro Reg, Offset
-
-if Offset
-
-        lea     Reg, Offset[rsp]
-
-else
-
-        mov     reg, rsp
-
-endif
-
-        .setframe Reg, Offset
-
-        endm
-
-END_PROLOGUE macro
-
-        .endprolog
-
-        endm
-
-;
-; Define alternate entry macro.
-;
-
-ALTERNATE_ENTRY macro Name
-
-Name:
-
-        endm
-;
-; Define function entry/end macros.
-;
-
-LEAF_ENTRY macro Name, Section
-
-Section segment para 'CODE'
-
-        align   16
-
-        public  Name
-Name    proc
-
-        endm
-
-LEAF_END macro Name, section
-
-Name    endp
-
-Section ends
-
-        endm
-
-NESTED_ENTRY macro Name, Section, Handler
-
-Section segment para 'CODE'
-
-        align   16
-
-        public  Name
-
-ifb <Handler>
-
-Name    proc    frame
-
-else
-
-Name    proc    frame:Handler
-
-endif
-
-        endm
-
-NESTED_END macro Name, section
-
-Name    endp
-
-Section ends
-
-        endm
-
-
-
-
-; 
-; Appropriate instructions for certain specific scenarios:
-;  - REPRET: should be used as the return instruction when the return is a branch 
-;            target or immediately follows a conditional branch 
-;  - TAILCALL_RAX: ("jmp rax") should be used for tailcalls, this emits an instruction 
-;            sequence which is recognized by the unwinder as a valid epilogue terminator
-;
-REPRET      TEXTEQU <DB 0F3h, 0C3h>
-TAILJMP_RAX TEXTEQU <DB 048h, 0FFh, 0E0h>
-NOP_4BYTE   TEXTEQU <DB 066h, 066h, 066h, 090h>
-        
-
-        
diff --git a/src/installer/corehost/cli/ijwhost/AMD64/bootstrap_thunk.cpp b/src/installer/corehost/cli/ijwhost/AMD64/bootstrap_thunk.cpp
deleted file mode 100644 (file)
index c0f618e..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-// 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.
-
-#include "bootstrap_thunk.h"
-#include "corhdr.h"
-
-namespace
-{
-    // 49 BA 78 56 34 12 78 56 34 12 mov         r10,1234567812345678h
-    // 49 BB 34 12 34 12 34 12 34 12 mov         r11,1234123412341234h
-    // 41 FF E3                      jmp         r11
-    BYTE mov_r10_instruction[2] = {0x49, 0xBA};
-    BYTE mov_r11_instruction[2] = {0x49, 0xBB};
-    BYTE jmp_r11_instruction[3] = {0x41, 0xFF, 0xE3};
-}
-
-//=================================================================================
-// Get thunk from the return address that the call instruction would have pushed
-bootstrap_thunk *bootstrap_thunk::get_thunk_from_cookie(std::uintptr_t cookie)
-{
-    return (bootstrap_thunk*)cookie;
-}
-
-//=================================================================================
-//
-bootstrap_thunk *bootstrap_thunk::get_thunk_from_entrypoint(std::uintptr_t entryAddr)
-{
-    return (bootstrap_thunk *)
-        ((std::uintptr_t)entryAddr - offsetof(bootstrap_thunk, m_mov_r10));
-}
-
-//=================================================================================
-// Returns the slot address of the vtable entry for this thunk
-std::uintptr_t *bootstrap_thunk::get_slot_address()
-{
-    return m_slot;
-}
-
-//=================================================================================
-// Returns the pal::dll_t for this thunk's module
-pal::dll_t bootstrap_thunk::get_dll_handle()
-{
-    return m_dll;
-}
-
-//=================================================================================
-// Returns the token of this thunk
-std::uint32_t bootstrap_thunk::get_token()
-{
-    return m_token;
-}
-
-//=================================================================================
-std::uintptr_t bootstrap_thunk::get_entrypoint()
-{
-    return (std::uintptr_t)&m_mov_r10[0];
-}
-
-//=================================================================================
-// Initializes the thunk to point to the bootstrap helper that will load the
-// runtime and perform the real thunk initialization.
-//
-void bootstrap_thunk::initialize(std::uintptr_t pThunkInitFcn,
-                                          pal::dll_t dll,
-                                          std::uint32_t token,
-                                          std::uintptr_t *pSlot)
-{
-    // Initialize the jump thunk.
-    memcpy(&m_mov_r10[0], &mov_r10_instruction[0], sizeof(mov_r10_instruction));
-    (*((void **)&m_val_r10[0])) = (void *)this;
-    memcpy(&m_mov_r11[0], &mov_r11_instruction[0], sizeof(mov_r11_instruction));
-    (*((void **)&m_val_r11[0])) = (void *)pThunkInitFcn;
-    memcpy(&m_jmp_r11[0], &jmp_r11_instruction[0], sizeof(jmp_r11_instruction));
-
-    // Fill out the rest of the info
-    m_token = token;
-    m_dll = dll;
-    m_slot = pSlot;
-}
diff --git a/src/installer/corehost/cli/ijwhost/AMD64/bootstrap_thunk.h b/src/installer/corehost/cli/ijwhost/AMD64/bootstrap_thunk.h
deleted file mode 100644 (file)
index 6b4ecda..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// 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.
-
-#ifndef IJW_BOOTSTRAP_THUNK_H
-#define IJW_BOOTSTRAP_THUNK_H
-
-#if !defined(_TARGET_AMD64_)
-#error "This file should only be included on amd64 builds."
-#endif
-
-#include "pal.h"
-#include "corhdr.h"
-
-extern "C" void start_runtime_thunk_stub();
-
-#include <pshpack1.h>
-class bootstrap_thunk
-{
-private:
-
-    BYTE                    m_mov_r10[2];
-    BYTE                    m_val_r10[8];
-    BYTE                    m_mov_r11[2];
-    BYTE                    m_val_r11[8];
-    BYTE                    m_jmp_r11[3];
-    BYTE                    m_padding[1];
-    // Data for the thunk
-    std::uint32_t           m_token;
-    pal::dll_t              m_dll;
-    std::uintptr_t          *m_slot;
-public:
-    // Get thunk from the return address that the call instruction would have pushed
-    static bootstrap_thunk *get_thunk_from_cookie(std::uintptr_t cookie);
-
-    // Get thunk from the return address that the call instruction would have pushed
-    static bootstrap_thunk *get_thunk_from_entrypoint(std::uintptr_t entryAddr);
-
-    // Initializes the thunk to point to pThunkInitFcn that will load the
-    // runtime and perform the real thunk initialization.
-    void initialize(std::uintptr_t pThunkInitFcn,
-                    pal::dll_t dll,
-                    std::uint32_t token,
-                    std::uintptr_t *pSlot);
-
-    // Returns the slot address of the vtable entry for this thunk
-    std::uintptr_t *get_slot_address();
-
-    // Returns the pal::dll_t for this thunk's module
-    pal::dll_t get_dll_handle();
-
-    // Returns the token of this thunk
-    std::uint32_t get_token();
-
-    std::uintptr_t get_entrypoint();
-};
-#include <poppack.h>
-
-#endif
\ No newline at end of file
index c89996f6e1ce4c4ee93fe3478f008ea038d70792..7174983993bafc6c8e69f564fe9bf17951f86517 100644 (file)
@@ -8,7 +8,7 @@ set(DOTNET_PROJECT_NAME "ijwhost")
 
 # Include directories
 include_directories(../fxr)
-include_directories(${ARCH_SPECIFIC_FOLDER_NAME})
+include_directories(${ARCH_SOURCES_DIR})
 
 # CMake does not recommend using globbing since it messes with the freshness checks
 set(SOURCES
@@ -17,7 +17,7 @@ set(SOURCES
     ../fxr_resolver.cpp
     pedecoder.cpp
     bootstrap_thunk_chunk.cpp
-    ${ARCH_SPECIFIC_FOLDER_NAME}/bootstrap_thunk.cpp
+    ${ARCH_SOURCES_DIR}/bootstrap_thunk.cpp
 )
 
 if(CLR_CMAKE_TARGET_WIN32)
@@ -26,7 +26,7 @@ if(CLR_CMAKE_TARGET_WIN32)
 endif()
 
 set (ASM_HELPERS_SOURCES
-    ${ARCH_SPECIFIC_FOLDER_NAME}/asmhelpers.asm)
+    ${ARCH_SOURCES_DIR}/asmhelpers.asm)
 
 add_definitions(-DFEATURE_LIBHOST=1)
 
diff --git a/src/installer/corehost/cli/ijwhost/amd64/asmhelpers.asm b/src/installer/corehost/cli/ijwhost/amd64/asmhelpers.asm
new file mode 100644 (file)
index 0000000..fd377b0
--- /dev/null
@@ -0,0 +1,90 @@
+; 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.
+
+include AsmMacros.inc
+
+extern  start_runtime_and_get_target_address:proc
+
+; Stack setup at time of call to start_runtime_and_get_target_address
+;   32-byte scratch space
+;   xmm0 (saved incoming arg)
+;   xmm1 (saved incoming arg)
+;   xmm2 (saved incoming arg)
+;   xmm3 (saved incoming arg)
+;   8-byte padding
+;   return address
+;   rcx (saved incoming arg)    <- 16-byte aligned scratch space of caller
+;   rdx (saved incoming arg)
+;   r8  (saved incoming arg)
+;   r9  (saved incoming arg)
+
+SIZEOF_SCRATCH_SPACE                equ 20h
+SIZEOF_FP_ARG_SPILL                 equ 10h*4   ; == 40h
+SIZEOF_PADDING                      equ 8h
+
+SIZEOF_ALLOC_STACK                  equ SIZEOF_SCRATCH_SPACE + SIZEOF_FP_ARG_SPILL + SIZEOF_PADDING
+
+SIZEOF_RET_ADDR                     equ 8h
+
+; rcx, rdx, r8, r9 need preserving, in the scratch area
+SIZEOF_INCOMING_ARG_SPILL           equ 8h*4    ; == 20h
+
+; xmm0 - xmm3 need preserving.
+OFFSETOF_SCRATCH_SPACE              equ 0h
+OFFSETOF_FP_ARG_SPILL               equ OFFSETOF_SCRATCH_SPACE + SIZEOF_SCRATCH_SPACE
+OFFSETOF_PADDING                    equ OFFSETOF_FP_ARG_SPILL + SIZEOF_FP_ARG_SPILL
+OFFSETOF_RET_ADDR                   equ OFFSETOF_PADDING + SIZEOF_PADDING
+OFFSETOF_INCOMING_ARG_SPILL         equ OFFSETOF_RET_ADDR + SIZEOF_RET_ADDR
+
+NESTED_ENTRY start_runtime_thunk_stub, _TEXT
+    ; Allocate the stack space
+    alloc_stack     SIZEOF_ALLOC_STACK
+
+    ; Save the incoming floating point arguments
+    save_xmm128     xmm0,    0h + OFFSETOF_FP_ARG_SPILL
+    save_xmm128     xmm1,   10h + OFFSETOF_FP_ARG_SPILL
+    save_xmm128     xmm2,   20h + OFFSETOF_FP_ARG_SPILL
+    save_xmm128     xmm3,   30h + OFFSETOF_FP_ARG_SPILL
+
+    ; Save the incoming arguments into the scratch area
+    save_reg        rcx,     0h + OFFSETOF_INCOMING_ARG_SPILL
+    save_reg        rdx,     8h + OFFSETOF_INCOMING_ARG_SPILL
+    save_reg        r8,     10h + OFFSETOF_INCOMING_ARG_SPILL
+    save_reg        r9,     18h + OFFSETOF_INCOMING_ARG_SPILL
+
+    END_PROLOGUE
+
+    ; Secret arg is in r10.
+    mov             rcx,    r10
+
+    ; Call helper func.
+    call            start_runtime_and_get_target_address
+
+    ; Restore the incoming floating point arguments
+    movdqa          xmm0,   [rsp +  0h + OFFSETOF_FP_ARG_SPILL]
+    movdqa          xmm1,   [rsp + 10h + OFFSETOF_FP_ARG_SPILL]
+    movdqa          xmm2,   [rsp + 20h + OFFSETOF_FP_ARG_SPILL]
+    movdqa          xmm3,   [rsp + 30h + OFFSETOF_FP_ARG_SPILL]
+
+    ; Restore the incoming arguments
+    mov             rcx,    [rsp +  0h + OFFSETOF_INCOMING_ARG_SPILL]
+    mov             rdx,    [rsp +  8h + OFFSETOF_INCOMING_ARG_SPILL]
+    mov             r8,     [rsp + 10h + OFFSETOF_INCOMING_ARG_SPILL]
+    mov             r9,     [rsp + 18h + OFFSETOF_INCOMING_ARG_SPILL]
+
+    ; Restore the stack
+    add             rsp,    SIZEOF_ALLOC_STACK
+
+    ; Jump to the target
+    TAILJMP_RAX
+NESTED_END start_runtime_thunk_stub, _TEXT
+
+;LEAF_ENTRY start_runtime_thunk_stubSample, _TEXT
+;    mov             r10,    1234567812345678h
+;    mov             r11,    1234123412341234h
+;    jmp             r11
+;LEAF_END start_runtime_thunk_stubSample, _TEXT
+
+    end
+
diff --git a/src/installer/corehost/cli/ijwhost/amd64/asmmacros.inc b/src/installer/corehost/cli/ijwhost/amd64/asmmacros.inc
new file mode 100644 (file)
index 0000000..73378b8
--- /dev/null
@@ -0,0 +1,154 @@
+; 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.
+
+;
+; Define macros to build unwind data for prologues.
+;
+
+push_reg macro Reg
+
+        push    Reg
+        .pushreg Reg
+
+        endm
+
+push_eflags macro
+
+        pushfq
+        .allocstack 8
+
+        endm
+
+alloc_stack macro Size
+
+        sub     rsp, Size
+        .allocstack Size
+
+        endm
+
+save_reg macro Reg, Offset
+
+        mov     Offset[rsp], Reg
+        .savereg Reg, Offset
+
+        endm
+
+save_xmm macro Reg, Offset
+
+        movq    Offset[rsp], Reg
+        .savexmm Reg, Offset
+
+        endm
+
+save_xmm128 macro Reg, Offset
+
+        movdqa  Offset[rsp], Reg
+        .savexmm128 Reg, Offset
+
+        endm
+
+push_frame macro Code
+
+        .pushframe Code
+
+        endm
+
+set_frame macro Reg, Offset
+
+if Offset
+
+        lea     Reg, Offset[rsp]
+
+else
+
+        mov     reg, rsp
+
+endif
+
+        .setframe Reg, Offset
+
+        endm
+
+END_PROLOGUE macro
+
+        .endprolog
+
+        endm
+
+;
+; Define alternate entry macro.
+;
+
+ALTERNATE_ENTRY macro Name
+
+Name:
+
+        endm
+;
+; Define function entry/end macros.
+;
+
+LEAF_ENTRY macro Name, Section
+
+Section segment para 'CODE'
+
+        align   16
+
+        public  Name
+Name    proc
+
+        endm
+
+LEAF_END macro Name, section
+
+Name    endp
+
+Section ends
+
+        endm
+
+NESTED_ENTRY macro Name, Section, Handler
+
+Section segment para 'CODE'
+
+        align   16
+
+        public  Name
+
+ifb <Handler>
+
+Name    proc    frame
+
+else
+
+Name    proc    frame:Handler
+
+endif
+
+        endm
+
+NESTED_END macro Name, section
+
+Name    endp
+
+Section ends
+
+        endm
+
+
+
+
+; 
+; Appropriate instructions for certain specific scenarios:
+;  - REPRET: should be used as the return instruction when the return is a branch 
+;            target or immediately follows a conditional branch 
+;  - TAILCALL_RAX: ("jmp rax") should be used for tailcalls, this emits an instruction 
+;            sequence which is recognized by the unwinder as a valid epilogue terminator
+;
+REPRET      TEXTEQU <DB 0F3h, 0C3h>
+TAILJMP_RAX TEXTEQU <DB 048h, 0FFh, 0E0h>
+NOP_4BYTE   TEXTEQU <DB 066h, 066h, 066h, 090h>
+        
+
+        
diff --git a/src/installer/corehost/cli/ijwhost/amd64/bootstrap_thunk.cpp b/src/installer/corehost/cli/ijwhost/amd64/bootstrap_thunk.cpp
new file mode 100644 (file)
index 0000000..c0f618e
--- /dev/null
@@ -0,0 +1,80 @@
+// 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.
+
+#include "bootstrap_thunk.h"
+#include "corhdr.h"
+
+namespace
+{
+    // 49 BA 78 56 34 12 78 56 34 12 mov         r10,1234567812345678h
+    // 49 BB 34 12 34 12 34 12 34 12 mov         r11,1234123412341234h
+    // 41 FF E3                      jmp         r11
+    BYTE mov_r10_instruction[2] = {0x49, 0xBA};
+    BYTE mov_r11_instruction[2] = {0x49, 0xBB};
+    BYTE jmp_r11_instruction[3] = {0x41, 0xFF, 0xE3};
+}
+
+//=================================================================================
+// Get thunk from the return address that the call instruction would have pushed
+bootstrap_thunk *bootstrap_thunk::get_thunk_from_cookie(std::uintptr_t cookie)
+{
+    return (bootstrap_thunk*)cookie;
+}
+
+//=================================================================================
+//
+bootstrap_thunk *bootstrap_thunk::get_thunk_from_entrypoint(std::uintptr_t entryAddr)
+{
+    return (bootstrap_thunk *)
+        ((std::uintptr_t)entryAddr - offsetof(bootstrap_thunk, m_mov_r10));
+}
+
+//=================================================================================
+// Returns the slot address of the vtable entry for this thunk
+std::uintptr_t *bootstrap_thunk::get_slot_address()
+{
+    return m_slot;
+}
+
+//=================================================================================
+// Returns the pal::dll_t for this thunk's module
+pal::dll_t bootstrap_thunk::get_dll_handle()
+{
+    return m_dll;
+}
+
+//=================================================================================
+// Returns the token of this thunk
+std::uint32_t bootstrap_thunk::get_token()
+{
+    return m_token;
+}
+
+//=================================================================================
+std::uintptr_t bootstrap_thunk::get_entrypoint()
+{
+    return (std::uintptr_t)&m_mov_r10[0];
+}
+
+//=================================================================================
+// Initializes the thunk to point to the bootstrap helper that will load the
+// runtime and perform the real thunk initialization.
+//
+void bootstrap_thunk::initialize(std::uintptr_t pThunkInitFcn,
+                                          pal::dll_t dll,
+                                          std::uint32_t token,
+                                          std::uintptr_t *pSlot)
+{
+    // Initialize the jump thunk.
+    memcpy(&m_mov_r10[0], &mov_r10_instruction[0], sizeof(mov_r10_instruction));
+    (*((void **)&m_val_r10[0])) = (void *)this;
+    memcpy(&m_mov_r11[0], &mov_r11_instruction[0], sizeof(mov_r11_instruction));
+    (*((void **)&m_val_r11[0])) = (void *)pThunkInitFcn;
+    memcpy(&m_jmp_r11[0], &jmp_r11_instruction[0], sizeof(jmp_r11_instruction));
+
+    // Fill out the rest of the info
+    m_token = token;
+    m_dll = dll;
+    m_slot = pSlot;
+}
diff --git a/src/installer/corehost/cli/ijwhost/amd64/bootstrap_thunk.h b/src/installer/corehost/cli/ijwhost/amd64/bootstrap_thunk.h
new file mode 100644 (file)
index 0000000..2d8e407
--- /dev/null
@@ -0,0 +1,59 @@
+// 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.
+
+#ifndef IJW_BOOTSTRAP_THUNK_H
+#define IJW_BOOTSTRAP_THUNK_H
+
+#if !defined(TARGET_AMD64)
+#error "This file should only be included on amd64 builds."
+#endif
+
+#include "pal.h"
+#include "corhdr.h"
+
+extern "C" void start_runtime_thunk_stub();
+
+#include <pshpack1.h>
+class bootstrap_thunk
+{
+private:
+
+    BYTE                    m_mov_r10[2];
+    BYTE                    m_val_r10[8];
+    BYTE                    m_mov_r11[2];
+    BYTE                    m_val_r11[8];
+    BYTE                    m_jmp_r11[3];
+    BYTE                    m_padding[1];
+    // Data for the thunk
+    std::uint32_t           m_token;
+    pal::dll_t              m_dll;
+    std::uintptr_t          *m_slot;
+public:
+    // Get thunk from the return address that the call instruction would have pushed
+    static bootstrap_thunk *get_thunk_from_cookie(std::uintptr_t cookie);
+
+    // Get thunk from the return address that the call instruction would have pushed
+    static bootstrap_thunk *get_thunk_from_entrypoint(std::uintptr_t entryAddr);
+
+    // Initializes the thunk to point to pThunkInitFcn that will load the
+    // runtime and perform the real thunk initialization.
+    void initialize(std::uintptr_t pThunkInitFcn,
+                    pal::dll_t dll,
+                    std::uint32_t token,
+                    std::uintptr_t *pSlot);
+
+    // Returns the slot address of the vtable entry for this thunk
+    std::uintptr_t *get_slot_address();
+
+    // Returns the pal::dll_t for this thunk's module
+    pal::dll_t get_dll_handle();
+
+    // Returns the token of this thunk
+    std::uint32_t get_token();
+
+    std::uintptr_t get_entrypoint();
+};
+#include <poppack.h>
+
+#endif
index 516e369cfe04bdbefce09b602b5dafa0b68589af..4d27433f03584f27b3cf72cfbcd822f9cc44d1b9 100644 (file)
@@ -5,7 +5,7 @@
 #ifndef IJW_BOOTSTRAP_THUNK_H
 #define IJW_BOOTSTRAP_THUNK_H
 
-#if !defined(_TARGET_ARM_)
+#if !defined(TARGET_ARM)
 #error "This file should only be included on arm builds."
 #endif
 
@@ -53,4 +53,4 @@ public:
 };
 #include <poppack.h>
 
-#endif
\ No newline at end of file
+#endif
index 1e38d3ebffd7b475d45ac9a07ce52bcc9e3cd8e9..b486bd1c7a963c33fd5735be2f53bf81f8ca80f3 100644 (file)
@@ -5,7 +5,7 @@
 #ifndef IJW_BOOTSTRAP_THUNK_H
 #define IJW_BOOTSTRAP_THUNK_H
 
-#if !defined(_TARGET_ARM64_)
+#if !defined(TARGET_ARM64)
 #error "This file should only be included on arm64 builds."
 #endif
 
@@ -53,4 +53,4 @@ public:
 };
 #include <poppack.h>
 
-#endif
\ No newline at end of file
+#endif
index 8ffbf8c751fd585c690ba0b659c38063758daeff..63994a9f58d6c82867d470e81ada036968261433 100644 (file)
@@ -5,7 +5,7 @@
 #ifndef IJW_BOOTSTRAP_THUNK_H
 #define IJW_BOOTSTRAP_THUNK_H
 
-#if !defined(_TARGET_X86_)
+#if !defined(TARGET_X86)
 #error "This file should only be included on x86 builds."
 #endif
 
@@ -56,4 +56,4 @@ public:
 };
 #include <poppack.h>
 
-#endif
\ No newline at end of file
+#endif
index 2b1e1c892cb70438be98964df834aa6c265b2258..97e8b70b2011dc6d70338d5cc9495cc62e83c5c5 100644 (file)
@@ -26,7 +26,7 @@ namespace
     bootstrap_thunk_chunk* g_pVtableBootstrapThunkChunkList;
 
     // We swallow the trace messages so we don't output to a stderr of a process that we do not own unless tracing is enabled.
-    void swallow_trace(const pal::char_t* msg)
+    void __cdecl swallow_trace(const pal::char_t* msg)
     {
         (void)msg;
     }
@@ -187,4 +187,4 @@ bool are_thunks_installed_for_module(pal::dll_t instance)
     }
 
     return false;
-}
\ No newline at end of file
+}
index d7fb4a35082ce8b5842400cf1f122583fe5aed46..dc0cd695f905dcb445cf42bd76cc334bdccfa244 100644 (file)
@@ -12,7 +12,7 @@
 namespace
 {
     // Swallow the trace messages so we don't output to stderr of a process that we do not own unless tracing is enabled.
-    void swallow_trace(const pal::char_t* msg)
+    void __cdecl swallow_trace(const pal::char_t* msg)
     {
         (void)msg;
     }
index aa8fda4a385a52c2c9eb2bce5db61bcfd09848e1..ba97a2d1c29aed44b94fc637b9edbf22a5a0315d 100644 (file)
@@ -20,7 +20,7 @@ void reset_redirected_error_writer()
     get_redirected_error_stream().swap(newstream);
 }
 
-void redirected_error_writer(const pal::char_t* msg)
+void __cdecl redirected_error_writer(const pal::char_t* msg)
 {
     get_redirected_error_stream() << msg;
 }
index 7b330bd368b30ef53ffcb7145eaf41d0e907ad38..8022929d444d923e9a5a70cc8d06bb1af6848fd7 100644 (file)
@@ -9,8 +9,8 @@
 
 void reset_redirected_error_writer();
 
-void redirected_error_writer(const pal::char_t* msg);
+void __cdecl redirected_error_writer(const pal::char_t* msg);
 
 pal::string_t get_redirected_error_string();
 
-#endif /* _COREHOST_CLI_REDIRECTED_ERROR_WRITER_H_ */
\ No newline at end of file
+#endif /* _COREHOST_CLI_REDIRECTED_ERROR_WRITER_H_ */
diff --git a/src/installer/functions.cmake b/src/installer/functions.cmake
deleted file mode 100644 (file)
index 58a6c81..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-
-# 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_TARGET_ARCH_ARM AND CLR_CMAKE_TARGET_WIN32)
-        list(APPEND INC_DIRECTORIES /I${dir})
-      else()
-        list(APPEND INC_DIRECTORIES -I${dir})
-      endif(CLR_CMAKE_TARGET_ARCH_ARM AND CLR_CMAKE_TARGET_WIN32)
-
-    endforeach()
-    set(${IncludeDirectories} ${INC_DIRECTORIES} PARENT_SCOPE)
-endfunction(get_include_directories)
-
-#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}
-        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_compile_asm(ASM_FILES file1 [file2 ...] OUTPUT_OBJECTS [variableName])
-function(preprocess_compile_asm)
-  set(options "")
-  set(oneValueArgs OUTPUT_OBJECTS)
-  set(multiValueArgs ASM_FILES)
-  cmake_parse_arguments(PARSE_ARGV 0 COMPILE_ASM "${options}" "${oneValueArgs}" "${multiValueArgs}")
-
-  get_include_directories_asm(ASM_INCLUDE_DIRECTORIES)
-
-  set (ASSEMBLED_OBJECTS "")
-
-  foreach(ASM_FILE ${COMPILE_ASM_ASM_FILES})
-    # 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})
-
-    # We do not pass any defines since we have already done pre-processing above
-    set (ASM_CMDLINE "-o ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj ${ASM_PREPROCESSED_FILE}")
-
-    # Generate the batch file that will invoke the assembler
-    file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/runasm_${name}.cmd" ASM_SCRIPT_FILE)
-
-    file(GENERATE OUTPUT "${ASM_SCRIPT_FILE}"
-        CONTENT "\"${CMAKE_ASM_MASM_COMPILER}\" -g ${ASM_INCLUDE_DIRECTORIES} ${ASM_CMDLINE}")
-
-    message("Generated  - ${ASM_SCRIPT_FILE}")
-
-    # Need to compile asm file using custom command as include directories are not provided to asm compiler
-    add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj
-                        COMMAND ${ASM_SCRIPT_FILE}
-                        DEPENDS ${ASM_PREPROCESSED_FILE}
-                        COMMENT "Assembling ${ASM_PREPROCESSED_FILE} - ${ASM_SCRIPT_FILE}")
-
-    # mark obj as source that does not require compile
-    set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${name}.obj PROPERTIES EXTERNAL_OBJECT TRUE)
-
-    # Add the generated OBJ in the dependency list so that it gets consumed during linkage
-    list(APPEND ASSEMBLED_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj)
-  endforeach()
-
-  set(${COMPILE_ASM_OUTPUT_OBJECTS} ${ASSEMBLED_OBJECTS} PARENT_SCOPE)
-endfunction()
-
-# Build a list of include directories for consumption by the assembler
-function(get_include_directories_asm IncludeDirectories)
-    get_directory_property(dirs INCLUDE_DIRECTORIES)
-
-    if (CLR_CMAKE_TARGET_ARCH_ARM AND CLR_CMAKE_TARGET_WIN32)
-        list(APPEND INC_DIRECTORIES "-I ")
-    endif()
-
-    foreach(dir IN LISTS dirs)
-      if (CLR_CMAKE_TARGET_ARCH_ARM AND CLR_CMAKE_TARGET_WIN32)
-        list(APPEND INC_DIRECTORIES ${dir};)
-      else()
-        list(APPEND INC_DIRECTORIES -I${dir})
-      endif()
-    endforeach()
-
-    set(${IncludeDirectories} ${INC_DIRECTORIES} PARENT_SCOPE)
-endfunction(get_include_directories_asm)
-
-# 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)
diff --git a/src/installer/settings.cmake b/src/installer/settings.cmake
deleted file mode 100644 (file)
index c43bdbf..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-# 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.
-
-set (CMAKE_CXX_STANDARD 11)
-
-if (NOT CLR_CMAKE_HOST_WIN32)
-    # 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 (CLR_CMAKE_HOST_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()
-    endif (CLR_CMAKE_HOST_DARWIN)
-endif ()
-
-function(install_symbols targetName destination_path)
-    if(CLR_CMAKE_TARGET_WIN32)
-        install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pdb DESTINATION ${destination_path})
-    else()
-        strip_symbols(${targetName} strip_destination_file NO)
-        install(FILES ${strip_destination_file} DESTINATION ${destination_path})
-    endif()
-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)
-    if (NOT PAXCTL STREQUAL "PAXCTL-NOTFOUND")
-        add_custom_command(
-            TARGET ${targetName}
-            POST_BUILD
-            VERBATIM
-            COMMAND ${PAXCTL} -c -m $<TARGET_FILE:${targetName}>
-        )
-    endif()
-endfunction()
-
-if(CLR_CMAKE_HOST_WIN32)
-    add_definitions(-DWIN32)
-    add_definitions(-D_WIN32=1)
-    if(IS_64BIT_BUILD)
-        add_definitions(-D_WIN64=1)
-    endif()
-    add_compile_options($<$<CONFIG:Debug>:-DDEBUG>)
-    add_compile_options($<$<CONFIG:Release>:-DNDEBUG>)
-    add_compile_options($<$<CONFIG:RelWithDebInfo>:-DNDEBUG>)
-    add_compile_options($<$<CONFIG:Debug>:/Od>)
-    add_compile_options(/guard:cf)
-    add_compile_options(/d2Zi+) # make optimized builds debugging easier
-    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(/GF) # enable read-only string pooling
-    add_compile_options(/FC) # use full pathnames in diagnostics
-    add_compile_options(/DEBUG)
-    add_compile_options(/Zi) # enable debugging information
-    add_compile_options(/GS)
-    add_compile_options(/W1)
-    add_compile_options(/we5038) # make reorder warnings into errors
-    add_compile_options(/Zc:inline)
-    add_compile_options(/fp:precise)
-    add_compile_options(/EHsc)
-
-    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} /DEBUG")
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /INCREMENTAL:NO")
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /PDBCOMPRESS")
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1572864")
-
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /GUARD:CF")
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /GUARD:CF")
-
-    # Debug build specific flags
-    set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NOVCFEATURE")
-
-    # Release build specific flags
-    set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
-    set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
-    set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
-    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")
-
-    # RelWithDebInfo specific flags
-    set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG /OPT:REF /OPT:ICF")
-    set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG /OPT:REF /OPT:ICF")
-    set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG /OPT:REF /OPT:ICF")
-    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")
-else()
-    add_compile_options(-g) # enable debugging information
-    add_compile_options(-Wall)
-    add_compile_options(-Wextra)
-    if(CMAKE_C_COMPILER_ID STREQUAL Clang)
-        # Uncomment to enable additional, but likely irrelvant, warnings. For
-        # example, this will warn about using c++11 features even when
-        # compiling with -std=c++11.
-        # add_compile_options(-Weverything)
-    endif()
-    # Suppress warnings-as-errors in release branches to reduce servicing churn
-    if (PRERELEASE)
-        add_compile_options(-Werror)
-    endif()
-    add_compile_options(-Wno-missing-field-initializers)
-    add_compile_options(-Wno-unused-function)
-    add_compile_options(-Wno-unused-local-typedef)
-    add_compile_options(-Wno-unused-macros)
-    add_compile_options(-Wno-unused-parameter)
-
-    if(CLR_CMAKE_TARGET_ARCH_ARM)
-        if (NOT DEFINED CLR_ARM_FPU_TYPE)
-            set(CLR_ARM_FPU_TYPE vfpv3)
-        endif(NOT DEFINED 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})
-    endif()
-endif()
-
-# Older CMake doesn't support CMAKE_CXX_STANDARD and GCC/Clang need a switch to enable C++ 11
-if(${CMAKE_CXX_COMPILER_ID} MATCHES "(Clang|GNU)")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-endif()
-
-# This is required to map a symbol reference to a matching definition local to the module (.so)
-# containing the reference instead of using definitions from other modules.
-if(CLR_CMAKE_TARGET_LINUX)
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic -Bsymbolic-functions")
-    add_link_options(-Wl,--build-id=sha1 -Wl,-z,relro,-z,now)
-    add_compile_options(-fstack-protector-strong)
-elseif(CLR_CMAKE_TARGET_DARWIN)
-    add_compile_options(-fstack-protector)
-elseif(CLR_CMAKE_TARGET_FREEBSD)
-    add_link_options(-fuse-ld=lld -Wl,--build-id=sha1 -Wl,-z,relro,-z,now)
-    add_compile_options(-fstack-protector)
-endif()
-
-if(CLR_CMAKE_TARGET_ANDROID)
-    add_compile_options(-Wno-user-defined-warnings)
-endif()
-
-add_definitions(-D_NO_ASYNCRTIMP)
-add_definitions(-D_NO_PPLXIMP)
-if(CLR_CMAKE_TARGET_LINUX)
-    add_definitions(-D__LINUX__)
-endif()
-
-if(CLR_CMAKE_TARGET_ARCH_I386)
-    add_definitions(-D_TARGET_X86_=1)
-    set(ARCH_SPECIFIC_FOLDER_NAME "i386")
-elseif(CLR_CMAKE_TARGET_ARCH_AMD64)
-    add_definitions(-D_TARGET_AMD64_=1)
-    set(ARCH_SPECIFIC_FOLDER_NAME "AMD64")
-elseif(CLR_CMAKE_TARGET_ARCH_ARM)
-    add_definitions(-D_TARGET_ARM_=1)
-    set(ARCH_SPECIFIC_FOLDER_NAME "arm")
-elseif(CLR_CMAKE_TARGET_ARCH_ARM64)
-    add_definitions(-D_TARGET_ARM64_=1)
-    set(ARCH_SPECIFIC_FOLDER_NAME "arm64")
-else()
-    message(FATAL_ERROR "Unknown target architecture")
-endif()
-
-# Specify the Windows SDK to be used for Arm builds
-if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64))
-    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 or Arm64 build.")
-      else()
-             message("Using Windows SDK version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
-      endif()
-endif ()
-
-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)
-    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)
-    else()
-      enable_language(ASM_MASM)
-    endif()
-endif()
index f32da9d6563471bb05d7d4fceaab260ca5fa56fb..5e9c0f04bf5e030406c195a5cf1a9b9a3005cb4b 100644 (file)
@@ -5,10 +5,6 @@ project(CoreFX C)
 
 include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake)
 
-if(CLR_CMAKE_TARGET_IOS)
-    cmake_minimum_required(VERSION 3.14.5)
-endif()
-
 if(NOT CLR_CMAKE_TARGET_ARCH_WASM)
     cmake_policy(SET CMP0083 NEW)
 endif(NOT CLR_CMAKE_TARGET_ARCH_WASM)
@@ -131,7 +127,7 @@ else ()
 endif ()
 
 if(CLR_CMAKE_TARGET_ARCH_WASM)
-elseif (CLR_CMAKE_TARGET_DARWIN OR CLR_CMAKE_TARGET_IOS)
+elseif (CLR_CMAKE_TARGET_DARWIN)
     add_definitions(-D__APPLE_USE_RFC_3542)
 
    # We cannot enable "stack-protector-strong" on OS X due to a bug in clang compiler (current version 7.0.2)
@@ -158,19 +154,6 @@ endif(CLR_CMAKE_TARGET_FREEBSD)
 if(CLR_CMAKE_TARGET_UNIX)
     if (CLR_CMAKE_TARGET_DARWIN)
         add_link_options(-Wl,-bind_at_load)
-
-        # 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()
-    elseif (CLR_CMAKE_TARGET_IOS)
-        # No object stripping for iOS
     elseif (CLR_CMAKE_TARGET_ARCH_WASM)
         # No object stripping for WASM
     else (CLR_CMAKE_TARGET_DARWIN)
@@ -184,23 +167,9 @@ if(CLR_CMAKE_TARGET_UNIX)
 endif(CLR_CMAKE_TARGET_UNIX)
 
 function(install_library_and_symbols targetName)
-    strip_symbols(${targetName} strip_destination_file NO)
-
-    # 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_symbols(${targetName} .)
+    set(install_source_file $<TARGET_FILE:${targetName}>)
     install(PROGRAMS ${install_source_file} DESTINATION .)
-    if(CLR_CMAKE_TARGET_WIN32)
-        install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pdb DESTINATION PDB)
-    else()
-        install(FILES ${strip_destination_file} DESTINATION .)
-    endif()
 endfunction()
 
 include(configure.cmake)
@@ -219,18 +188,15 @@ endif()
 
 add_subdirectory(System.Native)
 
-if (NOT CLR_CMAKE_TARGET_ARCH_WASM)
-if (NOT CLR_CMAKE_TARGET_IOS)  # TODO: reenable
+if (NOT CLR_CMAKE_TARGET_ARCH_WASM AND NOT CLR_CMAKE_TARGET_IOS)  # TODO: reenable for iOS
     add_subdirectory(System.Globalization.Native)
     add_subdirectory(System.Net.Security.Native)
-endif()
-if (NOT CLR_CMAKE_TARGET_IOS)
+
     # disable System.Security.Cryptography.Native build on iOS,
     # only used for interacting with OpenSSL which isn't useful there
     add_subdirectory(System.Security.Cryptography.Native)
 endif()
-endif()
 
-if(CLR_CMAKE_TARGET_DARWIN OR CLR_CMAKE_TARGET_IOS)
+if(CLR_CMAKE_TARGET_DARWIN)
     add_subdirectory(System.Security.Cryptography.Native.Apple)
 endif()