Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Create 3.1.17 crossdac merge (#28185)
Browse files Browse the repository at this point in the history
* Update branding to 3.1.17 (#28173)

* Port from 5.0: Fix Position Independent Code in CMake files (#28143)

* CoreCLR PR26323 Port: Fix PIE options

* Added missing PIE and RELRO compilation flags.

* Merged PR 15832: Port from 5.0: Fix Position Independent Code in CMake files (#28143)

Port from 5.0: Fix Position Independent Code in CMake files (#28143)

* CoreCLR PR26323 Port: Fix PIE options

* Added missing PIE and RELRO compilation flags.

* Fix System.Globalization.Native build on Big Sur (#28181)

* Fix System.Globalization.Native build on Big Sur

* Fix build

* Add flags for Linux

* [release/3.1] Handle Counter Polling Interval of 0 (#28180)

* Backport  dotnet/runtime#53836

* Fix test build

* update test

Co-authored-by: Jan Jahoda <[email protected]>
Co-authored-by: Ivan Diaz Sanchez <[email protected]>
Co-authored-by: Will Godbe <[email protected]>
Co-authored-by: Santiago Fernandez Madero <[email protected]>
Co-authored-by: John Salem <[email protected]>
  • Loading branch information
6 people authored Jul 14, 2021
1 parent 7e3ee69 commit cae34e4
Show file tree
Hide file tree
Showing 52 changed files with 178 additions and 164 deletions.
18 changes: 13 additions & 5 deletions configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}")
Expand All @@ -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
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion dir.common.props
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

<PropertyGroup>
<!-- Central place to set the versions of all nuget packages produced in the repo -->
<PackageVersion Condition="'$(PackageVersion)' == ''">3.1.16</PackageVersion>
<PackageVersion Condition="'$(PackageVersion)' == ''">3.1.17</PackageVersion>
<PreReleaseLabel>servicing</PreReleaseLabel>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<!-- The .NET Core product branding version -->
<ProductVersion>3.1.16</ProductVersion>
<ProductVersion>3.1.17</ProductVersion>
<!-- File version numbers -->
<MajorVersion>4</MajorVersion>
<MinorVersion>7</MinorVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/binder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 0 additions & 4 deletions src/classlibnative/bcltype/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 0 additions & 4 deletions src/classlibnative/float/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/hosts/osxbundlerun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ project(osxbundlerun)

include_directories(../unixcoreruncommon)

add_compile_options(-fPIE)

set(CORERUN_SOURCES
osxbundlerun.cpp
)
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/hosts/unixcoreconsole/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ project(unixcoreconsole)

include_directories(../unixcoreruncommon)

add_compile_options(-fPIE)

set(CORECONSOLE_SOURCES
coreconsole.cpp
)
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/hosts/unixcorerun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ project(unixcorerun)

include_directories(../unixcoreruncommon)

add_compile_options(-fPIE)

set(CORERUN_SOURCES
corerun.cpp
)
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/hosts/unixcoreruncommon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
project(unixcoreruncommon)

add_compile_options(-fPIC)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

include(configure.cmake)
Expand Down
10 changes: 1 addition & 9 deletions src/corefx/System.Globalization.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 18 additions & 17 deletions src/corefx/System.Globalization.Native/configure.cmake
Original file line number Diff line number Diff line change
@@ -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 <unicode/udat.h>
int main(void) { enum UDateFormatSymbolType e = UDAT_STANDALONE_SHORTER_WEEKDAYS; }
" HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS)
CHECK_C_SOURCE_COMPILES("
#include <unicode/udat.h>
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
Expand Down
2 changes: 0 additions & 2 deletions src/debug/createdump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/debug/daccess/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions src/debug/dbgutil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
3 changes: 1 addition & 2 deletions src/debug/debug-pal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 0 additions & 2 deletions src/debug/di/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions src/debug/ee/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/debug/ee/wks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 0 additions & 4 deletions src/debug/ildbsymlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

4 changes: 0 additions & 4 deletions src/debug/shim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
2 changes: 0 additions & 2 deletions src/dlls/dbgshim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 0 additions & 4 deletions src/dlls/mscordac/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)

Expand Down
4 changes: 0 additions & 4 deletions src/dlls/mscorrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion src/gc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/gc/unix/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_compile_options(-fPIC)
include_directories("../env")

include(configure.cmake)
Expand Down
4 changes: 0 additions & 4 deletions src/gcinfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 0 additions & 4 deletions src/ilasm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/ildasm/exe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion src/inc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions src/jit/dll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Loading

0 comments on commit cae34e4

Please sign in to comment.