diff --git a/configurecompiler.cmake b/configurecompiler.cmake
index 667a12e544b3..f48880186b67 100644
--- a/configurecompiler.cmake
+++ b/configurecompiler.cmake
@@ -6,6 +6,9 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
+# All code we build should be compiled as position independent.
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
set(CLR_DEFINES_DEBUG_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
set(CLR_DEFINES_CHECKED_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
set(CLR_DEFINES_RELEASE_INIT NDEBUG URTBLDENV_FRIENDLY=Retail)
@@ -409,10 +412,9 @@ elseif (CLR_CMAKE_PLATFORM_UNIX)
endif ()
# -fdata-sections -ffunction-sections: each function has own section instead of one per .o file (needed for --gc-sections)
- # -fPIC: enable Position Independent Code normally just for shared libraries but required when linking with address sanitizer
# -O1: optimization level used instead of -O0 to avoid compile error "invalid operand for inline asm constraint"
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CLR_SANITIZE_CXX_FLAGS} -fdata-sections -ffunction-sections -fPIC -O1")
- set(CMAKE_CXX_FLAGS_CHECKED "${CMAKE_CXX_FLAGS_CHECKED} ${CLR_SANITIZE_CXX_FLAGS} -fdata-sections -ffunction-sections -fPIC -O1")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CLR_SANITIZE_CXX_FLAGS} -fdata-sections -ffunction-sections -O1")
+ set(CMAKE_CXX_FLAGS_CHECKED "${CMAKE_CXX_FLAGS_CHECKED} ${CLR_SANITIZE_CXX_FLAGS} -fdata-sections -ffunction-sections -O1")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${CLR_SANITIZE_LINK_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_CHECKED "${CMAKE_EXE_LINKER_FLAGS_CHECKED} ${CLR_SANITIZE_LINK_FLAGS}")
@@ -422,6 +424,12 @@ elseif (CLR_CMAKE_PLATFORM_UNIX)
set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "${CMAKE_SHARED_LINKER_FLAGS_CHECKED} ${CLR_SANITIZE_LINK_FLAGS} -Wl,--gc-sections")
endif ()
endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
+
+ # This linker option causes executables we build to be marked as containing
+ # position independent code.
+ # It is necessary to make ASLR work for executables.
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
+
endif(WIN32)
# CLR_ADDITIONAL_LINKER_FLAGS - used for passing additional arguments to linker
@@ -437,8 +445,8 @@ endif(CLR_CMAKE_PLATFORM_UNIX)
if(CLR_CMAKE_PLATFORM_LINUX)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack")
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=sha1")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=sha1 -Wl,-z,relro,-z,now")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1 -Wl,-z,relro,-z,now")
endif(CLR_CMAKE_PLATFORM_LINUX)
if(CLR_CMAKE_PLATFORM_FREEBSD)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack")
diff --git a/dir.common.props b/dir.common.props
index f1c3b8a1a0c9..8a04b983b698 100644
--- a/dir.common.props
+++ b/dir.common.props
@@ -65,7 +65,7 @@
- 3.1.16
+ 3.1.17
servicing
diff --git a/eng/Versions.props b/eng/Versions.props
index e49b975780d4..b8bfe7625302 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -2,7 +2,7 @@
- 3.1.16
+ 3.1.17
4
7
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/CounterGroup.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/CounterGroup.cs
index bbfba16a7f2c..908a59f1f21b 100644
--- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/CounterGroup.cs
+++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/CounterGroup.cs
@@ -240,10 +240,9 @@ private void OnTimer()
lock (s_counterGroupLock)
{
_timeStampSinceCollectionStarted = now;
- do
- {
- _nextPollingTimeStamp += new TimeSpan(0, 0, 0, 0, _pollingIntervalInMilliseconds);
- } while (_nextPollingTimeStamp <= now);
+ TimeSpan delta = now - _nextPollingTimeStamp;
+ if (delta > TimeSpan.Zero && _pollingIntervalInMilliseconds > 0)
+ _nextPollingTimeStamp += TimeSpan.FromMilliseconds(_pollingIntervalInMilliseconds * Math.Ceiling(delta.TotalMilliseconds / _pollingIntervalInMilliseconds));
}
}
}
diff --git a/src/binder/CMakeLists.txt b/src/binder/CMakeLists.txt
index d92bec6c99d0..07f6c15bffab 100644
--- a/src/binder/CMakeLists.txt
+++ b/src/binder/CMakeLists.txt
@@ -91,9 +91,5 @@ endif(WIN32)
convert_to_absolute_path(BINDER_SOURCES ${BINDER_SOURCES})
convert_to_absolute_path(BINDER_CROSSGEN_SOURCES ${BINDER_CROSSGEN_SOURCES})
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_subdirectory(v3binder)
add_subdirectory(v3binder_crossgen)
diff --git a/src/classlibnative/bcltype/CMakeLists.txt b/src/classlibnative/bcltype/CMakeLists.txt
index 843d7e8b6805..67d1ad2bab58 100644
--- a/src/classlibnative/bcltype/CMakeLists.txt
+++ b/src/classlibnative/bcltype/CMakeLists.txt
@@ -11,10 +11,6 @@ set(BCLTYPE_SOURCES
variant.cpp
)
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_library_clr(bcltype
STATIC
${BCLTYPE_SOURCES}
diff --git a/src/classlibnative/float/CMakeLists.txt b/src/classlibnative/float/CMakeLists.txt
index bf173fe6587d..44d40c925921 100644
--- a/src/classlibnative/float/CMakeLists.txt
+++ b/src/classlibnative/float/CMakeLists.txt
@@ -7,10 +7,6 @@ set(FLOAT_SOURCES
floatsingle.cpp
)
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_library_clr(comfloat_wks
STATIC
${FLOAT_SOURCES}
diff --git a/src/coreclr/hosts/osxbundlerun/CMakeLists.txt b/src/coreclr/hosts/osxbundlerun/CMakeLists.txt
index 8af173f97078..802c5899ad86 100644
--- a/src/coreclr/hosts/osxbundlerun/CMakeLists.txt
+++ b/src/coreclr/hosts/osxbundlerun/CMakeLists.txt
@@ -2,8 +2,6 @@ project(osxbundlerun)
include_directories(../unixcoreruncommon)
-add_compile_options(-fPIE)
-
set(CORERUN_SOURCES
osxbundlerun.cpp
)
diff --git a/src/coreclr/hosts/unixcoreconsole/CMakeLists.txt b/src/coreclr/hosts/unixcoreconsole/CMakeLists.txt
index 2daeaabfa371..6e337b662ba4 100644
--- a/src/coreclr/hosts/unixcoreconsole/CMakeLists.txt
+++ b/src/coreclr/hosts/unixcoreconsole/CMakeLists.txt
@@ -2,8 +2,6 @@ project(unixcoreconsole)
include_directories(../unixcoreruncommon)
-add_compile_options(-fPIE)
-
set(CORECONSOLE_SOURCES
coreconsole.cpp
)
diff --git a/src/coreclr/hosts/unixcorerun/CMakeLists.txt b/src/coreclr/hosts/unixcorerun/CMakeLists.txt
index 07beaae1dfc3..5ee10b871ca1 100644
--- a/src/coreclr/hosts/unixcorerun/CMakeLists.txt
+++ b/src/coreclr/hosts/unixcorerun/CMakeLists.txt
@@ -2,8 +2,6 @@ project(unixcorerun)
include_directories(../unixcoreruncommon)
-add_compile_options(-fPIE)
-
set(CORERUN_SOURCES
corerun.cpp
)
diff --git a/src/coreclr/hosts/unixcoreruncommon/CMakeLists.txt b/src/coreclr/hosts/unixcoreruncommon/CMakeLists.txt
index 93a5bbf9ff0f..c859b0a31273 100644
--- a/src/coreclr/hosts/unixcoreruncommon/CMakeLists.txt
+++ b/src/coreclr/hosts/unixcoreruncommon/CMakeLists.txt
@@ -1,7 +1,5 @@
project(unixcoreruncommon)
-add_compile_options(-fPIC)
-
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include(configure.cmake)
diff --git a/src/corefx/System.Globalization.Native/CMakeLists.txt b/src/corefx/System.Globalization.Native/CMakeLists.txt
index 454d69f53d86..038de6de554d 100644
--- a/src/corefx/System.Globalization.Native/CMakeLists.txt
+++ b/src/corefx/System.Globalization.Native/CMakeLists.txt
@@ -26,19 +26,11 @@ if (NOT CLR_CMAKE_PLATFORM_DARWIN)
return()
endif()
else()
- find_library(ICUCORE icucore)
- if(ICUI18N STREQUAL ICUCORE-NOTFOUND)
- message(FATAL_ERROR "Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.")
- return()
- endif()
-
- add_definitions(-DOSX_ICU_LIBRARY_PATH=\"/usr/lib/libicucore.dylib\")
+ add_definitions(-DOSX_ICU_LIBRARY_PATH="/usr/lib/libicucore.dylib")
endif()
include(configure.cmake)
-add_compile_options(-fPIC)
-
set(NATIVEGLOBALIZATION_SOURCES
pal_calendarData.c
pal_casing.c
diff --git a/src/corefx/System.Globalization.Native/configure.cmake b/src/corefx/System.Globalization.Native/configure.cmake
index 6fd506dbe25a..4086adc5dd93 100644
--- a/src/corefx/System.Globalization.Native/configure.cmake
+++ b/src/corefx/System.Globalization.Native/configure.cmake
@@ -1,26 +1,27 @@
-include(CheckCSourceCompiles)
-include(CheckSymbolExists)
+if (CLR_CMAKE_PLATFORM_DARWIN)
+ set(HAVE_SET_MAX_VARIABLE 1)
+ set(HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS 1)
+else()
+ include(CheckCSourceCompiles)
+ include(CheckSymbolExists)
-set(CMAKE_REQUIRED_INCLUDES ${UTYPES_H} ${ICU_HOMEBREW_INC_PATH})
+ set(CMAKE_REQUIRED_INCLUDES ${UTYPES_H} ${ICU_HOMEBREW_INC_PATH})
-CHECK_C_SOURCE_COMPILES("
- #include
- int main(void) { enum UDateFormatSymbolType e = UDAT_STANDALONE_SHORTER_WEEKDAYS; }
-" HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS)
+ CHECK_C_SOURCE_COMPILES("
+ #include
+ int main(void) { enum UDateFormatSymbolType e = UDAT_STANDALONE_SHORTER_WEEKDAYS; }
+ " HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS)
-if(NOT CLR_CMAKE_PLATFORM_DARWIN)
set(CMAKE_REQUIRED_LIBRARIES ${ICUUC} ${ICUI18N})
-else()
- set(CMAKE_REQUIRED_LIBRARIES ${ICUCORE})
-endif()
-check_symbol_exists(
- ucol_setMaxVariable
- "unicode/ucol.h"
- HAVE_SET_MAX_VARIABLE)
+ check_symbol_exists(
+ ucol_setMaxVariable
+ "unicode/ucol.h"
+ HAVE_SET_MAX_VARIABLE)
-unset(CMAKE_REQUIRED_LIBRARIES)
-unset(CMAKE_REQUIRED_INCLUDES)
+ unset(CMAKE_REQUIRED_LIBRARIES)
+ unset(CMAKE_REQUIRED_INCLUDES)
+endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
diff --git a/src/debug/createdump/CMakeLists.txt b/src/debug/createdump/CMakeLists.txt
index b44016c4d022..b7b09fd2d526 100644
--- a/src/debug/createdump/CMakeLists.txt
+++ b/src/debug/createdump/CMakeLists.txt
@@ -20,8 +20,6 @@ include_directories(BEFORE ${VM_DIR})
add_definitions(-DPAL_STDCPP_COMPAT)
-add_compile_options(-fPIE)
-
set(CREATEDUMP_SOURCES
createdump.cpp
crashinfo.cpp
diff --git a/src/debug/daccess/CMakeLists.txt b/src/debug/daccess/CMakeLists.txt
index 083d8e027153..ba7e743fbd41 100644
--- a/src/debug/daccess/CMakeLists.txt
+++ b/src/debug/daccess/CMakeLists.txt
@@ -11,7 +11,6 @@ include_directories(${CLR_DIR}/src/gcdump)
if(CLR_CMAKE_PLATFORM_UNIX)
include_directories(${GENERATED_INCLUDE_DIR})
- add_compile_options(-fPIC)
endif(CLR_CMAKE_PLATFORM_UNIX)
set(DACCESS_SOURCES
diff --git a/src/debug/dbgutil/CMakeLists.txt b/src/debug/dbgutil/CMakeLists.txt
index 1c0d49a24ec6..6c43b5ca759c 100644
--- a/src/debug/dbgutil/CMakeLists.txt
+++ b/src/debug/dbgutil/CMakeLists.txt
@@ -9,8 +9,4 @@ set(DBGUTIL_SOURCES
dbgutil.cpp
)
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_library_clr(dbgutil STATIC ${DBGUTIL_SOURCES})
diff --git a/src/debug/debug-pal/CMakeLists.txt b/src/debug/debug-pal/CMakeLists.txt
index 92f18a65a9dc..8b65cd144e8b 100644
--- a/src/debug/debug-pal/CMakeLists.txt
+++ b/src/debug/debug-pal/CMakeLists.txt
@@ -22,8 +22,7 @@ if(WIN32)
endif(WIN32)
if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-
+ add_definitions(-DFEATURE_PAL)
add_definitions(-DPAL_IMPLEMENTATION)
add_definitions(-D_POSIX_C_SOURCE=200809L)
diff --git a/src/debug/di/CMakeLists.txt b/src/debug/di/CMakeLists.txt
index 28c738b4dc3b..d28ffdd53a21 100644
--- a/src/debug/di/CMakeLists.txt
+++ b/src/debug/di/CMakeLists.txt
@@ -90,8 +90,6 @@ if(WIN32)
set(CORDBDI_SOURCES_ASM_FILE ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj)
endif()
elseif(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-
if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_ARM)
set(CORDBDI_SOURCES_ASM_FILE
${ARCH_SOURCES_DIR}/floatconversion.S
diff --git a/src/debug/ee/CMakeLists.txt b/src/debug/ee/CMakeLists.txt
index 11a670285b6f..383ab24cfbdc 100644
--- a/src/debug/ee/CMakeLists.txt
+++ b/src/debug/ee/CMakeLists.txt
@@ -6,10 +6,6 @@ include_directories(BEFORE ${VM_DIR})
include_directories(BEFORE ${VM_DIR}/${ARCH_SOURCES_DIR})
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR})
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
set(CORDBEE_SOURCES_DAC_AND_WKS
controller.cpp
debugger.cpp
diff --git a/src/debug/ee/wks/CMakeLists.txt b/src/debug/ee/wks/CMakeLists.txt
index c6a4bccb0845..6a1a47c7b84c 100644
--- a/src/debug/ee/wks/CMakeLists.txt
+++ b/src/debug/ee/wks/CMakeLists.txt
@@ -54,8 +54,6 @@ if (WIN32)
else ()
- add_compile_options(-fPIC)
-
if(CLR_CMAKE_PLATFORM_ARCH_AMD64 OR CLR_CMAKE_PLATFORM_ARCH_ARM OR CLR_CMAKE_PLATFORM_ARCH_ARM64 OR CLR_CMAKE_PLATFORM_ARCH_I386)
add_library_clr(cordbee_wks ${CORDBEE_SOURCES_WKS} ../${ARCH_SOURCES_DIR}/dbghelpers.S)
else()
diff --git a/src/debug/ildbsymlib/CMakeLists.txt b/src/debug/ildbsymlib/CMakeLists.txt
index 1bd1096ed6b2..cf72a0e8e9d9 100644
--- a/src/debug/ildbsymlib/CMakeLists.txt
+++ b/src/debug/ildbsymlib/CMakeLists.txt
@@ -10,9 +10,5 @@ set( ILDBSYMLIB_SOURCES
symwrite.cpp
)
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_library_clr(ildbsymlib ${ILDBSYMLIB_SOURCES})
diff --git a/src/debug/shim/CMakeLists.txt b/src/debug/shim/CMakeLists.txt
index 8720eb7df2d0..28b7f624c559 100644
--- a/src/debug/shim/CMakeLists.txt
+++ b/src/debug/shim/CMakeLists.txt
@@ -4,10 +4,6 @@ if(WIN32)
add_definitions(-DHOST_IS_WINDOWS_OS)
endif(WIN32)
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
set(DEBUGSHIM_SOURCES
debugshim.cpp
)
diff --git a/src/dlls/dbgshim/CMakeLists.txt b/src/dlls/dbgshim/CMakeLists.txt
index 7e6ae61de111..ca4556bd0323 100644
--- a/src/dlls/dbgshim/CMakeLists.txt
+++ b/src/dlls/dbgshim/CMakeLists.txt
@@ -41,8 +41,6 @@ endif(CLR_CMAKE_PLATFORM_DARWIN)
add_library_clr(dbgshim SHARED ${DBGSHIM_SOURCES})
if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-
add_custom_target(dbgshim_exports DEPENDS ${EXPORTS_FILE})
add_dependencies(dbgshim dbgshim_exports)
diff --git a/src/dlls/mscordac/CMakeLists.txt b/src/dlls/mscordac/CMakeLists.txt
index 5d9f83cb8cf8..2d56a99fa0c4 100644
--- a/src/dlls/mscordac/CMakeLists.txt
+++ b/src/dlls/mscordac/CMakeLists.txt
@@ -1,10 +1,6 @@
include(${CLR_DIR}/dac.cmake)
add_definitions(-DFEATURE_NO_HOST)
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
set(CLR_DAC_SOURCES
)
diff --git a/src/dlls/mscorrc/CMakeLists.txt b/src/dlls/mscorrc/CMakeLists.txt
index 8f67988a23b1..366ace463105 100644
--- a/src/dlls/mscorrc/CMakeLists.txt
+++ b/src/dlls/mscorrc/CMakeLists.txt
@@ -9,10 +9,6 @@ if(WIN32)
string(REPLACE "/guard:cf" "" CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS})
endif(WIN32)
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_subdirectory(full)
# Only add the small version of the resources if the platform is Windows.
diff --git a/src/gc/CMakeLists.txt b/src/gc/CMakeLists.txt
index ab9f3a0baddc..17a774ceb5c2 100644
--- a/src/gc/CMakeLists.txt
+++ b/src/gc/CMakeLists.txt
@@ -97,7 +97,6 @@ target_link_libraries(clrgc ${GC_LINK_LIBRARIES})
install_clr(clrgc)
if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
# dprintf causes many warnings (https://github.com/dotnet/coreclr/issues/13367)
add_compile_options(-Wno-format)
endif(CLR_CMAKE_PLATFORM_UNIX)
diff --git a/src/gc/unix/CMakeLists.txt b/src/gc/unix/CMakeLists.txt
index fbb94fd5130c..7c6e627c739f 100644
--- a/src/gc/unix/CMakeLists.txt
+++ b/src/gc/unix/CMakeLists.txt
@@ -1,5 +1,4 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-add_compile_options(-fPIC)
include_directories("../env")
include(configure.cmake)
diff --git a/src/gcinfo/CMakeLists.txt b/src/gcinfo/CMakeLists.txt
index 79c4f486da28..c9c60db89e5f 100644
--- a/src/gcinfo/CMakeLists.txt
+++ b/src/gcinfo/CMakeLists.txt
@@ -16,10 +16,6 @@ endif(CLR_CMAKE_TARGET_ARCH_I386)
convert_to_absolute_path(GCINFO_SOURCES ${GCINFO_SOURCES})
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_subdirectory(lib)
add_subdirectory(crossgen)
diff --git a/src/ilasm/CMakeLists.txt b/src/ilasm/CMakeLists.txt
index 6117030dcc39..46850fabf2c2 100644
--- a/src/ilasm/CMakeLists.txt
+++ b/src/ilasm/CMakeLists.txt
@@ -10,10 +10,6 @@ add_definitions(-DFEATURE_CORECLR)
include_directories(.)
include_directories(../ildasm/unixcoreclrloader)
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIE)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
set(ILASM_SOURCES
assem.cpp
writer.cpp
diff --git a/src/ildasm/exe/CMakeLists.txt b/src/ildasm/exe/CMakeLists.txt
index 196f2395b7c3..a8ca1df3b089 100644
--- a/src/ildasm/exe/CMakeLists.txt
+++ b/src/ildasm/exe/CMakeLists.txt
@@ -10,7 +10,6 @@ add_definitions(-DFEATURE_CORECLR)
include_directories(..)
if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIE)
include_directories(../unixcoreclrloader)
build_resources(${CMAKE_CURRENT_SOURCE_DIR}/../dasm.rc dasm_rc TARGET_CPP_FILE)
diff --git a/src/inc/CMakeLists.txt b/src/inc/CMakeLists.txt
index c38d59587af2..a6692ee4b23b 100644
--- a/src/inc/CMakeLists.txt
+++ b/src/inc/CMakeLists.txt
@@ -62,7 +62,6 @@ foreach(IDL_SOURCE IN LISTS CORGUIDS_IDL_SOURCES)
list(APPEND CORGUIDS_SOURCES ${C_SOURCE})
endforeach(IDL_SOURCE)
-add_compile_options(-fPIC)
endif(WIN32)
if(FEATURE_JIT_PITCHING)
diff --git a/src/jit/dll/CMakeLists.txt b/src/jit/dll/CMakeLists.txt
index 9e930de69d24..624e3579894d 100644
--- a/src/jit/dll/CMakeLists.txt
+++ b/src/jit/dll/CMakeLists.txt
@@ -3,8 +3,6 @@ project(ClrJit)
set_source_files_properties(${JIT_EXPORTS_FILE} PROPERTIES GENERATED TRUE)
if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-
add_library_clr(clrjit_static
STATIC
${SHARED_LIB_SOURCES}
diff --git a/src/md/ceefilegen/CMakeLists.txt b/src/md/ceefilegen/CMakeLists.txt
index 7170facc6fb4..57d4cb6338cb 100644
--- a/src/md/ceefilegen/CMakeLists.txt
+++ b/src/md/ceefilegen/CMakeLists.txt
@@ -21,10 +21,6 @@ set(CEEFILEGEN_HEADERS
../../inc/utilcode.h
)
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_precompiled_header(stdafx.h stdafx.cpp CEEFILEGEN_SOURCES)
if (WIN32)
diff --git a/src/md/compiler/CMakeLists.txt b/src/md/compiler/CMakeLists.txt
index 5000f1b6fc72..260731d4a343 100644
--- a/src/md/compiler/CMakeLists.txt
+++ b/src/md/compiler/CMakeLists.txt
@@ -51,10 +51,6 @@ set(MDCOMPILER_HEADERS
convert_to_absolute_path(MDCOMPILER_SOURCES ${MDCOMPILER_SOURCES})
convert_to_absolute_path(MDCOMPILER_HEADERS ${MDCOMPILER_HEADERS})
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_subdirectory(dac)
add_subdirectory(wks)
add_subdirectory(dbi)
diff --git a/src/md/datasource/CMakeLists.txt b/src/md/datasource/CMakeLists.txt
index 489ef343aa3f..3aaa00afa21b 100644
--- a/src/md/datasource/CMakeLists.txt
+++ b/src/md/datasource/CMakeLists.txt
@@ -1,7 +1,3 @@
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
set(MDDATASOURCE_SOURCES
api.cpp
datatargetreader.cpp
diff --git a/src/md/enc/CMakeLists.txt b/src/md/enc/CMakeLists.txt
index 32d640a09a20..2f1398d6f19f 100644
--- a/src/md/enc/CMakeLists.txt
+++ b/src/md/enc/CMakeLists.txt
@@ -44,10 +44,6 @@ endif(WIN32)
convert_to_absolute_path(MDRUNTIMERW_HEADERS ${MDRUNTIMERW_HEADERS})
convert_to_absolute_path(MDRUNTIMERW_SOURCES ${MDRUNTIMERW_SOURCES})
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_subdirectory(dac)
add_subdirectory(wks)
add_subdirectory(dbi)
diff --git a/src/md/hotdata/CMakeLists.txt b/src/md/hotdata/CMakeLists.txt
index 600da6a2bef9..92a16cc9f2ae 100644
--- a/src/md/hotdata/CMakeLists.txt
+++ b/src/md/hotdata/CMakeLists.txt
@@ -25,10 +25,6 @@ set(MDHOTDATA_HEADERS
convert_to_absolute_path(MDHOTDATA_HEADERS ${MDHOTDATA_HEADERS})
convert_to_absolute_path(MDHOTDATA_SOURCES ${MDHOTDATA_SOURCES})
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_subdirectory(dac)
add_subdirectory(full)
add_subdirectory(crossgen)
diff --git a/src/md/runtime/CMakeLists.txt b/src/md/runtime/CMakeLists.txt
index 1111bdb0fec9..fc817b1f0d71 100644
--- a/src/md/runtime/CMakeLists.txt
+++ b/src/md/runtime/CMakeLists.txt
@@ -41,10 +41,6 @@ set(MDRUNTIME_HEADERS
convert_to_absolute_path(MDRUNTIME_HEADERS ${MDRUNTIME_HEADERS})
convert_to_absolute_path(MDRUNTIME_SOURCES ${MDRUNTIME_SOURCES})
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_subdirectory(dac)
add_subdirectory(wks)
add_subdirectory(dbi)
diff --git a/src/md/winmd/CMakeLists.txt b/src/md/winmd/CMakeLists.txt
index 31dbbbfc4fd9..567a9758f136 100644
--- a/src/md/winmd/CMakeLists.txt
+++ b/src/md/winmd/CMakeLists.txt
@@ -20,10 +20,6 @@ set(MDWINMD_HEADERS
convert_to_absolute_path(MDWINMD_HEADERS ${MDWINMD_HEADERS})
convert_to_absolute_path(MDWINMD_SOURCES ${MDWINMD_SOURCES})
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_subdirectory(dac)
add_subdirectory(wks)
if(WIN32)
diff --git a/src/nativeresources/CMakeLists.txt b/src/nativeresources/CMakeLists.txt
index e73a0d21292b..947a91438970 100644
--- a/src/nativeresources/CMakeLists.txt
+++ b/src/nativeresources/CMakeLists.txt
@@ -1,7 +1,5 @@
project(nativeresourcestring)
-add_compile_options(-fPIC)
-
add_library_clr(nativeresourcestring
STATIC
resourcestring.cpp
diff --git a/src/pal/src/CMakeLists.txt b/src/pal/src/CMakeLists.txt
index 311af8e935ac..4f97f58bcf0c 100644
--- a/src/pal/src/CMakeLists.txt
+++ b/src/pal/src/CMakeLists.txt
@@ -9,8 +9,6 @@ if(NOT DEFINED ENV{ROOTFS_DIR})
include_directories(SYSTEM /usr/local/include)
endif()
-add_compile_options(-fPIC)
-
if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
include_directories(libunwind/include)
include_directories(libunwind/include/tdep)
diff --git a/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt b/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt
index b5bf8e855115..1f49aef64e0a 100644
--- a/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt
+++ b/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt
@@ -46,8 +46,6 @@ add_library(eventprovider
eventproviderhelpers.cpp
)
-add_compile_options(-fPIC)
-
add_library(coreclrtraceptprovider
SHARED
${TRACEPOINT_PROVIDER_SOURCES}
diff --git a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt
index 4a3abc2d640e..685ac2ed4f0b 100644
--- a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt
@@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
add_definitions(-DFEATURE_ENABLE_HARDWARE_EXCEPTIONS)
endif(CLR_CMAKE_PLATFORM_UNIX)
diff --git a/src/palrt/CMakeLists.txt b/src/palrt/CMakeLists.txt
index d9f7b94d7033..77fdc67a52d7 100644
--- a/src/palrt/CMakeLists.txt
+++ b/src/palrt/CMakeLists.txt
@@ -12,8 +12,6 @@ set(PALRT_SOURCES
variant.cpp
)
-add_compile_options(-fPIC)
-
add_library_clr(palrt
STATIC
${PALRT_SOURCES}
diff --git a/src/strongname/api/CMakeLists.txt b/src/strongname/api/CMakeLists.txt
index 4efcdb953cd7..6e596d8ea9bc 100644
--- a/src/strongname/api/CMakeLists.txt
+++ b/src/strongname/api/CMakeLists.txt
@@ -17,10 +17,6 @@ set(STRONGNAME_SOURCES
convert_to_absolute_path(STRONGNAME_SOURCES ${STRONGNAME_SOURCES})
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_subdirectory(dac)
add_subdirectory(wks)
add_subdirectory(crossgen)
diff --git a/src/tools/crossgen/CMakeLists.txt b/src/tools/crossgen/CMakeLists.txt
index 410f82d929ee..ab5b4eda5397 100644
--- a/src/tools/crossgen/CMakeLists.txt
+++ b/src/tools/crossgen/CMakeLists.txt
@@ -14,7 +14,6 @@ if(WIN32)
endif()
if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIE)
add_definitions(-DNO_NGENPDB)
endif(CLR_CMAKE_PLATFORM_UNIX)
diff --git a/src/unwinder/CMakeLists.txt b/src/unwinder/CMakeLists.txt
index 5cd7bae33797..9a5d7829c86d 100644
--- a/src/unwinder/CMakeLists.txt
+++ b/src/unwinder/CMakeLists.txt
@@ -19,10 +19,6 @@ list(APPEND UNWINDER_SOURCES
convert_to_absolute_path(UNWINDER_SOURCES ${UNWINDER_SOURCES})
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
if(CLR_CMAKE_PLATFORM_UNIX)
add_subdirectory(wks)
endif(CLR_CMAKE_PLATFORM_UNIX)
diff --git a/src/utilcode/CMakeLists.txt b/src/utilcode/CMakeLists.txt
index 55584c084740..d24a5a36d1bf 100644
--- a/src/utilcode/CMakeLists.txt
+++ b/src/utilcode/CMakeLists.txt
@@ -114,10 +114,6 @@ convert_to_absolute_path(UTILCODE_DBI_SOURCES ${UTILCODE_DBI_SOURCES})
convert_to_absolute_path(UTILCODE_CROSSGEN_SOURCES ${UTILCODE_CROSSGEN_SOURCES})
convert_to_absolute_path(UTILCODE_STATICNOHOST_SOURCES ${UTILCODE_STATICNOHOST_SOURCES})
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
add_subdirectory(dac)
add_subdirectory(dbi)
add_subdirectory(dyncrt)
diff --git a/src/vm/CMakeLists.txt b/src/vm/CMakeLists.txt
index 54d166f1daa8..83c6e2d60804 100644
--- a/src/vm/CMakeLists.txt
+++ b/src/vm/CMakeLists.txt
@@ -21,10 +21,6 @@ else()
endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
endif(CMAKE_CONFIGURATION_TYPES)
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
if(FEATURE_GDBJIT)
set(VM_SOURCES_GDBJIT
gdbjit.cpp
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 665b3687461a..a55602917eeb 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -32,10 +32,6 @@ if (WIN32)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
endif()
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
MACRO(SUBDIRLIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
SET(dirlist "")
diff --git a/tests/src/tracing/eventcounter/gh53564.cs b/tests/src/tracing/eventcounter/gh53564.cs
new file mode 100644
index 000000000000..4b2b5907abbe
--- /dev/null
+++ b/tests/src/tracing/eventcounter/gh53564.cs
@@ -0,0 +1,109 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+#if USE_MDT_EVENTSOURCE
+using Microsoft.Diagnostics.Tracing;
+#else
+using System.Diagnostics.Tracing;
+#endif
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Diagnostics;
+
+namespace gh53564Tests
+{
+ public class RuntimeCounterListener : EventListener
+ {
+ public RuntimeCounterListener(){}
+
+ private DateTime? setToZeroTimestamp = null;
+ private DateTime? mostRecentTimestamp = null;
+ private ManualResetEvent setToZero = new ManualResetEvent(initialState: false);
+ public ManualResetEvent ReadyToVerify { get; } = new ManualResetEvent(initialState: false);
+
+ protected override void OnEventSourceCreated(EventSource source)
+ {
+ if (source.Name.Equals("System.Runtime"))
+ {
+ Dictionary refreshInterval = new Dictionary();
+
+ Console.WriteLine($"[{DateTime.UtcNow:hh:mm:ss.fff}] OnEventSourceCreated :: Setting interval to 1");
+ // first set interval to 1 seconds
+ refreshInterval["EventCounterIntervalSec"] = "1";
+ EnableEvents(source, EventLevel.Informational, (EventKeywords)(-1), refreshInterval);
+
+ // wait a moment to get some events
+ Thread.Sleep(TimeSpan.FromSeconds(3));
+
+ // then set interval to 0
+ Console.WriteLine($"[{DateTime.UtcNow:hh:mm:ss.fff}] OnEventSourceCreated :: Setting interval to 0");
+ refreshInterval["EventCounterIntervalSec"] = "0";
+ EnableEvents(source, EventLevel.Informational, (EventKeywords)(-1), refreshInterval);
+ setToZeroTimestamp = DateTime.UtcNow + TimeSpan.FromSeconds(1); // Stash timestamp 1 second after setting to 0
+ setToZero.Set();
+
+ // then attempt to set interval back to 1
+ Thread.Sleep(TimeSpan.FromSeconds(3));
+ Console.WriteLine($"[{DateTime.UtcNow:hh:mm:ss.fff}] OnEventSourceCreated :: Setting interval to 1");
+ refreshInterval["EventCounterIntervalSec"] = "1";
+ EnableEvents(source, EventLevel.Informational, (EventKeywords)(-1), refreshInterval);
+ }
+ }
+
+ protected override void OnEventWritten(EventWrittenEventArgs eventData)
+ {
+ if (!ReadyToVerify.WaitOne(0))
+ {
+ mostRecentTimestamp = eventData.TimeStamp;
+ if (setToZero.WaitOne(0) && mostRecentTimestamp > setToZeroTimestamp)
+ {
+ Console.WriteLine($"[{DateTime.UtcNow:hh:mm:ss.fff}] OnEventWritten :: Setting ReadyToVerify");
+ ReadyToVerify.Set();
+ }
+ }
+ }
+
+ public bool Verify()
+ {
+ if (!ReadyToVerify.WaitOne(0))
+ return false;
+
+ Console.WriteLine($"[{DateTime.UtcNow:hh:mm:ss.fff}] Verify :: Verifying");
+ Console.WriteLine($"[{DateTime.UtcNow:hh:mm:ss.fff}] setToZeroTimestamp = {setToZeroTimestamp?.ToString("hh:mm:ss.fff") ?? "NULL"}");
+ Console.WriteLine($"[{DateTime.UtcNow:hh:mm:ss.fff}] mostRecentTimestamp = {mostRecentTimestamp?.ToString("hh:mm:ss.fff") ?? "NULL"}");
+
+ return (setToZeroTimestamp is null || mostRecentTimestamp is null) ? false : setToZeroTimestamp < mostRecentTimestamp;
+ }
+ }
+
+ public partial class TestRuntimeEventCounter
+ {
+ public static int Main(string[] args)
+ {
+ // Create an EventListener.
+ using (RuntimeCounterListener myListener = new RuntimeCounterListener())
+ {
+ if (myListener.ReadyToVerify.WaitOne(TimeSpan.FromSeconds(30)))
+ {
+ if (myListener.Verify())
+ {
+ Console.WriteLine("Test passed");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine($"Test Failed - did not see one or more of the expected runtime counters.");
+ return 1;
+ }
+ }
+ else
+ {
+ Console.WriteLine("Test Failed - timed out waiting for reset");
+ return 1;
+ }
+ }
+ }
+ }
+}
diff --git a/tests/src/tracing/eventcounter/gh53564.csproj b/tests/src/tracing/eventcounter/gh53564.csproj
new file mode 100644
index 000000000000..ff0986cd788f
--- /dev/null
+++ b/tests/src/tracing/eventcounter/gh53564.csproj
@@ -0,0 +1,31 @@
+
+
+
+
+ Debug
+ AnyCPU
+ 2.0
+ {8E3244CB-407F-4142-BAAB-E7A55901A5FA}
+ Exe
+ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ ..\..\
+ BuildAndRun
+ $(DefineConstants);STATIC
+ true
+ 0
+ true
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+