From 51e085f45e1dfddcf2b521da749d7f22c4c2a3fc Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 27 Jul 2026 14:23:41 -0700 Subject: [PATCH] Define REPO_COMMIT_HASH correctly for singlefilehost The single-file host statically links the hosting components, which use REPO_COMMIT_HASH (e.g. in 'dotnet --info', hostfxr_get_dotnet_environment_info, and tracing). It is built as part of coreclr, which never passed the commit hash, so configure.h.in hardcoded "static" whenever CLR_SINGLE_FILE_HOST_ONLY was set. Plumb the commit hash into the coreclr native build via SourceRevisionId the same way corehost.proj does for the rest of the host, and always define REPO_COMMIT_HASH from CLI_CMAKE_COMMIT_HASH so singlefilehost reports the real commit (or N/A when source control queries are disabled). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 759b9702-1ed5-4618-a21a-a4d7d9a4d7d5 --- src/coreclr/runtime.proj | 2 ++ src/native/corehost/configure.h.in | 9 --------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj index 24da48c265efdc..b20e9a35fc87ab 100644 --- a/src/coreclr/runtime.proj +++ b/src/coreclr/runtime.proj @@ -5,6 +5,7 @@ <_BuildNativeTargetOS Condition="'$(TargetsLinuxBionic)' == 'true'">linux-bionic true GetPgoDataPackagePath + $(BuildRuntimeDependsOnTargets);InitializeSourceControlInformationFromSourceControlManager AcquireEmscriptenSdk;$(BuildRuntimeDependsOnTargets);GenerateEmccExports AcquireWasiSdk;$(BuildRuntimeDependsOnTargets) @@ -57,6 +58,7 @@ <_CoreClrBuildArg Condition="'$(FeatureXplatEventSource)' == 'false'" Include="-cmakeargs "-DFEATURE_EVENTSOURCE_XPLAT=0"" /> <_CoreClrBuildArg Condition="'$(FeatureInterpreter)' == 'true'" Include="-cmakeargs "-DFEATURE_INTERPRETER=1"" /> <_CoreClrBuildArg Condition="'$(FeatureDynamicCodeCompiled)' == 'true' or '$(FeatureDynamicCodeCompiled)' == ''" Include="-cmakeargs "-DFEATURE_DYNAMIC_CODE_COMPILED=1"" /> + <_CoreClrBuildArg Include="-cmakeargs "-DCLI_CMAKE_COMMIT_HASH=$([MSBuild]::ValueOrDefault('$(SourceRevisionId)', 'N/A'))"" /> diff --git a/src/native/corehost/configure.h.in b/src/native/corehost/configure.h.in index dcd894a1297715..fc87f2113e5b19 100644 --- a/src/native/corehost/configure.h.in +++ b/src/native/corehost/configure.h.in @@ -1,16 +1,7 @@ #ifndef PAL_HOST_CONFIGURE_H_INCLUDED #define PAL_HOST_CONFIGURE_H_INCLUDED -#cmakedefine CLR_SINGLE_FILE_HOST_ONLY - -#ifdef CLR_SINGLE_FILE_HOST_ONLY -// When hosting components are all statically linked, -// the versioning information is irrelevant and may only come up in tracing. -// so we will use "static" -#define REPO_COMMIT_HASH "static" -#else #define REPO_COMMIT_HASH "@CLI_CMAKE_COMMIT_HASH@" -#endif #define FALLBACK_HOST_OS "@CLI_CMAKE_FALLBACK_OS@" #define CURRENT_OS_NAME "@CLR_CMAKE_TARGET_OS@"