From bff7536404f6657857c5571832a921f03ca40f16 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 3 Sep 2021 16:48:38 -0700 Subject: [PATCH 01/42] Move optdata and version file generation from the native build scripts up into the managed scripts. The native build scripts will now by default copy a fallback version file in place if the version files do not exist and will disable PGO if no pgo file path is passed in to the build-runtime scripts. This removes all cases of build-runtime calling into MSBuild. --- eng/Subsets.props | 18 +++--- eng/native/build-commons.sh | 48 --------------- .../optdata/{optdata.csproj => optdata.proj} | 12 ++-- src/coreclr/build-runtime.cmd | 58 +++---------------- src/coreclr/build-runtime.sh | 51 +++++----------- src/coreclr/runtime-prereqs.proj | 15 +++++ src/coreclr/runtime.proj | 24 +++++++- src/coreclr/versionfallback/_version.h | 29 ++++++++++ src/coreclr/versionfallback/runtime_version.h | 10 ++++ src/coreclr/versionfallback/version.c | 4 ++ 10 files changed, 115 insertions(+), 154 deletions(-) rename src/coreclr/.nuget/optdata/{optdata.csproj => optdata.proj} (95%) create mode 100644 src/coreclr/runtime-prereqs.proj create mode 100644 src/coreclr/versionfallback/_version.h create mode 100644 src/coreclr/versionfallback/runtime_version.h create mode 100644 src/coreclr/versionfallback/version.c diff --git a/eng/Subsets.props b/eng/Subsets.props index 7113a4ac779e3..b6c8e7147decb 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -94,7 +94,7 @@ - + @@ -120,7 +120,7 @@ - + @@ -164,12 +164,6 @@ - - - - $(ClrRuntimeBuildSubsets);ClrRuntimeSubset=true @@ -194,7 +188,11 @@ $(ClrRuntimeBuildSubsets);ClrILToolsSubset=true - + + + + + @@ -259,7 +257,7 @@ - + diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 9600e346b3613..7d00148e98903 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -101,50 +101,7 @@ build_native() buildTool="make" fi - runtimeVersionHeaderFile="$intermediatesDir/../runtime_version.h" if [[ "$__SkipConfigure" == 0 ]]; then - # if msbuild is not supported, then set __SkipGenerateVersion to 1 - if [[ "$__IsMSBuildOnNETCoreSupported" == 0 ]]; then __SkipGenerateVersion=1; fi - # Drop version.c file - __versionSourceFile="$intermediatesDir/version.c" - - if [[ ! -z "${__LogsDir}" ]]; then - __binlogArg="-bl:\"$__LogsDir/GenNativeVersion_$__TargetOS.$__BuildArch.$__BuildType.binlog\"" - fi - - if [[ "$__SkipGenerateVersion" == 0 ]]; then - "$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary "$__ArcadeScriptArgs" "$__RepoRootDir"/eng/empty.csproj \ - /p:NativeVersionFile="$__versionSourceFile" \ - /p:RuntimeVersionFile="$runtimeVersionHeaderFile" \ - /t:GenerateRuntimeVersionFile /restore \ - $__CommonMSBuildArgs $__binlogArg $__UnprocessedBuildArgs - local exit_code="$?" - if [[ "$exit_code" != 0 ]]; then - echo "${__ErrMsgPrefix}Failed to generate native version file." - exit "$exit_code" - fi - else - # Generate the dummy version.c and runtime_version.h, but only if they didn't exist to make sure we don't trigger unnecessary rebuild - __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";" - if [[ -e "$__versionSourceFile" ]]; then - read existingVersionSourceLine < "$__versionSourceFile" - fi - if [[ "$__versionSourceLine" != "$existingVersionSourceLine" ]]; then - cat << EOF > $runtimeVersionHeaderFile -#define RuntimeAssemblyMajorVersion 0 -#define RuntimeAssemblyMinorVersion 0 -#define RuntimeFileMajorVersion 0 -#define RuntimeFileMinorVersion 0 -#define RuntimeFileBuildVersion 0 -#define RuntimeFileRevisionVersion 0 -#define RuntimeProductMajorVersion 0 -#define RuntimeProductMinorVersion 0 -#define RuntimeProductPatchVersion 0 -#define RuntimeProductVersion -EOF - echo "$__versionSourceLine" > "$__versionSourceFile" - fi - fi if [[ "$__StaticAnalyzer" == 1 ]]; then scan_build=scan-build @@ -248,7 +205,6 @@ usage() echo "-numproc: set the number of build processes." echo "-portablebuild: pass -portablebuild=false to force a non-portable build." echo "-skipconfigure: skip build configuration." - echo "-skipgenerateversion: disable version generation even if MSBuild is supported." echo "-keepnativesymbols: keep native/unmanaged debug symbols." echo "-verbose: optional argument to enable verbose build output." echo "" @@ -419,10 +375,6 @@ while :; do __SkipConfigure=1 ;; - skipgenerateversion|-skipgenerateversion) - __SkipGenerateVersion=1 - ;; - verbose|-verbose) __VerboseBuild=1 ;; diff --git a/src/coreclr/.nuget/optdata/optdata.csproj b/src/coreclr/.nuget/optdata/optdata.proj similarity index 95% rename from src/coreclr/.nuget/optdata/optdata.csproj rename to src/coreclr/.nuget/optdata/optdata.proj index 716f99f6c1686..d219f7a3e2558 100644 --- a/src/coreclr/.nuget/optdata/optdata.csproj +++ b/src/coreclr/.nuget/optdata/optdata.proj @@ -1,4 +1,4 @@ - + $(NetCoreAppCurrent) @@ -32,10 +32,7 @@ - - - - + Pkgoptimization_$(_TargetOSArchLowercase)_PGO_CoreCLR @@ -56,8 +53,11 @@ + - + + + : specify this option one or more times to limit components built to those specified. echo Allowed ^: jit alljits runtime paltests iltools -echo -nopgooptimize: do not use profile guided optimizations. echo -enforcepgo: verify after the build that PGO was used for key DLLs, and fail the build if not echo -pgoinstrument: generate instrumented code for profile guided optimization enabled binaries. echo -cmakeargs: user-settable additional arguments passed to CMake. diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh index 1d9881f281b18..ffd9b340a21e7 100755 --- a/src/coreclr/build-runtime.sh +++ b/src/coreclr/build-runtime.sh @@ -18,7 +18,7 @@ fi export PYTHON -usage_list+=("-nopgooptimize: do not use profile guided optimizations.") +usage_list+=("-pgodatapath: path to profile guided optimization data.") usage_list+=("-pgoinstrument: generate instrumented code for profile guided optimization enabled binaries.") usage_list+=("-skipcrossarchnative: Skip building cross-architecture native binaries.") usage_list+=("-staticanalyzer: use scan_build static analyzer.") @@ -36,35 +36,6 @@ setup_dirs_local() fi } -restore_optdata() -{ - local OptDataProjectFilePath="$__ProjectRoot/.nuget/optdata/optdata.csproj" - - if [[ "$__PgoOptimize" == 1 && "$__IsMSBuildOnNETCoreSupported" == 1 ]]; then - # Parse the optdata package versions out of msbuild so that we can pass them on to CMake - - local PgoDataPackagePathOutputFile="${__IntermediatesDir}/optdatapath.txt" - - local RestoreArg="" - - if [[ "$__SkipRestoreOptData" == "0" ]]; then - RestoreArg="/restore" - fi - - # Writes into ${PgoDataPackagePathOutputFile} - "$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary $__ArcadeScriptArgs $OptDataProjectFilePath $RestoreArg /t:DumpPgoDataPackagePath \ - ${__CommonMSBuildArgs} /p:PgoDataPackagePathOutputFile=${PgoDataPackagePathOutputFile} \ - -bl:"$__LogsDir/PgoVersionRead_$__ConfigTriplet.binlog" > /dev/null 2>&1 - local exit_code="$?" - if [[ "$exit_code" != 0 || ! -f "${PgoDataPackagePathOutputFile}" ]]; then - echo "${__ErrMsgPrefix}Failed to get PGO data package path." - exit "$exit_code" - fi - - __PgoOptDataPath=$(<"${PgoDataPackagePathOutputFile}") - fi -} - build_cross_architecture_components() { local intermediatesForBuild="$__IntermediatesDir/Host$__CrossArch/crossgen" @@ -95,12 +66,19 @@ build_cross_architecture_components() export CROSSCOMPILE } +copy_version_files() +{ + # Copy dummy version files if version files haven't already been generated + cp -r -n "$__ProjectRoot/versionfallback/"* "$__ArtifactsIntermediatesDir/" +} + handle_arguments_local() { case "$1" in - nopgooptimize|-nopgooptimize) - __PgoOptimize=0 - __SkipRestoreOptData=1 + pgodatapath|-pgodatapath) + __PgoOptimize=1 + __PgoOptDataPath=$2 + __ShiftArgs=1 ;; pgoinstrument|-pgoinstrument) @@ -152,7 +130,7 @@ __CrossBuild=0 __DistroRid="" __PgoInstrument=0 __PgoOptDataPath="" -__PgoOptimize=1 +__PgoOptimize=0 __PortableBuild=1 __ProjectDir="$__ProjectRoot" __RootBinDir="$__RepoRootDir/artifacts" @@ -218,9 +196,6 @@ export MSBUILDDEBUGPATH # Check prereqs. check_prereqs -# Restore the package containing profile counts for profile-guided optimizations -restore_optdata - # Build the coreclr (native) components. __CMakeArgs="-DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_PATH=$__PgoOptDataPath -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize $__CMakeArgs" @@ -240,6 +215,8 @@ fi if [[ "$__SkipNative" == 1 ]]; then echo "Skipping CoreCLR component build." else + copy_version_files + build_native "$__TargetOS" "$__BuildArch" "$__ProjectRoot" "$__IntermediatesDir" "$__CMakeTarget" "$__CMakeArgs" "CoreCLR component" # Build cross-architecture components diff --git a/src/coreclr/runtime-prereqs.proj b/src/coreclr/runtime-prereqs.proj new file mode 100644 index 0000000000000..b15803bff5e75 --- /dev/null +++ b/src/coreclr/runtime-prereqs.proj @@ -0,0 +1,15 @@ + + + $(ArtifactsObjDir)/coreclr/_version.h + $(ArtifactsObjDir)/coreclr/runtime_version.h + + + + + + + + + + + diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj index 3d4705a92f6fd..07b1762a341ff 100644 --- a/src/coreclr/runtime.proj +++ b/src/coreclr/runtime.proj @@ -1,7 +1,26 @@ + + ClrFullNativeBuild;ClrRuntimeSubset;ClrJitSubset;ClrPalTestsSubset;ClrAllJitsSubset;ClrILToolsSubset + + + + + + + BeforeTargets="Build"> + + + + + + + <_CoreClrBuildArg Condition="'$(TargetArchitecture)' != ''" Include="-$(TargetArchitecture)" /> <_CoreClrBuildArg Condition="!$([MSBuild]::IsOsPlatform(Windows)) and '$(CMakeArgs)' != ''" Include="$(CMakeArgs)" /> @@ -25,7 +44,7 @@ <_CoreClrBuildArg Condition="'$(Ninja)' == 'true' and !$([MSBuild]::IsOsPlatform(Windows))" Include="-ninja" /> <_CoreClrBuildArg Condition="'$(Ninja)' == 'false' and $([MSBuild]::IsOsPlatform(Windows))" Include="-msbuild" /> <_CoreClrBuildArg Condition="'$(PgoInstrument)' == 'true'" Include="-pgoinstrument" /> - <_CoreClrBuildArg Condition="'$(NoPgoOptimize)' == 'true' or '$(PgoInstrument)' == 'true'" Include="-nopgooptimize" /> + <_CoreClrBuildArg Condition="'$(NoPgoOptimize)' != 'true' and '$(PgoInstrument)' != 'true'" Include="-pgodatapath "$(PgoDataPath)"" /> <_CoreClrBuildArg Condition="'$(OfficialBuildId)' != ''" Include="/p:OfficialBuildId=$(OfficialBuildId)" /> @@ -43,6 +62,7 @@ + diff --git a/src/coreclr/versionfallback/_version.h b/src/coreclr/versionfallback/_version.h new file mode 100644 index 0000000000000..98873728c39d3 --- /dev/null +++ b/src/coreclr/versionfallback/_version.h @@ -0,0 +1,29 @@ +#ifndef VER_COMPANYNAME_STR +#define VER_COMPANYNAME_STR "Microsoft Corporation" +#endif +#ifndef VER_FILEDESCRIPTION_STR +#define VER_FILEDESCRIPTION_STR "empty" +#endif +#ifndef VER_INTERNALNAME_STR +#define VER_INTERNALNAME_STR VER_FILEDESCRIPTION_STR +#endif +#ifndef VER_ORIGINALFILENAME_STR +#define VER_ORIGINALFILENAME_STR VER_FILEDESCRIPTION_STR +#endif +#ifndef VER_PRODUCTNAME_STR +#define VER_PRODUCTNAME_STR "Microsoft\xae .NET Framework" +#endif +#undef VER_PRODUCTVERSION +#define VER_PRODUCTVERSION 00,00,00,00000 +#undef VER_PRODUCTVERSION_STR +#define VER_PRODUCTVERSION_STR "0.0.0" +#undef VER_FILEVERSION +#define VER_FILEVERSION 00,00,00,00000 +#undef VER_FILEVERSION_STR +#define VER_FILEVERSION_STR "00,00,00,00000" +#ifndef VER_LEGALCOPYRIGHT_STR +#define VER_LEGALCOPYRIGHT_STR "\xa9 Microsoft Corporation. All rights reserved." +#endif +#ifndef VER_DEBUG +#define VER_DEBUG VS_FF_DEBUG +#endif diff --git a/src/coreclr/versionfallback/runtime_version.h b/src/coreclr/versionfallback/runtime_version.h new file mode 100644 index 0000000000000..c261e2f994a72 --- /dev/null +++ b/src/coreclr/versionfallback/runtime_version.h @@ -0,0 +1,10 @@ +#define RuntimeAssemblyMajorVersion 0 +#define RuntimeAssemblyMinorVersion 0 +#define RuntimeFileMajorVersion 0 +#define RuntimeFileMinorVersion 0 +#define RuntimeFileBuildVersion 0 +#define RuntimeFileRevisionVersion 0 +#define RuntimeProductMajorVersion 0 +#define RuntimeProductMinorVersion 0 +#define RuntimeProductPatchVersion 0 +#define RuntimeProductVersion diff --git a/src/coreclr/versionfallback/version.c b/src/coreclr/versionfallback/version.c new file mode 100644 index 0000000000000..153d9f05f14e4 --- /dev/null +++ b/src/coreclr/versionfallback/version.c @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +static char sccsid[] __attribute__((used)) = "@(#)No version information produced"; From a8b692c00329f237fceadea4dc18cc39072baa97 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 3 Sep 2021 16:56:17 -0700 Subject: [PATCH 02/42] Update CI to use the new prereqs model. --- eng/pipelines/coreclr/templates/build-job.yml | 9 ++++----- src/coreclr/runtime-prereqs.proj | 14 +++++++++++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/eng/pipelines/coreclr/templates/build-job.yml b/eng/pipelines/coreclr/templates/build-job.yml index e94d630ba2e95..2f795dbaf8011 100644 --- a/eng/pipelines/coreclr/templates/build-job.yml +++ b/eng/pipelines/coreclr/templates/build-job.yml @@ -181,14 +181,13 @@ jobs: df -h displayName: Disk Usage before Build - # Build DacTableGen (Windows-only) - - ${{ if eq(parameters.osGroup, 'windows') }}: - - script: $(Build.SourcesDirectory)$(dir)build$(scriptExt) -subset clr.dactools $(crossArg) -arch $(archType) $(osArg) -c $(buildConfig) $(officialBuildIdArg) -ci /bl:$(Build.SourcesDirectory)artifacts/log/$(buildConfig)/DacTools.binlog - displayName: Build DAC utility tools + # Build/Generate native prerequisites + - script: $(Build.SourcesDirectory)$(dir)build$(scriptExt) -subset clr.nativeprereqs $(crossArg) -arch $(archType) $(osArg) -c $(buildConfig) $(officialBuildIdArg) -ci /bl:$(Build.SourcesDirectory)artifacts/log/$(buildConfig)/CoreCLRNativePrereqs.binlog + displayName: Build and generate native prerequisites # Build CoreCLR Runtime - ${{ if ne(parameters.osGroup, 'windows') }}: - - script: $(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) $(crossArg) $(osArg) -ci $(compilerArg) $(clrBuildPALTestsBuildArg) $(pgoInstrumentArg) $(officialBuildIdArg) $(clrInterpreterBuildArg) + - script: $(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) $(crossArg) $(osArg) -ci $(compilerArg) $(clrBuildPALTestsBuildArg) $(pgoInstrumentArg) $(officialBuildIdArg) $(clrInterpreterBuildArg) $(CoreClrPgoDataArg) displayName: Build CoreCLR Runtime - ${{ if eq(parameters.osGroup, 'windows') }}: - script: set __TestIntermediateDir=int&&$(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) -ci $(enforcePgoArg) $(pgoInstrumentArg) $(officialBuildIdArg) $(clrInterpreterBuildArg) diff --git a/src/coreclr/runtime-prereqs.proj b/src/coreclr/runtime-prereqs.proj index b15803bff5e75..577bca9881ff1 100644 --- a/src/coreclr/runtime-prereqs.proj +++ b/src/coreclr/runtime-prereqs.proj @@ -11,5 +11,17 @@ - + + + + + + + + + From 1813a732da829223ecb48bb9450689ae0bcc3c7d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 3 Sep 2021 16:58:51 -0700 Subject: [PATCH 03/42] Remove some old MSBuild arg pass-through that's no longer needed as build-runtime no longer calls into any MSBuild processes. --- src/coreclr/build-runtime.cmd | 5 ----- src/coreclr/runtime.proj | 1 - 2 files changed, 6 deletions(-) diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index 2d3a73216ee9d..f1b48ae65fd05 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -60,7 +60,6 @@ set __PassThroughArgs= REM __UnprocessedBuildArgs are args that we pass to msbuild (e.g. /p:OfficialBuildId=value) set "__remainingArgs=%*" set __UnprocessedBuildArgs= -set __CommonMSBuildArgs= set __BuildNative=1 set __BuildCrossArchNative=0 @@ -159,8 +158,6 @@ if /i "%1" == "skiprestoreoptdata" (set __RestoreOptData=0&shift&goto Arg_Loop) if /i "%1" == "pgoinstrument" (set __PgoInstrument=1&shift&goto Arg_Loop) if /i "%1" == "enforcepgo" (set __EnforcePgo=1&shift&goto Arg_Loop) -REM Preserve the equal sign for MSBuild properties -if "!__remainingArgs:~0,1!" == "=" (set "__UnprocessedBuildArgs=!__UnprocessedBuildArgs! %1=%2"&set "__remainingArgs=!__remainingArgs:*%2=!"&shift&shift&goto Arg_Loop) set "__UnprocessedBuildArgs=!__UnprocessedBuildArgs! %1"&shift&goto Arg_Loop :ArgsDone @@ -209,8 +206,6 @@ if %__BuildTypeDebug%==1 set __BuildType=Debug if %__BuildTypeChecked%==1 set __BuildType=Checked if %__BuildTypeRelease%==1 set __BuildType=Release -set __CommonMSBuildArgs=/p:TargetOS=%__TargetOS% /p:Configuration=%__BuildType% /p:TargetArchitecture=%__BuildArch% - if %__EnforcePgo%==1 ( if %__BuildArchArm%==1 ( echo NOTICE: enforcepgo does nothing on arm architecture diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj index 07b1762a341ff..1e972b6dc85b0 100644 --- a/src/coreclr/runtime.proj +++ b/src/coreclr/runtime.proj @@ -45,7 +45,6 @@ <_CoreClrBuildArg Condition="'$(Ninja)' == 'false' and $([MSBuild]::IsOsPlatform(Windows))" Include="-msbuild" /> <_CoreClrBuildArg Condition="'$(PgoInstrument)' == 'true'" Include="-pgoinstrument" /> <_CoreClrBuildArg Condition="'$(NoPgoOptimize)' != 'true' and '$(PgoInstrument)' != 'true'" Include="-pgodatapath "$(PgoDataPath)"" /> - <_CoreClrBuildArg Condition="'$(OfficialBuildId)' != ''" Include="/p:OfficialBuildId=$(OfficialBuildId)" /> From 81f808ef795e0b6faf3d510c099550b7fc212a1a Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 8 Sep 2021 09:55:09 -0700 Subject: [PATCH 04/42] Apply suggestions from code review Co-authored-by: Viktor Hofer Co-authored-by: Jan Kotas --- src/coreclr/runtime-prereqs.proj | 2 +- src/coreclr/versionfallback/_version.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/coreclr/runtime-prereqs.proj b/src/coreclr/runtime-prereqs.proj index 577bca9881ff1..bd018e1734f16 100644 --- a/src/coreclr/runtime-prereqs.proj +++ b/src/coreclr/runtime-prereqs.proj @@ -1,6 +1,6 @@ - $(ArtifactsObjDir)/coreclr/_version.h + $(ArtifactsObjDir)coreclr/_version.h $(ArtifactsObjDir)/coreclr/runtime_version.h diff --git a/src/coreclr/versionfallback/_version.h b/src/coreclr/versionfallback/_version.h index 98873728c39d3..25268bf7e52db 100644 --- a/src/coreclr/versionfallback/_version.h +++ b/src/coreclr/versionfallback/_version.h @@ -1,8 +1,8 @@ #ifndef VER_COMPANYNAME_STR -#define VER_COMPANYNAME_STR "Microsoft Corporation" +#define VER_COMPANYNAME_STR ".NET Foundation" #endif #ifndef VER_FILEDESCRIPTION_STR -#define VER_FILEDESCRIPTION_STR "empty" +#define VER_FILEDESCRIPTION_STR ".NET Runtime" #endif #ifndef VER_INTERNALNAME_STR #define VER_INTERNALNAME_STR VER_FILEDESCRIPTION_STR @@ -11,7 +11,7 @@ #define VER_ORIGINALFILENAME_STR VER_FILEDESCRIPTION_STR #endif #ifndef VER_PRODUCTNAME_STR -#define VER_PRODUCTNAME_STR "Microsoft\xae .NET Framework" +#define VER_PRODUCTNAME_STR ".NET" #endif #undef VER_PRODUCTVERSION #define VER_PRODUCTVERSION 00,00,00,00000 @@ -22,7 +22,7 @@ #undef VER_FILEVERSION_STR #define VER_FILEVERSION_STR "00,00,00,00000" #ifndef VER_LEGALCOPYRIGHT_STR -#define VER_LEGALCOPYRIGHT_STR "\xa9 Microsoft Corporation. All rights reserved." +#define VER_LEGALCOPYRIGHT_STR ".NET Foundation" #endif #ifndef VER_DEBUG #define VER_DEBUG VS_FF_DEBUG From db7eb91cd32426774bd635c862424af0619a6c9c Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 8 Sep 2021 10:22:37 -0700 Subject: [PATCH 05/42] Move some targets around based on feedback. --- src/coreclr/.nuget/optdata/optdata.proj | 37 ++++++++++--------------- src/coreclr/runtime-prereqs.proj | 16 ++--------- 2 files changed, 16 insertions(+), 37 deletions(-) diff --git a/src/coreclr/.nuget/optdata/optdata.proj b/src/coreclr/.nuget/optdata/optdata.proj index d219f7a3e2558..ba49b5f84e793 100644 --- a/src/coreclr/.nuget/optdata/optdata.proj +++ b/src/coreclr/.nuget/optdata/optdata.proj @@ -2,7 +2,6 @@ $(NetCoreAppCurrent) - true True True @@ -22,14 +21,13 @@ - + - - - - + + + @@ -55,22 +53,15 @@ - - - - - - - - - + + + + + + diff --git a/src/coreclr/runtime-prereqs.proj b/src/coreclr/runtime-prereqs.proj index bd018e1734f16..79c57d0d86b02 100644 --- a/src/coreclr/runtime-prereqs.proj +++ b/src/coreclr/runtime-prereqs.proj @@ -1,7 +1,7 @@ $(ArtifactsObjDir)coreclr/_version.h - $(ArtifactsObjDir)/coreclr/runtime_version.h + $(ArtifactsObjDir)coreclr/runtime_version.h @@ -11,17 +11,5 @@ - - - - - - - - - + From 5fbd69ebedbf2817b3c0fdd2d59e17b46f4225e8 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 8 Sep 2021 10:31:51 -0700 Subject: [PATCH 06/42] Output version files in the artifacts/obj dir so they can be easily shared. --- eng/native/configurepaths.cmake | 1 + src/coreclr/CMakeLists.txt | 2 +- src/coreclr/dlls/mscordac/CMakeLists.txt | 2 +- src/coreclr/runtime-prereqs.proj | 5 +++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/eng/native/configurepaths.cmake b/eng/native/configurepaths.cmake index d59e1aafc5d1a..7a14829306787 100644 --- a/eng/native/configurepaths.cmake +++ b/eng/native/configurepaths.cmake @@ -2,3 +2,4 @@ get_filename_component(CLR_REPO_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUT set(CLR_ENG_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}) get_filename_component(CLR_SRC_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../src/native ABSOLUTE) get_filename_component(CLR_SRC_LIBS_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../src/libraries/Native ABSOLUTE) +set (CLR_ARTIFACTS_OBJ_DIR ${CLR_REPO_ROOT_DIR}/artifacts/obj) diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 6f8897c20c796..2b8d80f1565d9 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -27,7 +27,7 @@ set(CLR_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(VM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vm) set(GENERATED_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/inc) set(GENERATED_EVENTING_DIR ${CMAKE_CURRENT_BINARY_DIR}/Eventing) -set(VERSION_FILE_PATH "${CMAKE_BINARY_DIR}/version.c") +set(CLR_ARTIFACTS_OBJ_DIR "${CMAKE_BINARY_DIR}/version.c") set(PAL_REDEFINES_FILE ${CMAKE_CURRENT_SOURCE_DIR}/dlls/mscordac/palredefines.S) # Avoid logging when skipping up-to-date copies diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index 2492842369601..d42f0476a05b5 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -203,7 +203,7 @@ if(CLR_CMAKE_HOST_WIN32) if (LONG_NAME_TARGET_ARCH STREQUAL x64) set(LONG_NAME_TARGET_ARCH "amd64") endif() - set(NATIVE_VERSION_HEADER_FILE "${CLR_DIR}/../../artifacts/obj/coreclr/_version.h") + set(NATIVE_VERSION_HEADER_FILE "${CLR_DIR}/../../artifacts/obj/_version.h") message ("Read file version from native version header at '${NATIVE_VERSION_HEADER_FILE}'.") file(READ "${NATIVE_VERSION_HEADER_FILE}" NATIVE_VERSION_HEADER) string(REGEX MATCH "#define VER_FILEVERSION[ \t]+[0-9]+(,[0-9]+)+" FILE_VERSION_LINE "${NATIVE_VERSION_HEADER}") diff --git a/src/coreclr/runtime-prereqs.proj b/src/coreclr/runtime-prereqs.proj index 79c57d0d86b02..d5fa8a1fec9c5 100644 --- a/src/coreclr/runtime-prereqs.proj +++ b/src/coreclr/runtime-prereqs.proj @@ -1,7 +1,8 @@ - $(ArtifactsObjDir)coreclr/_version.h - $(ArtifactsObjDir)coreclr/runtime_version.h + $(ArtifactsObjDir)_version.h + $(ArtifactsObjDir)_version.c + $(ArtifactsObjDir)runtime_version.h From 790204b39c4c2813b6e868a7cb0b73ada8d766d6 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 8 Sep 2021 10:53:46 -0700 Subject: [PATCH 07/42] Move native pgo into a targets file instead of being a separate project to be more static-graph friendly. --- eng/nativepgo.targets | 56 ++++++++++++++++ .../.nuget/optdata/Directory.Build.props | 4 -- .../.nuget/optdata/Directory.Build.targets | 4 -- src/coreclr/.nuget/optdata/optdata.proj | 67 ------------------- src/coreclr/runtime-prereqs.proj | 4 +- src/coreclr/runtime.proj | 18 ++--- 6 files changed, 63 insertions(+), 90 deletions(-) create mode 100644 eng/nativepgo.targets delete mode 100644 src/coreclr/.nuget/optdata/Directory.Build.props delete mode 100644 src/coreclr/.nuget/optdata/Directory.Build.targets delete mode 100644 src/coreclr/.nuget/optdata/optdata.proj diff --git a/eng/nativepgo.targets b/eng/nativepgo.targets new file mode 100644 index 0000000000000..1a5d22e94436d --- /dev/null +++ b/eng/nativepgo.targets @@ -0,0 +1,56 @@ + + + true + true + false + false + + <_NativeOptimizationDataPackageTarget>$(TargetOS.ToLower())-$(TargetArchitecture.ToLower()) + <_NativeOptimizationDataPackageTarget Condition="'$(TargetOS)' == 'windows'">windows_nt-$(TargetArchitecture.ToLower()) + + + + + + + + + + + + + + + + + + + + Pkgoptimization_$(_NativeOptimizationDataPackageTarget)_PGO_CoreCLR + + + + + + + $(%(Identity)) + + + + + @(PgoPackagePathPropertyItemList->'%(PgoPackagePath)') + + + + + + + + + diff --git a/src/coreclr/.nuget/optdata/Directory.Build.props b/src/coreclr/.nuget/optdata/Directory.Build.props deleted file mode 100644 index 4ac51105d96d4..0000000000000 --- a/src/coreclr/.nuget/optdata/Directory.Build.props +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/coreclr/.nuget/optdata/Directory.Build.targets b/src/coreclr/.nuget/optdata/Directory.Build.targets deleted file mode 100644 index 18aaf2d3aabf4..0000000000000 --- a/src/coreclr/.nuget/optdata/Directory.Build.targets +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/coreclr/.nuget/optdata/optdata.proj b/src/coreclr/.nuget/optdata/optdata.proj deleted file mode 100644 index ba49b5f84e793..0000000000000 --- a/src/coreclr/.nuget/optdata/optdata.proj +++ /dev/null @@ -1,67 +0,0 @@ - - - - $(NetCoreAppCurrent) - - True - True - - - win7-x64;win7-x86;linux-x64 - true - <_TargetOSArchLowercase>$(TargetOS.ToLower())-$(TargetArchitecture.ToLower()) - <_TargetOSArchLowercase Condition="'$(TargetOS)' == 'windows'">windows_nt-$(TargetArchitecture.ToLower()) - - - - - - - - - - - - - - - - - - - Pkgoptimization_$(_TargetOSArchLowercase)_PGO_CoreCLR - - - - - - - $(%(Identity)) - - - - - @(PgoPackagePathPropertyItemList->'%(PgoPackagePath)') - - - - - - - - - - - - - diff --git a/src/coreclr/runtime-prereqs.proj b/src/coreclr/runtime-prereqs.proj index d5fa8a1fec9c5..feabb4fff5f9a 100644 --- a/src/coreclr/runtime-prereqs.proj +++ b/src/coreclr/runtime-prereqs.proj @@ -6,11 +6,11 @@ - + - + diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj index 1e972b6dc85b0..2765ff402f722 100644 --- a/src/coreclr/runtime.proj +++ b/src/coreclr/runtime.proj @@ -8,19 +8,11 @@ + + - - - - - - - <_CoreClrBuildArg Condition="'$(TargetArchitecture)' != ''" Include="-$(TargetArchitecture)" /> <_CoreClrBuildArg Condition="!$([MSBuild]::IsOsPlatform(Windows)) and '$(CMakeArgs)' != ''" Include="$(CMakeArgs)" /> @@ -37,14 +29,14 @@ ('$(TargetArchitecture)' == 'x86' or '$(TargetArchitecture)' == 'x64') and '$(Configuration)' == 'Release' and '$(ClrRuntimeSubset)' == 'true' and - '$(NoPgoOptimize)' != 'true' and + '$(NativeOptimizationDataSupported)' == 'true' and '$(PgoInstrument)' != 'true'" Include="-enforcepgo" /> <_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows)) and '$(CrossDac)' != ''" Include="-$(CrossDac)dac" /> <_CoreClrBuildArg Condition="'$(Ninja)' == 'true' and !$([MSBuild]::IsOsPlatform(Windows))" Include="-ninja" /> <_CoreClrBuildArg Condition="'$(Ninja)' == 'false' and $([MSBuild]::IsOsPlatform(Windows))" Include="-msbuild" /> <_CoreClrBuildArg Condition="'$(PgoInstrument)' == 'true'" Include="-pgoinstrument" /> - <_CoreClrBuildArg Condition="'$(NoPgoOptimize)' != 'true' and '$(PgoInstrument)' != 'true'" Include="-pgodatapath "$(PgoDataPath)"" /> + <_CoreClrBuildArg Condition="'$(NativeOptimizationDataSupported)' == 'true' and '$(PgoInstrument)' != 'true'" Include="-pgodatapath "$(PgoPackagePath)"" /> From 751f259bd9b5a6d7674e8f62886549cd65f49f26 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 8 Sep 2021 13:26:06 -0700 Subject: [PATCH 08/42] Fix subsets. --- eng/Subsets.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/Subsets.props b/eng/Subsets.props index b6c8e7147decb..48f2dc79353be 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -188,11 +188,11 @@ $(ClrRuntimeBuildSubsets);ClrILToolsSubset=true - + - + From 1066209b4882dd4140fe452d508791dee621ba4b Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 8 Sep 2021 13:27:55 -0700 Subject: [PATCH 09/42] Share version file path by default --- eng/native/configurepaths.cmake | 3 ++- src/coreclr/CMakeLists.txt | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/native/configurepaths.cmake b/eng/native/configurepaths.cmake index 7a14829306787..92a2f13b162c8 100644 --- a/eng/native/configurepaths.cmake +++ b/eng/native/configurepaths.cmake @@ -2,4 +2,5 @@ get_filename_component(CLR_REPO_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUT set(CLR_ENG_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}) get_filename_component(CLR_SRC_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../src/native ABSOLUTE) get_filename_component(CLR_SRC_LIBS_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../src/libraries/Native ABSOLUTE) -set (CLR_ARTIFACTS_OBJ_DIR ${CLR_REPO_ROOT_DIR}/artifacts/obj) +set (CLR_ARTIFACTS_OBJ_DIR "${CLR_REPO_ROOT_DIR}/artifacts/obj") +set(VERSION_FILE_PATH "${CMAKE_BINARY_DIR}/_version.c") diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 2b8d80f1565d9..87d5e5b59411e 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -27,7 +27,6 @@ set(CLR_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(VM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vm) set(GENERATED_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/inc) set(GENERATED_EVENTING_DIR ${CMAKE_CURRENT_BINARY_DIR}/Eventing) -set(CLR_ARTIFACTS_OBJ_DIR "${CMAKE_BINARY_DIR}/version.c") set(PAL_REDEFINES_FILE ${CMAKE_CURRENT_SOURCE_DIR}/dlls/mscordac/palredefines.S) # Avoid logging when skipping up-to-date copies From 2bb8b1d767e059e10e4c3dbce014fe3fca568f01 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 8 Sep 2021 13:37:19 -0700 Subject: [PATCH 10/42] Fix VER_FILEDESCRIPTION_STR --- src/coreclr/runtime-prereqs.proj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/runtime-prereqs.proj b/src/coreclr/runtime-prereqs.proj index feabb4fff5f9a..1127c3df8bdf3 100644 --- a/src/coreclr/runtime-prereqs.proj +++ b/src/coreclr/runtime-prereqs.proj @@ -3,6 +3,7 @@ $(ArtifactsObjDir)_version.h $(ArtifactsObjDir)_version.c $(ArtifactsObjDir)runtime_version.h + .NET Runtime From 0d1e82b68711c736374e0c8557c73c19373ee1fe Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 8 Sep 2021 15:39:04 -0700 Subject: [PATCH 11/42] Fix version fallback copies. --- src/coreclr/build-runtime.cmd | 6 +++--- src/coreclr/build-runtime.sh | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index f1b48ae65fd05..204b128a0c7b1 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -16,7 +16,7 @@ set __ThisScriptFull="%~f0" :: __ProjectDir -- default: directory of the dir.props file :: __RepoRootDir -- default: directory two levels above the dir.props file :: __RootBinDir -- default: %__RepoRootDir%\artifacts\ -:: __BinDir -- default: %__RootBinDir%\%__TargetOS%.%__BuildArch.%__BuildType%\ +:: __BinDir -- default: %__RootBinDir%\obj\coreclr\%__TargetOS%.%__BuildArch.%__BuildType%\ :: __IntermediatesDir :: __PackagesBinDir -- default: %__BinDir%\.nuget :: @@ -307,8 +307,8 @@ REM ============================================================================ REM We will copy our fallback version files to the expected directory if no one generated REM and version files previously. for /r "%__ProjectDir%\versionfallback" %%a in (*) do ( - if not exist "%__RootBinDir%\obj\coreclr\%%~nxa" ( - copy "%%a" "%__RootBinDir%\obj\coreclr" + if not exist "%__RootBinDir%\obj\%%~nxa" ( + copy "%%a" "%__RootBinDir%\obj" ) ) diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh index ffd9b340a21e7..d8b2b6ab2aad4 100755 --- a/src/coreclr/build-runtime.sh +++ b/src/coreclr/build-runtime.sh @@ -69,7 +69,7 @@ build_cross_architecture_components() copy_version_files() { # Copy dummy version files if version files haven't already been generated - cp -r -n "$__ProjectRoot/versionfallback/"* "$__ArtifactsIntermediatesDir/" + cp -r -n "$__ProjectRoot/versionfallback/"* "$__ArtifactsObjDir/" } handle_arguments_local() { @@ -159,7 +159,8 @@ __LogsDir="$__RootBinDir/log/$__BuildType" __MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs" __ConfigTriplet="$__TargetOS.$__BuildArch.$__BuildType" __BinDir="$__RootBinDir/bin/coreclr/$__ConfigTriplet" -__ArtifactsIntermediatesDir="$__RepoRootDir/artifacts/obj/coreclr" +__ArtifactsObjDir="$__RepoRootDir/artifacts/obj" +__ArtifactsIntermediatesDir="$__ArtifactsObjDir/coreclr" __IntermediatesDir="$__ArtifactsIntermediatesDir/$__ConfigTriplet" export __IntermediatesDir __ArtifactsIntermediatesDir From 99fb01fe02e7e89ae402caf65ed107771361531e Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 9 Sep 2021 11:26:16 -0700 Subject: [PATCH 12/42] Fix include path for the version headers. --- src/coreclr/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 87d5e5b59411e..15e042547044f 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -132,7 +132,7 @@ endif() #------------------------------------- # Include the basic prebuilt headers - required for getting fileversion resource details. include_directories("pal/prebuilt/inc") -include_directories("../../artifacts/obj/coreclr") +include_directories(${CLR_ARTIFACTS_OBJ_DIR}) add_subdirectory(tools/aot/jitinterface) From 0411fabc15237bef2960127071a91e0290993f0c Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 9 Sep 2021 11:31:55 -0700 Subject: [PATCH 13/42] Update src/coreclr/dlls/mscordac/CMakeLists.txt Co-authored-by: Juan Hoyos <19413848+hoyosjs@users.noreply.github.com> --- src/coreclr/dlls/mscordac/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index d42f0476a05b5..8ea586d058688 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -203,7 +203,7 @@ if(CLR_CMAKE_HOST_WIN32) if (LONG_NAME_TARGET_ARCH STREQUAL x64) set(LONG_NAME_TARGET_ARCH "amd64") endif() - set(NATIVE_VERSION_HEADER_FILE "${CLR_DIR}/../../artifacts/obj/_version.h") + set(NATIVE_VERSION_HEADER_FILE "${CLR_ARTIFACTS_OBJ_DIR}/_version.h") message ("Read file version from native version header at '${NATIVE_VERSION_HEADER_FILE}'.") file(READ "${NATIVE_VERSION_HEADER_FILE}" NATIVE_VERSION_HEADER) string(REGEX MATCH "#define VER_FILEVERSION[ \t]+[0-9]+(,[0-9]+)+" FILE_VERSION_LINE "${NATIVE_VERSION_HEADER}") From 70afaada3fe62fe86577fbdaa55100b7dc34f016 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 9 Sep 2021 12:15:10 -0700 Subject: [PATCH 14/42] Enable easily sharing the fallback version files between all components of the repo. --- eng/native/build-commons.sh | 8 ++++ eng/native/configurepaths.cmake | 3 +- eng/native/versionfallback/NativeVersion.rc | 41 +++++++++++++++++++ eng/native/versionfallback/_version.h | 29 +++++++++++++ .../versionfallback/copy_version_files.cmd | 12 ++++++ .../versionfallback/copy_version_files.sh | 4 ++ eng/native/versionfallback/runtime_version.h | 10 +++++ eng/native/versionfallback/version.c | 4 ++ src/coreclr/build-runtime.cmd | 8 +--- src/coreclr/build-runtime.sh | 6 --- src/libraries/Native/Unix/CMakeLists.txt | 1 - .../CMakeLists.txt | 2 +- src/libraries/Native/build-native.cmd | 2 + 13 files changed, 114 insertions(+), 16 deletions(-) create mode 100644 eng/native/versionfallback/NativeVersion.rc create mode 100644 eng/native/versionfallback/_version.h create mode 100644 eng/native/versionfallback/copy_version_files.cmd create mode 100755 eng/native/versionfallback/copy_version_files.sh create mode 100644 eng/native/versionfallback/runtime_version.h create mode 100644 eng/native/versionfallback/version.c diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 7d00148e98903..a40b2a8923ffb 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -66,8 +66,16 @@ check_prereqs() fi } +copy_version_files() +{ + # Copy dummy version files if version files haven't already been generated + cp -r -n "$__RepoRootDir/eng/native/versionfallback/"* "$__RepoRootDir/artifacts/obj/" +} + build_native() { + "$__RepoRootDir/eng/native/versionfallback/copy_version_files.sh" + targetOS="$1" platformArch="$2" cmakeDir="$3" diff --git a/eng/native/configurepaths.cmake b/eng/native/configurepaths.cmake index 92a2f13b162c8..ab45062d76b87 100644 --- a/eng/native/configurepaths.cmake +++ b/eng/native/configurepaths.cmake @@ -3,4 +3,5 @@ set(CLR_ENG_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}) get_filename_component(CLR_SRC_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../src/native ABSOLUTE) get_filename_component(CLR_SRC_LIBS_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../src/libraries/Native ABSOLUTE) set (CLR_ARTIFACTS_OBJ_DIR "${CLR_REPO_ROOT_DIR}/artifacts/obj") -set(VERSION_FILE_PATH "${CMAKE_BINARY_DIR}/_version.c") +set(VERSION_FILE_PATH "${CLR_ARTIFACTS_OBJ_DIR}/_version.c") +set(VERSION_FILE_RC_PATH "${CLR_ARTIFACTS_OBJ_DIR}/NativeVersion.rc") diff --git a/eng/native/versionfallback/NativeVersion.rc b/eng/native/versionfallback/NativeVersion.rc new file mode 100644 index 0000000000000..618bb1145ed3a --- /dev/null +++ b/eng/native/versionfallback/NativeVersion.rc @@ -0,0 +1,41 @@ +#include "_version.h" + +#include + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VER_FILEVERSION +PRODUCTVERSION VER_PRODUCTVERSION +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS VER_DEBUG +FILEOS VOS__WINDOWS32 +FILETYPE VFT_DLL +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", VER_COMPANYNAME_STR + VALUE "FileDescription", VER_FILEDESCRIPTION_STR + VALUE "FileVersion", VER_FILEVERSION_STR + VALUE "InternalName", VER_INTERNALNAME_STR + VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR + VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR + VALUE "ProductName", VER_PRODUCTNAME_STR + VALUE "ProductVersion", VER_PRODUCTVERSION_STR + END + END + + BLOCK "VarFileInfo" + BEGIN + /* The following line should only be modified for localized versions. */ + /* It consists of any number of WORD,WORD pairs, with each pair */ + /* describing a language,codepage combination supported by the file. */ + /* */ + /* For example, a file might have values "0x409,1252" indicating that it */ + /* supports English language (0x409) in the Windows ANSI codepage (1252). */ + + VALUE "Translation", 0x409, 1252 + + END +END diff --git a/eng/native/versionfallback/_version.h b/eng/native/versionfallback/_version.h new file mode 100644 index 0000000000000..25268bf7e52db --- /dev/null +++ b/eng/native/versionfallback/_version.h @@ -0,0 +1,29 @@ +#ifndef VER_COMPANYNAME_STR +#define VER_COMPANYNAME_STR ".NET Foundation" +#endif +#ifndef VER_FILEDESCRIPTION_STR +#define VER_FILEDESCRIPTION_STR ".NET Runtime" +#endif +#ifndef VER_INTERNALNAME_STR +#define VER_INTERNALNAME_STR VER_FILEDESCRIPTION_STR +#endif +#ifndef VER_ORIGINALFILENAME_STR +#define VER_ORIGINALFILENAME_STR VER_FILEDESCRIPTION_STR +#endif +#ifndef VER_PRODUCTNAME_STR +#define VER_PRODUCTNAME_STR ".NET" +#endif +#undef VER_PRODUCTVERSION +#define VER_PRODUCTVERSION 00,00,00,00000 +#undef VER_PRODUCTVERSION_STR +#define VER_PRODUCTVERSION_STR "0.0.0" +#undef VER_FILEVERSION +#define VER_FILEVERSION 00,00,00,00000 +#undef VER_FILEVERSION_STR +#define VER_FILEVERSION_STR "00,00,00,00000" +#ifndef VER_LEGALCOPYRIGHT_STR +#define VER_LEGALCOPYRIGHT_STR ".NET Foundation" +#endif +#ifndef VER_DEBUG +#define VER_DEBUG VS_FF_DEBUG +#endif diff --git a/eng/native/versionfallback/copy_version_files.cmd b/eng/native/versionfallback/copy_version_files.cmd new file mode 100644 index 0000000000000..e042b48e8f64a --- /dev/null +++ b/eng/native/versionfallback/copy_version_files.cmd @@ -0,0 +1,12 @@ +@if not defined _echo @echo off +setlocal EnableDelayedExpansion EnableExtensions + +set __VersionFallbackFolder=%~dp0 +set __RepoRoot=%~dp0..\..\.. +set __artifactsObjDir=%__RepoRoot%\artifacts\obj + +for /r "%__VersionFallbackFolder%" %%a in (*.h *.rc) do ( + if not exist "%__artifactsObjDir%\%%~nxa" ( + copy "%%a" "%__artifactsObjDir%" + ) +) diff --git a/eng/native/versionfallback/copy_version_files.sh b/eng/native/versionfallback/copy_version_files.sh new file mode 100755 index 0000000000000..48d8621ef92ec --- /dev/null +++ b/eng/native/versionfallback/copy_version_files.sh @@ -0,0 +1,4 @@ +__VersionFallbackFolder="$(cd "$(dirname "$0")"; pwd -P)" +__RepoRoot="$(cd "$(dirname "$__VersionFallbackFolder")/../../"; pwd -P)" + +cp -r -n "${__VersionFallbackFolder}/"*{.h,.c} "$__RepoRoot/artifacts/obj/" diff --git a/eng/native/versionfallback/runtime_version.h b/eng/native/versionfallback/runtime_version.h new file mode 100644 index 0000000000000..c261e2f994a72 --- /dev/null +++ b/eng/native/versionfallback/runtime_version.h @@ -0,0 +1,10 @@ +#define RuntimeAssemblyMajorVersion 0 +#define RuntimeAssemblyMinorVersion 0 +#define RuntimeFileMajorVersion 0 +#define RuntimeFileMinorVersion 0 +#define RuntimeFileBuildVersion 0 +#define RuntimeFileRevisionVersion 0 +#define RuntimeProductMajorVersion 0 +#define RuntimeProductMinorVersion 0 +#define RuntimeProductPatchVersion 0 +#define RuntimeProductVersion diff --git a/eng/native/versionfallback/version.c b/eng/native/versionfallback/version.c new file mode 100644 index 0000000000000..153d9f05f14e4 --- /dev/null +++ b/eng/native/versionfallback/version.c @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +static char sccsid[] __attribute__((used)) = "@(#)No version information produced"; diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index 204b128a0c7b1..7787bf59f2d9e 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -304,13 +304,7 @@ REM ============================================================================ @if defined _echo @echo on -REM We will copy our fallback version files to the expected directory if no one generated -REM and version files previously. -for /r "%__ProjectDir%\versionfallback" %%a in (*) do ( - if not exist "%__RootBinDir%\obj\%%~nxa" ( - copy "%%a" "%__RootBinDir%\obj" - ) -) +call "%__RepoRootDir%\eng\native\versionfallback\copy_version_files.cmd" REM ========================================================================================= REM === diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh index d8b2b6ab2aad4..e694e7f199ccd 100755 --- a/src/coreclr/build-runtime.sh +++ b/src/coreclr/build-runtime.sh @@ -66,12 +66,6 @@ build_cross_architecture_components() export CROSSCOMPILE } -copy_version_files() -{ - # Copy dummy version files if version files haven't already been generated - cp -r -n "$__ProjectRoot/versionfallback/"* "$__ArtifactsObjDir/" -} - handle_arguments_local() { case "$1" in diff --git a/src/libraries/Native/Unix/CMakeLists.txt b/src/libraries/Native/Unix/CMakeLists.txt index 1b0fbe036d3b6..e6974b707c4ed 100644 --- a/src/libraries/Native/Unix/CMakeLists.txt +++ b/src/libraries/Native/Unix/CMakeLists.txt @@ -23,7 +23,6 @@ endif() set(CMAKE_INSTALL_PREFIX $ENV{__CMakeBinDir}) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") -set(VERSION_FILE_PATH "${CMAKE_BINARY_DIR}/version.c") add_compile_options(-I${CMAKE_CURRENT_SOURCE_DIR}/Common) add_compile_options(-I${CMAKE_CURRENT_BINARY_DIR}/Common) diff --git a/src/libraries/Native/Windows/System.IO.Compression.Native/CMakeLists.txt b/src/libraries/Native/Windows/System.IO.Compression.Native/CMakeLists.txt index 0ca238d56fd92..936c077419f27 100644 --- a/src/libraries/Native/Windows/System.IO.Compression.Native/CMakeLists.txt +++ b/src/libraries/Native/Windows/System.IO.Compression.Native/CMakeLists.txt @@ -85,7 +85,7 @@ if (GEN_SHARED_LIB) ${NATIVECOMPRESSION_SOURCES} System.IO.Compression.Native.def # This will add versioning to the library - ${CMAKE_REPO_ROOT}/artifacts/obj/NativeVersion.rc + ${VERSION_FILE_RC_PATH} ) endif() diff --git a/src/libraries/Native/build-native.cmd b/src/libraries/Native/build-native.cmd index c9c3216e5d717..23c4715be17dc 100644 --- a/src/libraries/Native/build-native.cmd +++ b/src/libraries/Native/build-native.cmd @@ -49,6 +49,8 @@ if NOT [%errorlevel%] == [0] goto :Failure echo Commencing build of native components echo. +call "%__engNativeDir%\versionfallback\copy_version_files.cmd" + :: cmake requires forward slashes in paths set __cmakeRepoRoot=%__repoRoot:\=/% set __ExtraCmakeParams="-DCMAKE_REPO_ROOT=%__cmakeRepoRoot%" From d4e8d9cceba86cc70f28815b8859c6cc89425e12 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 9 Sep 2021 12:22:50 -0700 Subject: [PATCH 15/42] Remove some now-unused command-line options from our build scripts. --- docs/workflow/building/coreclr/android.md | 2 +- .../libraries/freebsd-instructions.md | 4 +-- eng/native/build-commons.sh | 30 ------------------- .../coreclr/templates/build-jit-job.yml | 4 +-- src/coreclr/build-runtime.cmd | 7 ----- src/coreclr/build-runtime.sh | 2 -- src/libraries/Native/build-native.sh | 2 -- src/native/corehost/build.sh | 2 -- src/tests/build.sh | 2 -- 9 files changed, 5 insertions(+), 50 deletions(-) diff --git a/docs/workflow/building/coreclr/android.md b/docs/workflow/building/coreclr/android.md index 4b785ccad31ad..0195d00677e2b 100644 --- a/docs/workflow/building/coreclr/android.md +++ b/docs/workflow/building/coreclr/android.md @@ -29,7 +29,7 @@ When cross compiling, you need to set both the `CONFIG_DIR` and `ROOTFS_DIR` var To compile for arm64, run: ``` -CONFIG_DIR=`realpath cross/android/arm64` ROOTFS_DIR=`realpath cross/android-rootfs/toolchain/arm64/sysroot` ./build.sh cross arm64 skipgenerateversion skipmscorlib cmakeargs -DENABLE_LLDBPLUGIN=0 +CONFIG_DIR=`realpath cross/android/arm64` ROOTFS_DIR=`realpath cross/android-rootfs/toolchain/arm64/sysroot` ./build.sh cross arm64 cmakeargs -DENABLE_LLDBPLUGIN=0 ``` The resulting binaries will be found in `artifacts/bin/coreclr/Linux.BuildArch.BuildType/` diff --git a/docs/workflow/building/libraries/freebsd-instructions.md b/docs/workflow/building/libraries/freebsd-instructions.md index 53a60d0d12924..a7589bd9f2739 100644 --- a/docs/workflow/building/libraries/freebsd-instructions.md +++ b/docs/workflow/building/libraries/freebsd-instructions.md @@ -78,8 +78,8 @@ index 81b8c7b..bb26868 100644 +++ b/repos/coreclr.proj @@ -5,6 +5,7 @@ $(Platform) $(Configuration) skiptests - $(BuildArguments) -nopgooptimize - $(BuildArguments) msbuildonunsupportedplatform + $(BuildArguments) + $(BuildArguments) + $(BuildArguments) -clang6.0 $(BuildArguments) cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE $(BuildArguments) skipnuget cross -skiprestore cmakeargs -DFEATURE_GDBJIT=TRUE diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index a40b2a8923ffb..a67f0b83ec33a 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -14,26 +14,6 @@ initTargetDistroRid() initDistroRidGlobal "$__TargetOS" "$__BuildArch" "$__PortableBuild" "$passedRootfsDir" } -isMSBuildOnNETCoreSupported() -{ - __IsMSBuildOnNETCoreSupported="$__msbuildonunsupportedplatform" - - if [[ "$__IsMSBuildOnNETCoreSupported" == 1 ]]; then - return - fi - - if [[ "$__SkipManaged" == 1 ]]; then - __IsMSBuildOnNETCoreSupported=0 - return - fi - - if [[ ( "$__HostOS" == "Linux" ) && ( "$__HostArch" == "x64" || "$__HostArch" == "arm" || "$__HostArch" == "armel" || "$__HostArch" == "arm64" || "$__HostArch" == "s390x" ) ]]; then - __IsMSBuildOnNETCoreSupported=1 - elif [[ ( "$__HostOS" == "OSX" || "$__HostOS" == "FreeBSD" ) && "$__HostArch" == "x64" ]]; then - __IsMSBuildOnNETCoreSupported=1 - fi -} - setup_dirs() { echo Setting up directories for build @@ -208,7 +188,6 @@ usage() echo " will use ROOTFS_DIR environment variable if set." echo "-gcc: optional argument to build using gcc in PATH." echo "-gccx.y: optional argument to build using gcc version x.y." - echo "-msbuildonunsupportedplatform: build managed binaries even if distro is not officially supported." echo "-ninja: target ninja instead of GNU make" echo "-numproc: set the number of build processes." echo "-portablebuild: pass -portablebuild=false to force a non-portable build." @@ -233,8 +212,6 @@ __TargetOS=$os __HostOS=$os __BuildOS=$os -__msbuildonunsupportedplatform=0 - # Get the number of processors available to the scheduler # Other techniques such as `nproc` only get the number of # processors available to a single process. @@ -353,10 +330,6 @@ while :; do __CMakeArgs="$__CMakeArgs -DCLR_CMAKE_KEEP_NATIVE_SYMBOLS=true" ;; - msbuildonunsupportedplatform|-msbuildonunsupportedplatform) - __msbuildonunsupportedplatform=1 - ;; - ninja|-ninja) __UseNinja=1 ;; @@ -467,6 +440,3 @@ fi # init the target distro name initTargetDistroRid - -# Init if MSBuild for .NET Core is supported for this platform -isMSBuildOnNETCoreSupported diff --git a/eng/pipelines/coreclr/templates/build-jit-job.yml b/eng/pipelines/coreclr/templates/build-jit-job.yml index 5ac3f54679d86..fd48f4ae79b7a 100644 --- a/eng/pipelines/coreclr/templates/build-jit-job.yml +++ b/eng/pipelines/coreclr/templates/build-jit-job.yml @@ -103,10 +103,10 @@ jobs: # Build CoreCLR JIT - ${{ if ne(parameters.osGroup, 'windows') }}: - - script: $(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) $(crossArg) -ci $(compilerArg) -nopgooptimize -component alljits + - script: $(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) $(crossArg) -ci $(compilerArg) -component alljits displayName: Build CoreCLR JIT - ${{ if eq(parameters.osGroup, 'windows') }}: - - script: set __TestIntermediateDir=int&&$(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) -ci -nopgooptimize -skiprestoreoptdata -component alljits + - script: set __TestIntermediateDir=int&&$(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) -ci -component alljits displayName: Build CoreCLR JIT - ${{ if eq(parameters.uploadAs, 'azureBlob') }}: diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index 7787bf59f2d9e..f23517df29848 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -64,7 +64,6 @@ set __UnprocessedBuildArgs= set __BuildNative=1 set __BuildCrossArchNative=0 set __SkipCrossArchNative=0 -set __SkipGenerateVersion=0 set __RestoreOptData=1 set __CrossArch= set __CrossArch2= @@ -137,8 +136,6 @@ if /i "%1" == "-configureonly" (set __ConfigureOnly=1&set __BuildNative=1& if /i "%1" == "-skipconfigure" (set __SkipConfigure=1&shift&goto Arg_Loop) if /i "%1" == "-skipnative" (set __BuildNative=0&shift&goto Arg_Loop) if /i "%1" == "-skipcrossarchnative" (set __SkipCrossArchNative=1&shift&goto Arg_Loop) -if /i "%1" == "-skipgenerateversion" (set __SkipGenerateVersion=1&shift&goto Arg_Loop) -if /i "%1" == "-skiprestoreoptdata" (set __RestoreOptData=0&shift&goto Arg_Loop) REM -ninja is a no-op option since Ninja is now the default generator on Windows. if /i "%1" == "-ninja" (shift&goto Arg_Loop) if /i "%1" == "-msbuild" (set __Ninja=0&shift&goto Arg_Loop) @@ -153,8 +150,6 @@ if /i "%1" == "configureonly" (set __ConfigureOnly=1&set __BuildNative=1&s if /i "%1" == "skipconfigure" (set __SkipConfigure=1&shift&goto Arg_Loop) if /i "%1" == "skipnative" (set __BuildNative=0&shift&goto Arg_Loop) if /i "%1" == "skipcrossarchnative" (set __SkipCrossArchNative=1&shift&goto Arg_Loop) -if /i "%1" == "skipgenerateversion" (set __SkipGenerateVersion=1&shift&goto Arg_Loop) -if /i "%1" == "skiprestoreoptdata" (set __RestoreOptData=0&shift&goto Arg_Loop) if /i "%1" == "pgoinstrument" (set __PgoInstrument=1&shift&goto Arg_Loop) if /i "%1" == "enforcepgo" (set __EnforcePgo=1&shift&goto Arg_Loop) @@ -752,8 +747,6 @@ echo -configureonly: skip all builds; only run CMake ^(default: CMake and builds echo -skipconfigure: skip CMake ^(default: CMake is run^) echo -skipnative: skip building native components ^(default: native components are built^). echo -skipcrossarchnative: skip building cross-architecture native components ^(default: components are built^). -echo -skiprestoreoptdata: skip restoring optimization data used by profile-based optimizations. -echo -skipgenerateversion: skip generating the native version headers. echo. echo Examples: echo build-runtime diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh index e694e7f199ccd..915f94887908a 100755 --- a/src/coreclr/build-runtime.sh +++ b/src/coreclr/build-runtime.sh @@ -132,10 +132,8 @@ __SignTypeArg="" __SkipConfigure=0 __SkipNative=0 __SkipCrossArchNative=0 -__SkipGenerateVersion=0 __SkipManaged=0 __SkipRestore="" -__SkipRestoreOptData=0 __SourceDir="$__ProjectDir/src" __StaticAnalyzer=0 __UnprocessedBuildArgs= diff --git a/src/libraries/Native/build-native.sh b/src/libraries/Native/build-native.sh index ba3e88b4260be..adb55af23449b 100755 --- a/src/libraries/Native/build-native.sh +++ b/src/libraries/Native/build-native.sh @@ -34,11 +34,9 @@ __Compiler=clang __CompilerMajorVersion= __CompilerMinorVersion= __CrossBuild=0 -__IsMSBuildOnNETCoreSupported=0 __PortableBuild=1 __RootBinDir="$__RepoRootDir/artifacts" __SkipConfigure=0 -__SkipGenerateVersion=0 __StaticLibLink=0 __UnprocessedBuildArgs= __VerboseBuild=false diff --git a/src/native/corehost/build.sh b/src/native/corehost/build.sh index 3aa6820e73a10..333f3802f1074 100755 --- a/src/native/corehost/build.sh +++ b/src/native/corehost/build.sh @@ -19,11 +19,9 @@ __Compiler=clang __CompilerMajorVersion= __CompilerMinorVersion= __CrossBuild=0 -__IsMSBuildOnNETCoreSupported=0 __PortableBuild=1 __RootBinDir="$__RepoRootDir/artifacts" __SkipConfigure=0 -__SkipGenerateVersion=0 __StaticLibLink=0 __UnprocessedBuildArgs= __VerboseBuild=false diff --git a/src/tests/build.sh b/src/tests/build.sh index ac59074ac35c1..6436ceb888ece 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -563,7 +563,6 @@ __BuildTestDir="%3B" __BuildTestTree="%3B" __DotNetCli="$__RepoRootDir/dotnet.sh" __GenerateLayoutOnly= -__IsMSBuildOnNETCoreSupported=0 __MSBCleanBuildArgs= __NativeTestIntermediatesDir= __PortableBuild=1 @@ -572,7 +571,6 @@ __RootBinDir="$__RepoRootDir/artifacts" __RunTests=0 __SkipConfigure=0 __SkipGenerateLayout=0 -__SkipGenerateVersion=0 __SkipManaged=0 __SkipNative=0 __SkipRestore="" From dd83c26ae61ced121452c47c2770a400c31f239f Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 9 Sep 2021 15:17:22 -0700 Subject: [PATCH 16/42] Bump importance output to pass the pgo path between steps. --- eng/nativepgo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/nativepgo.targets b/eng/nativepgo.targets index 1a5d22e94436d..e73fe13a2dab2 100644 --- a/eng/nativepgo.targets +++ b/eng/nativepgo.targets @@ -51,6 +51,6 @@ - + From 19a327cf72f0de8694cc97387bbde594b6a41220 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 9 Sep 2021 15:20:04 -0700 Subject: [PATCH 17/42] Add eval statement to run copy_version_files script --- eng/native/build-commons.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index a67f0b83ec33a..e3d93fbdd129d 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -54,7 +54,7 @@ copy_version_files() build_native() { - "$__RepoRootDir/eng/native/versionfallback/copy_version_files.sh" + eval "$__RepoRootDir/eng/native/versionfallback/copy_version_files.sh" targetOS="$1" platformArch="$2" From aa6251777e1ff8af54431f78d7d308ab9928ad9f Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 9 Sep 2021 16:51:18 -0700 Subject: [PATCH 18/42] Rename some files and and standardize on a _version.c file name for Linux. --- eng/native/build-commons.sh | 4 +-- .../NativeVersion.rc | 0 .../version.c => version/_version.c} | 0 .../{versionfallback => version}/_version.h | 0 .../copy_version_files.cmd | 4 +-- eng/native/version/copy_version_files.sh | 4 +++ .../runtime_version.h | 0 .../versionfallback/copy_version_files.sh | 4 --- src/coreclr/build-runtime.cmd | 2 +- src/coreclr/versionfallback/_version.h | 29 ------------------- src/coreclr/versionfallback/runtime_version.h | 10 ------- src/coreclr/versionfallback/version.c | 4 --- src/libraries/Native/build-native.cmd | 2 +- src/libraries/Native/build-native.proj | 2 ++ 14 files changed, 12 insertions(+), 53 deletions(-) rename eng/native/{versionfallback => version}/NativeVersion.rc (100%) rename eng/native/{versionfallback/version.c => version/_version.c} (100%) rename eng/native/{versionfallback => version}/_version.h (100%) rename eng/native/{versionfallback => version}/copy_version_files.cmd (73%) create mode 100644 eng/native/version/copy_version_files.sh rename eng/native/{versionfallback => version}/runtime_version.h (100%) delete mode 100755 eng/native/versionfallback/copy_version_files.sh delete mode 100644 src/coreclr/versionfallback/_version.h delete mode 100644 src/coreclr/versionfallback/runtime_version.h delete mode 100644 src/coreclr/versionfallback/version.c diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index e3d93fbdd129d..1bd2cdd16c5bd 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -49,12 +49,12 @@ check_prereqs() copy_version_files() { # Copy dummy version files if version files haven't already been generated - cp -r -n "$__RepoRootDir/eng/native/versionfallback/"* "$__RepoRootDir/artifacts/obj/" + cp -r -n "$__RepoRootDir/eng/native/version/"* "$__RepoRootDir/artifacts/obj/" } build_native() { - eval "$__RepoRootDir/eng/native/versionfallback/copy_version_files.sh" + eval "$__RepoRootDir/eng/native/version/copy_version_files.sh" targetOS="$1" platformArch="$2" diff --git a/eng/native/versionfallback/NativeVersion.rc b/eng/native/version/NativeVersion.rc similarity index 100% rename from eng/native/versionfallback/NativeVersion.rc rename to eng/native/version/NativeVersion.rc diff --git a/eng/native/versionfallback/version.c b/eng/native/version/_version.c similarity index 100% rename from eng/native/versionfallback/version.c rename to eng/native/version/_version.c diff --git a/eng/native/versionfallback/_version.h b/eng/native/version/_version.h similarity index 100% rename from eng/native/versionfallback/_version.h rename to eng/native/version/_version.h diff --git a/eng/native/versionfallback/copy_version_files.cmd b/eng/native/version/copy_version_files.cmd similarity index 73% rename from eng/native/versionfallback/copy_version_files.cmd rename to eng/native/version/copy_version_files.cmd index e042b48e8f64a..ef5f31e24c3de 100644 --- a/eng/native/versionfallback/copy_version_files.cmd +++ b/eng/native/version/copy_version_files.cmd @@ -1,11 +1,11 @@ @if not defined _echo @echo off setlocal EnableDelayedExpansion EnableExtensions -set __VersionFallbackFolder=%~dp0 +set __VersionFolder=%~dp0 set __RepoRoot=%~dp0..\..\.. set __artifactsObjDir=%__RepoRoot%\artifacts\obj -for /r "%__VersionFallbackFolder%" %%a in (*.h *.rc) do ( +for /r "%__VersionFolder%" %%a in (*.h *.rc) do ( if not exist "%__artifactsObjDir%\%%~nxa" ( copy "%%a" "%__artifactsObjDir%" ) diff --git a/eng/native/version/copy_version_files.sh b/eng/native/version/copy_version_files.sh new file mode 100644 index 0000000000000..eb2880c0596e8 --- /dev/null +++ b/eng/native/version/copy_version_files.sh @@ -0,0 +1,4 @@ +__VersionFolder="$(cd "$(dirname "$0")"; pwd -P)" +__RepoRoot="$(cd "$(dirname "$__VersionFolder")/../../"; pwd -P)" + +cp -r -n "${__VersionFolder}/"*{.h,.c} "$__RepoRoot/artifacts/obj/" diff --git a/eng/native/versionfallback/runtime_version.h b/eng/native/version/runtime_version.h similarity index 100% rename from eng/native/versionfallback/runtime_version.h rename to eng/native/version/runtime_version.h diff --git a/eng/native/versionfallback/copy_version_files.sh b/eng/native/versionfallback/copy_version_files.sh deleted file mode 100755 index 48d8621ef92ec..0000000000000 --- a/eng/native/versionfallback/copy_version_files.sh +++ /dev/null @@ -1,4 +0,0 @@ -__VersionFallbackFolder="$(cd "$(dirname "$0")"; pwd -P)" -__RepoRoot="$(cd "$(dirname "$__VersionFallbackFolder")/../../"; pwd -P)" - -cp -r -n "${__VersionFallbackFolder}/"*{.h,.c} "$__RepoRoot/artifacts/obj/" diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index f23517df29848..dc17395f48631 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -299,7 +299,7 @@ REM ============================================================================ @if defined _echo @echo on -call "%__RepoRootDir%\eng\native\versionfallback\copy_version_files.cmd" +call "%__RepoRootDir%\eng\native\version\copy_version_files.cmd" REM ========================================================================================= REM === diff --git a/src/coreclr/versionfallback/_version.h b/src/coreclr/versionfallback/_version.h deleted file mode 100644 index 25268bf7e52db..0000000000000 --- a/src/coreclr/versionfallback/_version.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef VER_COMPANYNAME_STR -#define VER_COMPANYNAME_STR ".NET Foundation" -#endif -#ifndef VER_FILEDESCRIPTION_STR -#define VER_FILEDESCRIPTION_STR ".NET Runtime" -#endif -#ifndef VER_INTERNALNAME_STR -#define VER_INTERNALNAME_STR VER_FILEDESCRIPTION_STR -#endif -#ifndef VER_ORIGINALFILENAME_STR -#define VER_ORIGINALFILENAME_STR VER_FILEDESCRIPTION_STR -#endif -#ifndef VER_PRODUCTNAME_STR -#define VER_PRODUCTNAME_STR ".NET" -#endif -#undef VER_PRODUCTVERSION -#define VER_PRODUCTVERSION 00,00,00,00000 -#undef VER_PRODUCTVERSION_STR -#define VER_PRODUCTVERSION_STR "0.0.0" -#undef VER_FILEVERSION -#define VER_FILEVERSION 00,00,00,00000 -#undef VER_FILEVERSION_STR -#define VER_FILEVERSION_STR "00,00,00,00000" -#ifndef VER_LEGALCOPYRIGHT_STR -#define VER_LEGALCOPYRIGHT_STR ".NET Foundation" -#endif -#ifndef VER_DEBUG -#define VER_DEBUG VS_FF_DEBUG -#endif diff --git a/src/coreclr/versionfallback/runtime_version.h b/src/coreclr/versionfallback/runtime_version.h deleted file mode 100644 index c261e2f994a72..0000000000000 --- a/src/coreclr/versionfallback/runtime_version.h +++ /dev/null @@ -1,10 +0,0 @@ -#define RuntimeAssemblyMajorVersion 0 -#define RuntimeAssemblyMinorVersion 0 -#define RuntimeFileMajorVersion 0 -#define RuntimeFileMinorVersion 0 -#define RuntimeFileBuildVersion 0 -#define RuntimeFileRevisionVersion 0 -#define RuntimeProductMajorVersion 0 -#define RuntimeProductMinorVersion 0 -#define RuntimeProductPatchVersion 0 -#define RuntimeProductVersion diff --git a/src/coreclr/versionfallback/version.c b/src/coreclr/versionfallback/version.c deleted file mode 100644 index 153d9f05f14e4..0000000000000 --- a/src/coreclr/versionfallback/version.c +++ /dev/null @@ -1,4 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -static char sccsid[] __attribute__((used)) = "@(#)No version information produced"; diff --git a/src/libraries/Native/build-native.cmd b/src/libraries/Native/build-native.cmd index 23c4715be17dc..5db6e48ebdf94 100644 --- a/src/libraries/Native/build-native.cmd +++ b/src/libraries/Native/build-native.cmd @@ -49,7 +49,7 @@ if NOT [%errorlevel%] == [0] goto :Failure echo Commencing build of native components echo. -call "%__engNativeDir%\versionfallback\copy_version_files.cmd" +call "%__engNativeDir%\version\copy_version_files.cmd" :: cmake requires forward slashes in paths set __cmakeRepoRoot=%__repoRoot:\=/% diff --git a/src/libraries/Native/build-native.proj b/src/libraries/Native/build-native.proj index 6fb1d6e5dfc84..5bd59e844d75e 100644 --- a/src/libraries/Native/build-native.proj +++ b/src/libraries/Native/build-native.proj @@ -3,11 +3,13 @@ $(ArtifactsObjDir)_version.h $(ArtifactsObjDir)_version.c + .NET Runtime <_BuildNativeArgs>$(TargetArchitecture) $(Configuration) outconfig $(NetCoreAppCurrent)-$(TargetOS)-$(Configuration)-$(TargetArchitecture) -os $(TargetOS) <_BuildNativeArgs Condition="'$(OfficialBuildId)' != ''">$(_BuildNativeArgs) /p:OfficialBuildId="$(OfficialBuildId)" + From 7ddf99c9a1bf9ace6a36a537e051d94532f065da Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 9 Sep 2021 16:53:02 -0700 Subject: [PATCH 19/42] Remove temp proj ref. --- src/libraries/Native/build-native.proj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/Native/build-native.proj b/src/libraries/Native/build-native.proj index 5bd59e844d75e..279958b8e5ca1 100644 --- a/src/libraries/Native/build-native.proj +++ b/src/libraries/Native/build-native.proj @@ -9,7 +9,6 @@ - From 9817bc55e01932809fd268c37ec45bc9126cad70 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 9 Sep 2021 16:59:51 -0700 Subject: [PATCH 20/42] Fix permissions --- eng/native/version/copy_version_files.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 eng/native/version/copy_version_files.sh diff --git a/eng/native/version/copy_version_files.sh b/eng/native/version/copy_version_files.sh old mode 100644 new mode 100755 From bfcff4d877ce279f59524a5f68da37774b6245ed Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 9 Sep 2021 17:00:52 -0700 Subject: [PATCH 21/42] Reference targets to produce version file in libraries native build. --- src/libraries/Native/build-native.proj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/Native/build-native.proj b/src/libraries/Native/build-native.proj index 279958b8e5ca1..c23e65add6c86 100644 --- a/src/libraries/Native/build-native.proj +++ b/src/libraries/Native/build-native.proj @@ -13,6 +13,7 @@ @@ -40,6 +41,7 @@ From 032bf86a012836bbfaf4433217a977ace567dbf8 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 10 Sep 2021 10:07:34 -0700 Subject: [PATCH 22/42] Fix CoreCLR build breaks --- eng/pipelines/coreclr/templates/build-job.yml | 2 +- src/coreclr/debug/createdump/crashreportwriter.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/eng/pipelines/coreclr/templates/build-job.yml b/eng/pipelines/coreclr/templates/build-job.yml index 2f795dbaf8011..82a8672dd2325 100644 --- a/eng/pipelines/coreclr/templates/build-job.yml +++ b/eng/pipelines/coreclr/templates/build-job.yml @@ -190,7 +190,7 @@ jobs: - script: $(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) $(crossArg) $(osArg) -ci $(compilerArg) $(clrBuildPALTestsBuildArg) $(pgoInstrumentArg) $(officialBuildIdArg) $(clrInterpreterBuildArg) $(CoreClrPgoDataArg) displayName: Build CoreCLR Runtime - ${{ if eq(parameters.osGroup, 'windows') }}: - - script: set __TestIntermediateDir=int&&$(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) -ci $(enforcePgoArg) $(pgoInstrumentArg) $(officialBuildIdArg) $(clrInterpreterBuildArg) + - script: set __TestIntermediateDir=int&&$(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) -ci $(enforcePgoArg) $(pgoInstrumentArg) $(officialBuildIdArg) $(clrInterpreterBuildArg) $(CoreClrPgoDataArg) displayName: Build CoreCLR Runtime - ${{ if in(parameters.osGroup, 'OSX', 'iOS', 'tvOS') }}: diff --git a/src/coreclr/debug/createdump/crashreportwriter.cpp b/src/coreclr/debug/createdump/crashreportwriter.cpp index 1fb0865cf5d5f..289a98b0a0d19 100644 --- a/src/coreclr/debug/createdump/crashreportwriter.cpp +++ b/src/coreclr/debug/createdump/crashreportwriter.cpp @@ -4,7 +4,7 @@ #include "createdump.h" // Include the .NET Core version string instead of link because it is "static". -#include "version.c" +#include "_version.c" CrashReportWriter::CrashReportWriter(CrashInfo& crashInfo) : m_crashInfo(crashInfo) @@ -152,13 +152,13 @@ CrashReportWriter::WriteCrashReport() for (auto iterator = thread->StackFrames().cbegin(); iterator != thread->StackFrames().cend(); ++iterator) { if (thread->IsBeginRepeat(iterator)) - { + { OpenObject(); WriteValue32("repeated", thread->NumRepeatedFrames()); OpenArray("repeated_frames"); } if (thread->IsEndRepeat(iterator)) - { + { CloseArray(); // repeated_frames CloseObject(); } From 00333fc0ab88604f20e6eaf648610a57707420a8 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 10 Sep 2021 14:51:58 -0700 Subject: [PATCH 23/42] Generate the version files for Mono --- src/mono/mono.proj | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 22fe6353233de..e44356dfb5cbe 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -718,25 +718,18 @@ - - - + + + $(ArtifactsObjDir)_version.h + $(ArtifactsObjDir)_version.c + .NET Runtime + - - - - + - CheckEnv;GenerateMonoVersionFile;BuildMonoRuntime;BuildMonoCross + CheckEnv;GenerateRuntimeVersionFile;BuildMonoRuntime;BuildMonoCross ProvisionEmscripten;$(MonoDependsOnTargets) From 8d5745d091cb63f808f327c0e72ce2fabf43e4dc Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 10 Sep 2021 14:55:25 -0700 Subject: [PATCH 24/42] include configurepaths.cmake on the Windows CoreFX build. --- src/libraries/Native/Windows/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/Native/Windows/CMakeLists.txt b/src/libraries/Native/Windows/CMakeLists.txt index 9d69ca81c24d4..7e39522f9661d 100644 --- a/src/libraries/Native/Windows/CMakeLists.txt +++ b/src/libraries/Native/Windows/CMakeLists.txt @@ -33,6 +33,8 @@ endif() project(CoreFX) +include(../../../../eng/native/configurepaths.cmake) + # The following options are set by the razzle build add_compile_options(/d2Zi+) # make optimized builds debugging easier add_compile_options(/nologo) # Suppress Startup Banner From cfe980aaf275cedb5f5fc4a73249ba329fe022f8 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 13 Sep 2021 10:10:22 -0700 Subject: [PATCH 25/42] Restore mono.proj when building it through monoaotcross.proj. --- src/mono/monoaotcross.proj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mono/monoaotcross.proj b/src/mono/monoaotcross.proj index cc8adc6c580f3..37b5a6a2d6093 100644 --- a/src/mono/monoaotcross.proj +++ b/src/mono/monoaotcross.proj @@ -21,6 +21,9 @@ + Date: Mon, 13 Sep 2021 11:25:15 -0700 Subject: [PATCH 26/42] Update copy script to work on macos. --- eng/native/build-commons.sh | 6 ------ eng/native/version/copy_version_files.sh | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 1bd2cdd16c5bd..19308d01c0ef2 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -46,12 +46,6 @@ check_prereqs() fi } -copy_version_files() -{ - # Copy dummy version files if version files haven't already been generated - cp -r -n "$__RepoRootDir/eng/native/version/"* "$__RepoRootDir/artifacts/obj/" -} - build_native() { eval "$__RepoRootDir/eng/native/version/copy_version_files.sh" diff --git a/eng/native/version/copy_version_files.sh b/eng/native/version/copy_version_files.sh index eb2880c0596e8..d2b3aecf8c947 100755 --- a/eng/native/version/copy_version_files.sh +++ b/eng/native/version/copy_version_files.sh @@ -1,4 +1,5 @@ __VersionFolder="$(cd "$(dirname "$0")"; pwd -P)" __RepoRoot="$(cd "$(dirname "$__VersionFolder")/../../"; pwd -P)" -cp -r -n "${__VersionFolder}/"*{.h,.c} "$__RepoRoot/artifacts/obj/" +# Use yes n and interactive cp instead of -n since -n is not supported on macOS. +yes n | cp -i "${__VersionFolder}/"*{.h,.c} "$__RepoRoot/artifacts/obj/" From 7340c8e6e64e3463e9bb9715ca84eef4a5a75dbd Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 13 Sep 2021 14:05:03 -0700 Subject: [PATCH 27/42] Make sure mono pulls in the shared version files. --- eng/native/configurepaths.cmake | 2 ++ src/coreclr/dlls/mscordac/CMakeLists.txt | 5 ++--- src/libraries/Native/build-native.cmd | 4 ---- src/mono/CMakeLists.txt | 24 +++++++++++------------- src/mono/dlls/dbgshim/CMakeLists.txt | 2 +- src/mono/dlls/mscordbi/CMakeLists.txt | 2 +- src/mono/mono/mini/CMakeLists.txt | 4 ++-- 7 files changed, 19 insertions(+), 24 deletions(-) diff --git a/eng/native/configurepaths.cmake b/eng/native/configurepaths.cmake index ab45062d76b87..19407a40a1957 100644 --- a/eng/native/configurepaths.cmake +++ b/eng/native/configurepaths.cmake @@ -3,5 +3,7 @@ set(CLR_ENG_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}) get_filename_component(CLR_SRC_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../src/native ABSOLUTE) get_filename_component(CLR_SRC_LIBS_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../src/libraries/Native ABSOLUTE) set (CLR_ARTIFACTS_OBJ_DIR "${CLR_REPO_ROOT_DIR}/artifacts/obj") +set(VERSION_HEADER_PATH "${CLR_ARTIFACTS_OBJ_DIR}/_version.h") set(VERSION_FILE_PATH "${CLR_ARTIFACTS_OBJ_DIR}/_version.c") set(VERSION_FILE_RC_PATH "${CLR_ARTIFACTS_OBJ_DIR}/NativeVersion.rc") +set(RUNTIME_VERSION_HEADER_PATH "${CLR_ARTIFACTS_OBJ_DIR}/runtime_version.h") diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index 8ea586d058688..8d04b34e48aad 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -203,9 +203,8 @@ if(CLR_CMAKE_HOST_WIN32) if (LONG_NAME_TARGET_ARCH STREQUAL x64) set(LONG_NAME_TARGET_ARCH "amd64") endif() - set(NATIVE_VERSION_HEADER_FILE "${CLR_ARTIFACTS_OBJ_DIR}/_version.h") - message ("Read file version from native version header at '${NATIVE_VERSION_HEADER_FILE}'.") - file(READ "${NATIVE_VERSION_HEADER_FILE}" NATIVE_VERSION_HEADER) + message ("Read file version from native version header at '${VERSION_HEADER_PATH}'.") + file(READ "${VERSION_HEADER_PATH}" NATIVE_VERSION_HEADER) string(REGEX MATCH "#define VER_FILEVERSION[ \t]+[0-9]+(,[0-9]+)+" FILE_VERSION_LINE "${NATIVE_VERSION_HEADER}") string(REGEX MATCHALL "[0-9]+" FILE_VERSION_COMPONENTS "${FILE_VERSION_LINE}") list(JOIN FILE_VERSION_COMPONENTS "." FILE_VERSION) diff --git a/src/libraries/Native/build-native.cmd b/src/libraries/Native/build-native.cmd index 5db6e48ebdf94..3759649bebf86 100644 --- a/src/libraries/Native/build-native.cmd +++ b/src/libraries/Native/build-native.cmd @@ -86,10 +86,6 @@ set MSBUILD_EMPTY_PROJECT_CONTENT= ^ echo %MSBUILD_EMPTY_PROJECT_CONTENT% > "%__artifactsDir%\obj\native\Directory.Build.props" echo %MSBUILD_EMPTY_PROJECT_CONTENT% > "%__artifactsDir%\obj\native\Directory.Build.targets" -:: generate version file -powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__repoRoot%\eng\common\msbuild.ps1" /clp:nosummary %__ArcadeScriptArgs%^ - "%__repoRoot%\eng\empty.csproj" /p:NativeVersionFile="%__artifactsDir%\obj\_version.h"^ - /t:GenerateNativeVersionFile /restore :: Regenerate the VS solution pushd "%__IntermediatesDir%" diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index a7038121e37da..a403ea1c5f9de 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -727,18 +727,16 @@ endif() ###################################### # EXTRACT VERSION ###################################### -if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/_version.h") +include("${CMAKE_CURRENT_SOURCE_DIR}/../../eng/native/configurepaths.cmake") +if(NOT EXISTS "${VERSION_HEADER_PATH}") if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/_version.h" "#undef VER_PRODUCTVERSION_STR\n#define VER_PRODUCTVERSION_STR \"42.42.42.42424\"\n") + file(WRITE "${VERSION_HEADER_PATH}" "#undef VER_PRODUCTVERSION_STR\n#define VER_PRODUCTVERSION_STR \"42.42.42.42424\"\n") else() - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/_version.h" "static char sccsid[] __attribute__((used)) = \"@(#)Version 42.42.42.42424 @Commit: AAA\";\n") + file(WRITE "${VERSION_HEADER_PATH}" "static char sccsid[] __attribute__((used)) = \"@(#)Version 42.42.42.42424 @Commit: AAA\";\n") endif() endif() -if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" AND NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/NativeVersion.rc") - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/NativeVersion.rc" "\n") -endif() -if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/runtime_version.h") - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/runtime_version.h" +if (NOT EXISTS "${RUNTIME_VERSION_HEADER_PATH}") + file(WRITE "${RUNTIME_VERSION_HEADER_PATH}" "#define RuntimeFileMajorVersion 42\n" "#define RuntimeFileMinorVersion 42\n" "#define RuntimeFileBuildVersion 42\n" @@ -750,16 +748,16 @@ if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/runtime_version.h") endif() if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") - file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/_version.h" product_version_string_line REGEX "VER_PRODUCTVERSION_STR ") + file(STRINGS "${VERSION_HEADER_PATH}" product_version_string_line REGEX "VER_PRODUCTVERSION_STR ") string(REGEX REPLACE ".*VER_PRODUCTVERSION_STR *(.*)" "\\1" product_version_string ${product_version_string_line}) else() - file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/_version.h" product_version_string_line REGEX "sccsid") + file(STRINGS "${VERSION_HEADER_PATH}" product_version_string_line REGEX "sccsid") string(REGEX REPLACE ".*Version *(.*)\";" "\"\\1\"" product_version_string ${product_version_string_line}) endif() -file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/runtime_version.h" runtime_version_major_line REGEX "RuntimeProductMajorVersion ") -file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/runtime_version.h" runtime_version_minor_line REGEX "RuntimeProductMinorVersion ") -file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/runtime_version.h" runtime_version_patch_line REGEX "RuntimeProductPatchVersion ") +file(STRINGS "${RUNTIME_VERSION_HEADER_PATH}" runtime_version_major_line REGEX "RuntimeProductMajorVersion ") +file(STRINGS "${RUNTIME_VERSION_HEADER_PATH}" runtime_version_minor_line REGEX "RuntimeProductMinorVersion ") +file(STRINGS "${RUNTIME_VERSION_HEADER_PATH}" runtime_version_patch_line REGEX "RuntimeProductPatchVersion ") string(REGEX REPLACE ".*RuntimeProductMajorVersion *([0-9]+)" "\\1" runtime_version_major ${runtime_version_major_line}) string(REGEX REPLACE ".*RuntimeProductMinorVersion *([0-9]+)" "\\1" runtime_version_minor ${runtime_version_minor_line}) string(REGEX REPLACE ".*RuntimeProductPatchVersion *([0-9]+)" "\\1" runtime_version_patch ${runtime_version_patch_line}) diff --git a/src/mono/dlls/dbgshim/CMakeLists.txt b/src/mono/dlls/dbgshim/CMakeLists.txt index 40c36fc1af196..7787dc02a24ed 100644 --- a/src/mono/dlls/dbgshim/CMakeLists.txt +++ b/src/mono/dlls/dbgshim/CMakeLists.txt @@ -68,7 +68,7 @@ elseif(HOST_LINUX) set(OS_LIBS pthread m dl) elseif(HOST_WIN32) set(OS_LIBS bcrypt.lib Mswsock.lib ws2_32.lib psapi.lib version.lib advapi32.lib winmm.lib kernel32.lib) -set(DBGSHIM_SOURCES "${DBGSHIM_SOURCES};${PROJECT_BINARY_DIR}/../../NativeVersion.rc") # this is generated by GenerateMonoVersionFile in mono.proj +set(DBGSHIM_SOURCES "${DBGSHIM_SOURCES};${VERSION_FILE_RC_PATH}") # this is generated by GenerateMonoVersionFile in mono.proj endif() add_library(dbgshim SHARED ${DBGSHIM_SOURCES}) diff --git a/src/mono/dlls/mscordbi/CMakeLists.txt b/src/mono/dlls/mscordbi/CMakeLists.txt index ea667c3e2b2f6..7a3bcedbd1541 100644 --- a/src/mono/dlls/mscordbi/CMakeLists.txt +++ b/src/mono/dlls/mscordbi/CMakeLists.txt @@ -89,7 +89,7 @@ elseif(HOST_LINUX) set(OS_LIBS pthread m dl) elseif(HOST_WIN32) set(OS_LIBS bcrypt.lib Mswsock.lib ws2_32.lib psapi.lib version.lib advapi32.lib winmm.lib kernel32.lib) -set(mscorbi_sources "${mscorbi_sources};${PROJECT_BINARY_DIR}/../../NativeVersion.rc") # this is generated by GenerateMonoVersionFile in mono.proj +set(mscorbi_sources "${mscorbi_sources};${VERSION_FILE_RC_PATH}NativeVersion.rc") # this is generated by GenerateMonoVersionFile in mono.proj endif() add_subdirectory(${PROJECT_SOURCE_DIR}/socket-dbi) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 5b2eac8f049ee..ce5cd566421ea 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -316,7 +316,7 @@ if(LLVM_LIBDIR) endif() if(HOST_WIN32) -set(mini_sources "${mini_sources};${PROJECT_BINARY_DIR}/../../NativeVersion.rc") # this is generated by GenerateMonoVersionFile in mono.proj +set(mini_sources "${mini_sources};${VERSION_FILE_RC_PATH}") # this is generated by GenerateMonoVersionFile in mono.proj endif() set(monosgen-sources "${metadata_sources};${utils_sources};${sgen_sources};${icu_shim_sources};${mini_sources};${zlib_sources}") @@ -472,7 +472,7 @@ add_custom_command( if(NOT DISABLE_EXECUTABLES) set(sgen_sources "main-sgen.c") if(HOST_WIN32) - set(sgen_sources "${sgen_sources};${PROJECT_BINARY_DIR}/../../NativeVersion.rc") + set(sgen_sources "${sgen_sources};${VERSION_FILE_RC_PATH}") endif() add_executable(mono-sgen "${sgen_sources}") target_link_libraries(mono-sgen PRIVATE monosgen-static ${OS_LIBS} ${ICONV_LIB} ${LLVM_LIBS} ${ICU_LIBS}) From 0a3c1c5bf9a96551c1770e83a65a6cef94298f2e Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 13 Sep 2021 16:59:38 -0700 Subject: [PATCH 28/42] Add artifcats/obj dir as include dir for CoreCLR diagonstic components included in Mono --- src/mono/dlls/dbgshim/CMakeLists.txt | 2 ++ src/mono/dlls/mscordbi/CMakeLists.txt | 1 + 2 files changed, 3 insertions(+) diff --git a/src/mono/dlls/dbgshim/CMakeLists.txt b/src/mono/dlls/dbgshim/CMakeLists.txt index 7787dc02a24ed..37dee8c075c60 100644 --- a/src/mono/dlls/dbgshim/CMakeLists.txt +++ b/src/mono/dlls/dbgshim/CMakeLists.txt @@ -1,5 +1,7 @@ project(dbgshim) +include_directories(${ARTIFACTS_OBJ_DIR}) + set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/src/mono/dlls/mscordbi/CMakeLists.txt b/src/mono/dlls/mscordbi/CMakeLists.txt index 7a3bcedbd1541..664919465cbff 100644 --- a/src/mono/dlls/mscordbi/CMakeLists.txt +++ b/src/mono/dlls/mscordbi/CMakeLists.txt @@ -1,5 +1,6 @@ project(mscordbi) +include_directories(${ARTIFACTS_OBJ_DIR}) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) From 7898e7549131a140f49869d411929fcde14e479d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 14 Sep 2021 08:49:03 -0700 Subject: [PATCH 29/42] Add artifacts/obj include for the whole mono build. --- src/mono/CMakeLists.txt | 1 + src/mono/dlls/dbgshim/CMakeLists.txt | 2 -- src/mono/dlls/mscordbi/CMakeLists.txt | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index a403ea1c5f9de..17bda4d2bd014 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -728,6 +728,7 @@ endif() # EXTRACT VERSION ###################################### include("${CMAKE_CURRENT_SOURCE_DIR}/../../eng/native/configurepaths.cmake") +include_directories(${ARTIFACTS_OBJ_DIR}) if(NOT EXISTS "${VERSION_HEADER_PATH}") if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") file(WRITE "${VERSION_HEADER_PATH}" "#undef VER_PRODUCTVERSION_STR\n#define VER_PRODUCTVERSION_STR \"42.42.42.42424\"\n") diff --git a/src/mono/dlls/dbgshim/CMakeLists.txt b/src/mono/dlls/dbgshim/CMakeLists.txt index 37dee8c075c60..7787dc02a24ed 100644 --- a/src/mono/dlls/dbgshim/CMakeLists.txt +++ b/src/mono/dlls/dbgshim/CMakeLists.txt @@ -1,7 +1,5 @@ project(dbgshim) -include_directories(${ARTIFACTS_OBJ_DIR}) - set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/src/mono/dlls/mscordbi/CMakeLists.txt b/src/mono/dlls/mscordbi/CMakeLists.txt index 664919465cbff..7a3bcedbd1541 100644 --- a/src/mono/dlls/mscordbi/CMakeLists.txt +++ b/src/mono/dlls/mscordbi/CMakeLists.txt @@ -1,6 +1,5 @@ project(mscordbi) -include_directories(${ARTIFACTS_OBJ_DIR}) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) From c0dcc5c7b7eb80807fddcc6038f9466377eba4da Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 15 Sep 2021 09:43:24 -0700 Subject: [PATCH 30/42] Update CMakeLists.txt --- src/mono/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 17bda4d2bd014..8851de144152a 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -728,7 +728,7 @@ endif() # EXTRACT VERSION ###################################### include("${CMAKE_CURRENT_SOURCE_DIR}/../../eng/native/configurepaths.cmake") -include_directories(${ARTIFACTS_OBJ_DIR}) +include_directories(${CLR_ARTIFACTS_OBJ_DIR}) if(NOT EXISTS "${VERSION_HEADER_PATH}") if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") file(WRITE "${VERSION_HEADER_PATH}" "#undef VER_PRODUCTVERSION_STR\n#define VER_PRODUCTVERSION_STR \"42.42.42.42424\"\n") From 22e1a60c1168b3127190a7826eea7b368ea23f58 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 15 Sep 2021 10:37:20 -0700 Subject: [PATCH 31/42] Fix NativeVersion.rc path on Windows. --- src/mono/dlls/mscordbi/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/dlls/mscordbi/CMakeLists.txt b/src/mono/dlls/mscordbi/CMakeLists.txt index 7a3bcedbd1541..840937bbfd369 100644 --- a/src/mono/dlls/mscordbi/CMakeLists.txt +++ b/src/mono/dlls/mscordbi/CMakeLists.txt @@ -89,7 +89,7 @@ elseif(HOST_LINUX) set(OS_LIBS pthread m dl) elseif(HOST_WIN32) set(OS_LIBS bcrypt.lib Mswsock.lib ws2_32.lib psapi.lib version.lib advapi32.lib winmm.lib kernel32.lib) -set(mscorbi_sources "${mscorbi_sources};${VERSION_FILE_RC_PATH}NativeVersion.rc") # this is generated by GenerateMonoVersionFile in mono.proj +set(mscorbi_sources "${mscorbi_sources};${VERSION_FILE_RC_PATH}") # this is generated by GenerateMonoVersionFile in mono.proj endif() add_subdirectory(${PROJECT_SOURCE_DIR}/socket-dbi) From 879be008ec808b08c16ece6e2dc476a403478d43 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 15 Sep 2021 10:39:41 -0700 Subject: [PATCH 32/42] Fix linux version parsing to point at the right file. --- src/mono/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 8851de144152a..032f6242ec245 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -752,8 +752,8 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") file(STRINGS "${VERSION_HEADER_PATH}" product_version_string_line REGEX "VER_PRODUCTVERSION_STR ") string(REGEX REPLACE ".*VER_PRODUCTVERSION_STR *(.*)" "\\1" product_version_string ${product_version_string_line}) else() - file(STRINGS "${VERSION_HEADER_PATH}" product_version_string_line REGEX "sccsid") - string(REGEX REPLACE ".*Version *(.*)\";" "\"\\1\"" product_version_string ${product_version_string_line}) + file(STRINGS "${VERSION_FILE_PATH}" product_version_string_line REGEX "sccsid") + string(REGEX REPLACE ".*Version *(.*)\";" "\"\\1\"" product_version_string "${product_version_string_line}") endif() file(STRINGS "${RUNTIME_VERSION_HEADER_PATH}" runtime_version_major_line REGEX "RuntimeProductMajorVersion ") From d871c228690bcb8b1a79a893cbd70bf3b954381f Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 17 Sep 2021 12:02:06 -0700 Subject: [PATCH 33/42] Fix mono version parsing (apparently the quotes make a difference here) --- src/mono/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 032f6242ec245..28712a8ca5900 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -753,7 +753,7 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") string(REGEX REPLACE ".*VER_PRODUCTVERSION_STR *(.*)" "\\1" product_version_string ${product_version_string_line}) else() file(STRINGS "${VERSION_FILE_PATH}" product_version_string_line REGEX "sccsid") - string(REGEX REPLACE ".*Version *(.*)\";" "\"\\1\"" product_version_string "${product_version_string_line}") + string(REGEX REPLACE ".*Version *(.*)\";" "\"\\1\"" product_version_string ${product_version_string_line}) endif() file(STRINGS "${RUNTIME_VERSION_HEADER_PATH}" runtime_version_major_line REGEX "RuntimeProductMajorVersion ") From a9b03d622f4a7400406fbd4acba48a19f1869052 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 Sep 2021 14:49:58 -0700 Subject: [PATCH 34/42] Update src/coreclr/build-runtime.sh Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> --- src/coreclr/build-runtime.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh index 915f94887908a..7adfb63f21743 100755 --- a/src/coreclr/build-runtime.sh +++ b/src/coreclr/build-runtime.sh @@ -208,7 +208,7 @@ fi if [[ "$__SkipNative" == 1 ]]; then echo "Skipping CoreCLR component build." else - copy_version_files + eval "$__RepoRootDir/eng/native/version/copy_version_files.sh" build_native "$__TargetOS" "$__BuildArch" "$__ProjectRoot" "$__IntermediatesDir" "$__CMakeTarget" "$__CMakeArgs" "CoreCLR component" From f9aa7bedf3040e24c3531b29668a3b8efeb62edc Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 21 Sep 2021 08:48:26 -0700 Subject: [PATCH 35/42] Update eng/native/version/copy_version_files.sh Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> --- eng/native/version/copy_version_files.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/eng/native/version/copy_version_files.sh b/eng/native/version/copy_version_files.sh index d2b3aecf8c947..2db96e4745cce 100755 --- a/eng/native/version/copy_version_files.sh +++ b/eng/native/version/copy_version_files.sh @@ -1,5 +1,9 @@ __VersionFolder="$(cd "$(dirname "$0")"; pwd -P)" __RepoRoot="$(cd "$(dirname "$__VersionFolder")/../../"; pwd -P)" -# Use yes n and interactive cp instead of -n since -n is not supported on macOS. -yes n | cp -i "${__VersionFolder}/"*{.h,.c} "$__RepoRoot/artifacts/obj/" +for path in "${__VersionFolder}/"*{.h,.c}; do + # -s checks if file has nonzero size (we don't need any more guarantee than that) + if [ ! -s "$__RepoRoot/artifacts/obj/$(basename "$path")" ]; then + cp "$path" "$__RepoRoot/artifacts/obj/" + fi +done From 83b726a0042866fed6eea01f1d288ae3ac768b1e Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 21 Sep 2021 10:15:45 -0700 Subject: [PATCH 36/42] Update copy_version_files.sh to insert the current commit hash into _version.c. --- eng/native/version/copy_version_files.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/eng/native/version/copy_version_files.sh b/eng/native/version/copy_version_files.sh index 2db96e4745cce..e134f3c1573de 100755 --- a/eng/native/version/copy_version_files.sh +++ b/eng/native/version/copy_version_files.sh @@ -2,8 +2,20 @@ __VersionFolder="$(cd "$(dirname "$0")"; pwd -P)" __RepoRoot="$(cd "$(dirname "$__VersionFolder")/../../"; pwd -P)" for path in "${__VersionFolder}/"*{.h,.c}; do - # -s checks if file has nonzero size (we don't need any more guarantee than that) - if [ ! -s "$__RepoRoot/artifacts/obj/$(basename "$path")" ]; then + if [[ "$(basename $path)" == _version.c ]]; then + # For _version.c, update the commit ID if it has changed from the last build. + # Set IFS to nothing to prevent the shell from combining all of the piped output into a single line in the script below + IFS= + # update commit + commit="$(git rev-parse HEAD 2>/dev/null)" + commit="${commit:-N/A}" + substitute="$(printf 'static char sccsid[] __attribute__((used)) = "@(#)Version N/A @Commit: %s";\n' "$commit")" + version_file_contents=$(cat $path | sed "s|^static.*|$substitute|") + version_file_destination=$__RepoRoot/artifacts/obj/_version.c + if [[ ! -e "$version_file_destination" || "$version_file_contents" != "$(<"$__RepoRoot/artifacts/obj/_version.c")" ]]; then + echo $version_file_contents > "$version_file_destination" + fi + elif [[ ! -e "$__RepoRoot/artifacts/obj/$(basename "$path")" ]]; then cp "$path" "$__RepoRoot/artifacts/obj/" fi done From 74236258fc948299a2162478058533d6c9273367 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 21 Sep 2021 11:52:46 -0700 Subject: [PATCH 37/42] Apply suggestions from code review Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> --- eng/native/version/copy_version_files.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eng/native/version/copy_version_files.sh b/eng/native/version/copy_version_files.sh index e134f3c1573de..265c74f871f61 100755 --- a/eng/native/version/copy_version_files.sh +++ b/eng/native/version/copy_version_files.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + __VersionFolder="$(cd "$(dirname "$0")"; pwd -P)" __RepoRoot="$(cd "$(dirname "$__VersionFolder")/../../"; pwd -P)" @@ -10,10 +12,10 @@ for path in "${__VersionFolder}/"*{.h,.c}; do commit="$(git rev-parse HEAD 2>/dev/null)" commit="${commit:-N/A}" substitute="$(printf 'static char sccsid[] __attribute__((used)) = "@(#)Version N/A @Commit: %s";\n' "$commit")" - version_file_contents=$(cat $path | sed "s|^static.*|$substitute|") - version_file_destination=$__RepoRoot/artifacts/obj/_version.c + version_file_contents="$(cat "$path" | sed "s|^static.*|$substitute|")" + version_file_destination="$__RepoRoot/artifacts/obj/_version.c" if [[ ! -e "$version_file_destination" || "$version_file_contents" != "$(<"$__RepoRoot/artifacts/obj/_version.c")" ]]; then - echo $version_file_contents > "$version_file_destination" + echo "$version_file_contents" > "$version_file_destination" fi elif [[ ! -e "$__RepoRoot/artifacts/obj/$(basename "$path")" ]]; then cp "$path" "$__RepoRoot/artifacts/obj/" From 272fb266314b9f0fb4804327903b085e14df659f Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 22 Sep 2021 14:21:25 -0700 Subject: [PATCH 38/42] Update the _version.c writing script to only update the placeholder version file if it actually is a placeholder (not a real generated file). --- eng/native/version/copy_version_files.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/eng/native/version/copy_version_files.sh b/eng/native/version/copy_version_files.sh index 265c74f871f61..d60ed4715b5ec 100755 --- a/eng/native/version/copy_version_files.sh +++ b/eng/native/version/copy_version_files.sh @@ -14,7 +14,18 @@ for path in "${__VersionFolder}/"*{.h,.c}; do substitute="$(printf 'static char sccsid[] __attribute__((used)) = "@(#)Version N/A @Commit: %s";\n' "$commit")" version_file_contents="$(cat "$path" | sed "s|^static.*|$substitute|")" version_file_destination="$__RepoRoot/artifacts/obj/_version.c" - if [[ ! -e "$version_file_destination" || "$version_file_contents" != "$(<"$__RepoRoot/artifacts/obj/_version.c")" ]]; then + current_contents= + is_placeholder_file= + if [[ -e "$version_file_destination" ]]; then + current_contents="$(<"$__RepoRoot/artifacts/obj/_version.c")" + # If the current file has the version placeholder this script uses, we can update it + # to have the current commit. Otherwise, use the current version file that has the actual product version. + is_placeholder_file="$(echo $current_contents | grep "@(#)Version N/A @Commit:")" + else + # Treat a non-existent file like a file that doesn't exist. + is_placeholder_file=1 + fi + if [[ "$is_placeholder_file" && "$version_file_contents" != "$current_contents" ]]; then echo "$version_file_contents" > "$version_file_destination" fi elif [[ ! -e "$__RepoRoot/artifacts/obj/$(basename "$path")" ]]; then From 21fe213ce749e26bc66f22cf0294e5267ac2a85a Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 23 Sep 2021 15:39:48 -0700 Subject: [PATCH 39/42] Generate the version files for wasm/browser as well. --- src/mono/mono.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index e44356dfb5cbe..7cd0dac3b3bbe 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -730,7 +730,7 @@ CheckEnv;GenerateRuntimeVersionFile;BuildMonoRuntime;BuildMonoCross - ProvisionEmscripten;$(MonoDependsOnTargets) + GenerateRuntimeVersionFile;ProvisionEmscripten;$(MonoDependsOnTargets) From 52aaaf8eb4c2d1a7ff127f82757da2d8dae67254 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 11 Oct 2021 15:31:49 -0700 Subject: [PATCH 40/42] Fix Mono WASM cross build. --- src/mono/mono.proj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 26ef1b1372510..2f98f545da9cc 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -730,9 +730,9 @@ - - $(ArtifactsObjDir)_version.h - $(ArtifactsObjDir)_version.c + + $(ArtifactsObjDir)_version.h + $(ArtifactsObjDir)_version.c .NET Runtime From fdfc57c1814c87b9b81c21bebef6b86b6be919e4 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 19 Oct 2021 15:38:48 -0700 Subject: [PATCH 41/42] Update eng/nativepgo.targets Co-authored-by: Juan Hoyos <19413848+hoyosjs@users.noreply.github.com> --- eng/nativepgo.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/nativepgo.targets b/eng/nativepgo.targets index e73fe13a2dab2..2131c79d74951 100644 --- a/eng/nativepgo.targets +++ b/eng/nativepgo.targets @@ -4,6 +4,7 @@ true false false + false <_NativeOptimizationDataPackageTarget>$(TargetOS.ToLower())-$(TargetArchitecture.ToLower()) <_NativeOptimizationDataPackageTarget Condition="'$(TargetOS)' == 'windows'">windows_nt-$(TargetArchitecture.ToLower()) From 9115b4765b1e2f2e101eb14792b7f4801c1635e5 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 26 Oct 2021 16:40:20 -0700 Subject: [PATCH 42/42] Fix comparison for NativeOptimizationDataSupported. --- eng/nativepgo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/nativepgo.targets b/eng/nativepgo.targets index 2131c79d74951..c9c5f519320f4 100644 --- a/eng/nativepgo.targets +++ b/eng/nativepgo.targets @@ -13,7 +13,7 @@