From 4fdc1c11ea7f3d56658215f290436270e7a730c2 Mon Sep 17 00:00:00 2001 From: Karim Shamazov Date: Tue, 5 May 2026 16:36:55 +0300 Subject: [PATCH 1/3] update k2-header.h --- runtime-light/k2-platform/k2-header.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/runtime-light/k2-platform/k2-header.h b/runtime-light/k2-platform/k2-header.h index 202dfbedc2..25b8789f7f 100644 --- a/runtime-light/k2-platform/k2-header.h +++ b/runtime-light/k2-platform/k2-header.h @@ -27,7 +27,7 @@ #include #endif -#define K2_PLATFORM_HEADER_H_VERSION 13 +#define K2_PLATFORM_HEADER_H_VERSION 14 // Always check that enum value is a valid value! @@ -98,17 +98,24 @@ enum UpdateStatus { }; struct ImageInfo { - // TODO: null terminated string is OK? - // TODO: namespaces? + // Base const char* image_name; + uint8_t is_oneshot; + // DSO specific uint64_t build_timestamp; uint64_t header_h_version; uint8_t commit_hash[40]; - // TODO: more informative? - uint8_t compiler_hash[64]; - // bool - uint8_t is_oneshot; + const char* version; + + // Extra + struct KeyValuePair { + const char* key; + const char* value; + }; + + size_t extra_info_size; + const struct KeyValuePair* extra_info; }; /** From 25a7f59218236e555627b555e10d9a58f20e3af2 Mon Sep 17 00:00:00 2001 From: Karim Shamazov Date: Tue, 5 May 2026 21:13:13 +0300 Subject: [PATCH 2/3] update ComponentInfoFile::compile --- compiler/code-gen/files/init-scripts.cpp | 24 ++++++++++++++++++++---- compiler/compiler-settings.cpp | 5 +++-- compiler/compiler-settings.h | 3 +++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/compiler/code-gen/files/init-scripts.cpp b/compiler/code-gen/files/init-scripts.cpp index 43117c7ec5..2e084abcf4 100644 --- a/compiler/code-gen/files/init-scripts.cpp +++ b/compiler/code-gen/files/init-scripts.cpp @@ -4,6 +4,13 @@ #include "compiler/code-gen/files/init-scripts.h" +#include +#include + +#include + +#include "common/wrappers/fmt_format.h" + #include "compiler/code-gen/common.h" #include "compiler/code-gen/const-globals-batched-mem.h" #include "compiler/code-gen/declarations.h" @@ -293,15 +300,24 @@ void CppMainFile::compile(CodeGenerator &W) const { } void ComponentInfoFile::compile(CodeGenerator &W) const { + auto build_time{std::chrono::system_clock::to_time_t(G->settings().build_tp)}; + auto date_str{fmt_format("{:%b %e %Y %T %Z}", fmt::localtime(build_time))}; + kphp_assert(G->is_output_mode_k2()); - G->settings().get_version(); W << OpenFile("image_info.cpp"); W << ExternInclude(G->settings().runtime_headers.get()); W << "__attribute__((visibility(\"default\"))) const ImageInfo *k2_describe() " << BEGIN << "static ImageInfo imageInfo {\"" - << G->settings().k2_component_name.get() << "\"" << "," << G->settings().build_timestamp.get() << "," + << G->settings().k2_component_name.get() << "\"" << "," + << (G->is_output_mode_k2_multishot() ? "0" : "1") << "," + << std::to_string( + std::chrono::duration_cast(G->settings().build_tp.time_since_epoch()).count() + ) << "," << "K2_PLATFORM_HEADER_H_VERSION, " << "{}," // todo:k2 add commit hash - << "{}," // todo:k2 add compiler hash? - << (G->is_output_mode_k2_multishot() ? "0" : "1") << "};" << NL << "return &imageInfo;" << NL << END; + << "\"" << G->settings().k2_component_name.get() << " compiled at " << date_str << " by " // todo:k2 add commit hash of target into version + << G->settings().get_version() << "\"," + << "0" << "," + << "nullptr" + << "};" << NL << "return &imageInfo;" << NL << END; W << CloseFile(); } diff --git a/compiler/compiler-settings.cpp b/compiler/compiler-settings.cpp index 4376284a13..d096a120ac 100644 --- a/compiler/compiler-settings.cpp +++ b/compiler/compiler-settings.cpp @@ -222,8 +222,9 @@ void CompilerSettings::init() { option_as_dir(kphp_src_path); functions_file.value_ = get_full_path(functions_file.get()); runtime_sha256_file.value_ = get_full_path(runtime_sha256_file.get()); - const auto now{std::chrono::system_clock::now()}; - build_timestamp.value_ = std::to_string(std::chrono::duration_cast(now.time_since_epoch()).count()); + build_timestamp.value_ = std::to_string( + std::chrono::duration_cast(build_tp.time_since_epoch()).count() + ); bool is_k2_mode = mode.get().substr(0, 3) == "k2-"; if (link_file.value_.empty()) { diff --git a/compiler/compiler-settings.h b/compiler/compiler-settings.h index 0d62a1cdc4..cd1615c72d 100644 --- a/compiler/compiler-settings.h +++ b/compiler/compiler-settings.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include #include @@ -196,6 +197,8 @@ class CompilerSettings : vk::not_copyable { KphpImplicitOption tl_namespace_prefix; KphpImplicitOption tl_classname_prefix; + std::chrono::system_clock::time_point build_tp{std::chrono::system_clock::now()}; + std::string get_version() const; bool is_composer_enabled() const; // reports whether composer compatibility mode is on color_settings get_color_settings() const; From b15e5c10b62dc0c77dfec14139bfcca4b689689f Mon Sep 17 00:00:00 2001 From: Karim Shamazov Date: Wed, 6 May 2026 12:25:25 +0300 Subject: [PATCH 3/3] mb fix --- compiler/code-gen/files/init-scripts.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/code-gen/files/init-scripts.cpp b/compiler/code-gen/files/init-scripts.cpp index 2e084abcf4..fa23886310 100644 --- a/compiler/code-gen/files/init-scripts.cpp +++ b/compiler/code-gen/files/init-scripts.cpp @@ -9,8 +9,6 @@ #include -#include "common/wrappers/fmt_format.h" - #include "compiler/code-gen/common.h" #include "compiler/code-gen/const-globals-batched-mem.h" #include "compiler/code-gen/declarations.h" @@ -301,7 +299,7 @@ void CppMainFile::compile(CodeGenerator &W) const { void ComponentInfoFile::compile(CodeGenerator &W) const { auto build_time{std::chrono::system_clock::to_time_t(G->settings().build_tp)}; - auto date_str{fmt_format("{:%b %e %Y %T %Z}", fmt::localtime(build_time))}; + auto date_str{fmt::format("{:%b %e %Y %T %Z}", fmt::localtime(build_time))}; kphp_assert(G->is_output_mode_k2()); W << OpenFile("image_info.cpp");