Skip to content

Commit

Permalink
Sync shared (PAL, utilcode, inc, etc.) files with latest runtime (dot…
Browse files Browse the repository at this point in the history
…net#4885)

Sync'ed to 96bcf7150deba280a070c6a4d85ca0640e405278 runtime commit hash

See src/shared/README.txt for more details on how some of the files are
merged.

Remove PAL_STDCPP_COMPAT
  • Loading branch information
mikem8361 authored Aug 28, 2024
1 parent 112bac7 commit c7ecd16
Show file tree
Hide file tree
Showing 418 changed files with 24,910 additions and 41,364 deletions.
55 changes: 14 additions & 41 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the MIT license. See LICENSE file in the project root for full license information.

# Verify minimum required version
cmake_minimum_required(VERSION 3.6.2)
cmake_minimum_required(VERSION 3.15)

cmake_policy(SET CMP0042 NEW) # MACOSX_RPATH is enabled by default.

Expand All @@ -13,18 +13,19 @@ project(diagnostics)
include(eng/native/configurepaths.cmake)
include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake)

# override some global configs
if (MSVC)
add_compile_options(/wd4960 /wd4961 /wd4603 /wd4627 /wd4838 /wd4456 /wd4457 /wd4458 /wd4459 /wd4091 /we4640)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/EHsc>)
add_compile_options($<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/MT>)
add_compile_options($<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:/MTd>)
else (MSVC)
add_compile_options(-Wno-unused-parameter)
add_compile_options(-Wno-unused-variable)
add_compile_options(-Wno-implicit-fallthrough)
if(CLR_CMAKE_HOST_UNIX)
# 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
add_compile_options(-fvisibility=default)
endif (MSVC)
endif(CLR_CMAKE_HOST_UNIX)

if (CMAKE_VERSION VERSION_LESS "3.16")
# Provide a no-op polyfill for precompiled headers on old CMake versions
function(target_precompile_headers)
endfunction()
endif()

# Register the default component
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME diagnostics)
Expand All @@ -48,7 +49,7 @@ endif(CLR_CMAKE_HOST_UNIX)

# Where _version.h for Windows is generated
if(CLR_CMAKE_HOST_WIN32)
include_directories(${CLR_ARTIFACTS_OBJ_DIR})
include_directories(${CLR_ARTIFACTS_OBJ_DIR})
endif(CLR_CMAKE_HOST_WIN32)

set(CORECLR_SET_RPATH ON)
Expand Down Expand Up @@ -182,42 +183,14 @@ if(CLR_CMAKE_HOST_WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif(CLR_CMAKE_HOST_WIN32)

add_definitions(-DUNICODE)
add_definitions(-D_UNICODE)

#--------------------------------------
# FEATURE Defines
#--------------------------------------

add_definitions(-DFEATURE_CORESYSTEM)

if(CLR_CMAKE_HOST_UNIX)
add_definitions(-DPLATFORM_UNIX=1)
add_definitions(-DFEATURE_PAL)
add_definitions(-DFEATURE_PAL_ANSI)
endif(CLR_CMAKE_HOST_UNIX)

if(CLR_CMAKE_HOST_WIN32)
add_definitions(-DFEATURE_COMINTEROP)
endif(CLR_CMAKE_HOST_WIN32)

if(NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
add_definitions(-DFEATURE_HIJACK)
endif(NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)

if(FEATURE_EVENT_TRACE)
add_definitions(-DFEATURE_EVENT_TRACE=1)
add_definitions(-DFEATURE_PERFTRACING=1)
endif(FEATURE_EVENT_TRACE)

if(CLR_CMAKE_HOST_UNIX_AMD64)
add_definitions(-DFEATURE_MULTIREG_RETURN)
endif (CLR_CMAKE_HOST_UNIX_AMD64)

if(CLR_CMAKE_HOST_UNIX AND CLR_CMAKE_TARGET_ARCH_AMD64)
add_definitions(-DUNIX_AMD64_ABI)
endif(CLR_CMAKE_HOST_UNIX AND CLR_CMAKE_TARGET_ARCH_AMD64)

#-----------------------------------------
# Native Projects
#-----------------------------------------
Expand Down
148 changes: 99 additions & 49 deletions diagnostics.sln

Large diffs are not rendered by default.

154 changes: 40 additions & 114 deletions eng/Build-Native.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@ if defined VS160COMNTOOLS (

:: Set the default arguments for build

set __BuildArch=x64
if /i "%PROCESSOR_ARCHITECTURE%" == "amd64" set __BuildArch=x64
if /i "%PROCESSOR_ARCHITECTURE%" == "x86" set __BuildArch=x86
set __TargetArch=x64
if /i "%PROCESSOR_ARCHITECTURE%" == "amd64" set __TargetArch=x64
if /i "%PROCESSOR_ARCHITECTURE%" == "arm64" set __TargetArch=arm64
if /i "%PROCESSOR_ARCHITECTURE%" == "x86" set __TargetArch=x86
set __HostArch=
set __BuildType=Debug
set __BuildOS=Windows_NT
set __Build=1
set __TargetOS=Windows_NT
set __BuildNative=1
set __CI=0
set __Verbosity=minimal
set __BuildCrossArch=0
set __CrossArch=
set __Ninja=0

:: Set the various build properties here so that CMake and MSBuild can pick them up
set "__ProjectDir=%~dp0"
Expand All @@ -61,7 +62,7 @@ if /i "%1" == "-help" goto Usage
if /i "%1" == "--help" goto Usage

if /i "%1" == "-configuration" (set __BuildType=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
if /i "%1" == "-architecture" (set __BuildArch=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
if /i "%1" == "-architecture" (set __TargetArch=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
if /i "%1" == "-verbosity" (set __Verbosity=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
if /i "%1" == "-ci" (set __CI=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)

Expand All @@ -88,18 +89,7 @@ if [!processedArgs!] == [] (

:ArgsDone

:: Determine if this is a cross-arch build

if /i "%__BuildArch%" == "arm64" (
set __BuildCrossArch=%__Build%
set __CrossArch=x64
)

if /i "%__BuildArch%" == "arm" (
set __BuildCrossArch=%__Build%
set __CrossArch=x86
)

if "%__HostArch%" == "" set __HostArch=%__TargetArch%
if /i "%__BuildType%" == "debug" set __BuildType=Debug
if /i "%__BuildType%" == "release" set __BuildType=Release

Expand All @@ -115,22 +105,18 @@ echo %NUGET_PACKAGES%

:: Set the remaining variables based upon the determined build configuration
set "__RootBinDir=%__ProjectDir%\artifacts"
set "__BinDir=%__RootBinDir%\bin\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__LogDir=%__RootBinDir%\log\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__BinDir=%__RootBinDir%\bin\%__TargetOS%.%__TargetArch%.%__BuildType%"
set "__LogDir=%__RootBinDir%\log\%__TargetOS%.%__TargetArch%.%__BuildType%"
set "__ArtifactsIntermediatesDir=%__RootBinDir%\obj"
set "__IntermediatesDir=%__ArtifactsIntermediatesDir%\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__IntermediatesDir=%__ArtifactsIntermediatesDir%\%__TargetOS%.%__TargetArch%.%__BuildType%"
set "__PackagesBinDir=%__RootBinDir%\packages\%__BuildType%\Shipping"

set "__CrossComponentBinDir=%__BinDir%"
set "__CrossCompIntermediatesDir=%__IntermediatesDir%\crossgen"
if NOT "%__CrossArch%" == "" set __CrossComponentBinDir=%__CrossComponentBinDir%\%__CrossArch%

:: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash
set "__CMakeBinDir=%__BinDir%"
set "__CMakeBinDir=%__CMakeBinDir:\=/%"

:: Common msbuild arguments
set "__CommonBuildArgs=/v:!__Verbosity! /p:Configuration=%__BuildType% /p:BuildArch=%__BuildArch% %__UnprocessedBuildArgs%"
set "__CommonBuildArgs=/v:!__Verbosity! /p:Configuration=%__BuildType% /p:BuildArch=%__TargetArch% %__UnprocessedBuildArgs%"

if not exist "%__BinDir%" md "%__BinDir%"
if not exist "%__IntermediatesDir%" md "%__IntermediatesDir%"
Expand All @@ -155,91 +141,27 @@ REM ============================================================================
:: Parse the optdata package versions out of msbuild so that we can pass them on to CMake
set __DotNetCli=%__ProjectDir%\dotnet.cmd

REM =========================================================================================
REM ===
REM === Build Cross-Architecture Native Components (if applicable)
REM ===
REM =========================================================================================

if /i %__BuildCrossArch% EQU 1 (
rem Scope environment changes start {
setlocal

echo %__MsgPrefix%Commencing build of cross architecture native components for %__BuildOS%.%__BuildArch%.%__BuildType%

:: Set the environment for the native build
set __VCBuildArch=x86_amd64
if /i "%__CrossArch%" == "x86" ( set __VCBuildArch=x86 )

echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch!
call "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch!
@if defined _echo @echo on

if not exist "%__CrossCompIntermediatesDir%" md "%__CrossCompIntermediatesDir%"

echo Generating Version Header
set __GenerateVersionLog="%__LogDir%\GenerateVersion.binlog"
powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__ProjectDir%\eng\common\msbuild.ps1" "%__ProjectDir%\eng\CreateVersionFile.proj" /bl:!__GenerateVersionLog! /t:GenerateVersionFiles /restore /p:FileVersionFile=%__RootBinDir%\bin\FileVersion.txt /p:GenerateVersionHeader=true /p:NativeVersionHeaderFile=%__ArtifactsIntermediatesDir%\_version.h %__CommonBuildArgs%
if not !errorlevel! == 0 (
echo Generate Version Header FAILED
goto ExitWithError
)
if defined __SkipConfigure goto SkipConfigureCrossBuild

set __CMakeBinDir=%__CrossComponentBinDir%
set "__CMakeBinDir=!__CMakeBinDir:\=/!"

set "__ManagedBinaryDir=%__RootBinDir%\bin"
set "__ManagedBinaryDir=!__ManagedBinaryDir:\=/!"
set __ExtraCmakeArgs="-DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir!" "-DCLR_BUILD_TYPE=%__BuildType%" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCMAKE_SYSTEM_VERSION=10.0" "-DNUGET_PACKAGES=%NUGET_PACKAGES:\=/%"

pushd "%__CrossCompIntermediatesDir%"
call "%__ProjectDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__CrossCompIntermediatesDir%" %__VSVersion% %__CrossArch% %__BuildOS% !__ExtraCmakeArgs!
@if defined _echo @echo on
popd

:SkipConfigureCrossBuild
if not exist "%__CrossCompIntermediatesDir%\CMakeCache.txt" (
echo %__MsgPrefix%Error: failed to generate cross-arch components build project!
goto ExitWithError
)
if defined __ConfigureOnly goto SkipCrossCompBuild

set __BuildLog="%__LogDir%\Cross.Build.binlog"

echo running "%CMakePath%" --build %__CrossCompIntermediatesDir% --target install --config %__BuildType% -- /bl:!__BuildLog! !__CommonBuildArgs!
"%CMakePath%" --build %__CrossCompIntermediatesDir% --target install --config %__BuildType% -- /bl:!__BuildLog! !__CommonBuildArgs!

if not !ERRORLEVEL! == 0 (
echo %__MsgPrefix%Error: cross-arch components build failed. Refer to the build log files for details:
echo !__BuildLog!
goto ExitWithError
)

:SkipCrossCompBuild
rem } Scope environment changes end
endlocal
)

REM =========================================================================================
REM ===
REM === Build the native code
REM ===
REM =========================================================================================

if %__Build% EQU 1 (
if %__BuildNative% EQU 1 (
rem Scope environment changes start {
setlocal

echo %__MsgPrefix%Commencing build of native components for %__BuildOS%.%__BuildArch%.%__BuildType%
echo %__MsgPrefix%Commencing build of native components for %__TargetOS%.%__TargetArch%.%__BuildType%

set __VCBuildArch=x86_amd64
if /i "%__BuildArch%" == "x86" ( set __VCBuildArch=x86 )
if /i "%__BuildArch%" == "arm" (
set __VCBuildArch=x86_arm
)
if /i "%__BuildArch%" == "arm64" (
set __VCBuildArch=x86_arm64
REM Set the environment for the native build
if /i "%PROCESSOR_ARCHITECTURE%" == "ARM64" (
set __VCBuildArch=arm64
if /i "%__HostArch%" == "x64" ( set __VCBuildArch=arm64_amd64 )
if /i "%__HostArch%" == "x86" ( set __VCBuildArch=arm64_x86 )
) else (
set __VCBuildArch=amd64
if /i "%__HostArch%" == "x86" ( set __VCBuildArch=amd64_x86 )
if /i "%__HostArch%" == "arm64" ( set __VCBuildArch=amd64_arm64 )
)

echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch!
Expand All @@ -251,9 +173,13 @@ if %__Build% EQU 1 (
goto ExitWithError
)

if %__Ninja% EQU 1 (
set __ExtraCmakeArgs="-DCMAKE_BUILD_TYPE=!__BuildType!"
)

echo Generating Version Header
set __GenerateVersionLog="%__LogDir%\GenerateVersion.binlog"
powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__ProjectDir%\eng\common\msbuild.ps1" "%__ProjectDir%\eng\CreateVersionFile.proj" /bl:!__GenerateVersionLog! /t:GenerateVersionFiles /restore /p:FileVersionFile=%__RootBinDir%\bin\FileVersion.txt /p:GenerateVersionHeader=true /p:NativeVersionHeaderFile=%__ArtifactsIntermediatesDir%\_version.h %__CommonBuildArgs%
powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__ProjectDir%\eng\common\msbuild.ps1" "%__ProjectDir%\eng\native-prereqs.proj" /bl:!__GenerateVersionLog! /t:BuildPrereqs /restore %__CommonBuildArgs%
if not !errorlevel! == 0 (
echo Generate Version Header FAILED
goto ExitWithError
Expand All @@ -264,10 +190,10 @@ if %__Build% EQU 1 (

set "__ManagedBinaryDir=%__RootBinDir%\bin"
set "__ManagedBinaryDir=!__ManagedBinaryDir:\=/!"
set __ExtraCmakeArgs="-DCMAKE_SYSTEM_VERSION=10.0" "-DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir!" "-DCLR_BUILD_TYPE=%__BuildType%" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DNUGET_PACKAGES=%NUGET_PACKAGES:\=/%"
set __ExtraCmakeArgs=!__ExtraCmakeArgs! "-DCMAKE_SYSTEM_VERSION=10.0" "-DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir!" "-DCLR_BUILD_TYPE=%__BuildType%" "-DCLR_CMAKE_TARGET_ARCH=%__TargetArch%" "-DNUGET_PACKAGES=%NUGET_PACKAGES:\=/%"

pushd "%__IntermediatesDir%"
call "%__ProjectDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% %__BuildOS% !__ExtraCmakeArgs!
call "%__ProjectDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__HostArch% %__TargetOS% !__ExtraCmakeArgs!
@if defined _echo @echo on
popd

Expand Down Expand Up @@ -299,14 +225,14 @@ REM Copy the native SOS binaries to where these tools expect for CI & VS testing
set "__targetRid=net6.0"
set "__dotnet_sos=%__RootBinDir%\bin\dotnet-sos\%__BuildType%\%__targetRid%"
set "__dotnet_dump=%__RootBinDir%\bin\dotnet-dump\%__BuildType%\%__targetRid%"
mkdir %__dotnet_sos%\win-%__BuildArch%
mkdir %__dotnet_sos%\publish\win-%__BuildArch%
mkdir %__dotnet_dump%\win-%__BuildArch%
mkdir %__dotnet_dump%\publish\win-%__BuildArch%
xcopy /y /q /i %__BinDir% %__dotnet_sos%\win-%__BuildArch%
xcopy /y /q /i %__BinDir% %__dotnet_sos%\publish\win-%__BuildArch%
xcopy /y /q /i %__BinDir% %__dotnet_dump%\win-%__BuildArch%
xcopy /y /q /i %__BinDir% %__dotnet_dump%\publish\win-%__BuildArch%
mkdir %__dotnet_sos%\win-%__TargetArch%
mkdir %__dotnet_sos%\publish\win-%__TargetArch%
mkdir %__dotnet_dump%\win-%__TargetArch%
mkdir %__dotnet_dump%\publish\win-%__TargetArch%
xcopy /y /q /i %__BinDir% %__dotnet_sos%\win-%__TargetArch%
xcopy /y /q /i %__BinDir% %__dotnet_sos%\publish\win-%__TargetArch%
xcopy /y /q /i %__BinDir% %__dotnet_dump%\win-%__TargetArch%
xcopy /y /q /i %__BinDir% %__dotnet_dump%\publish\win-%__TargetArch%

REM =========================================================================================
REM ===
Expand Down
Loading

0 comments on commit c7ecd16

Please sign in to comment.