Skip to content

Commit f8e923a

Browse files
authored
AIESW-24212 Enable reproducible builds for xrt_coreutil.dll (Xilinx#9638)
* AIESW-24212 Enable reproducible builds for xrt_coreutil.dll Remove time stamps from xrt_coreutil binary library. The timestamps means that builds are not deterministic when built from same source. The timestamps must be removed from binaries. Refactor version.h into version-git.h and existing version-slim.h. - version.h remains unchanged and caries the build timestamp - version-git.h contains git meta data such as hash and hash date - version-slim.h requires not must XRT major, minor, build XRT coreutil code no longer reports or uses build date, hence switches to include version-git.h. Since version.h in is no longer included by coreutil code, the baked in build timestamp is absent. Signed-off-by: Soren Soe <2106410+stsoe@users.noreply.github.com> * Fix build error Signed-off-by: Soren Soe <2106410+stsoe@users.noreply.github.com> --------- Signed-off-by: Soren Soe <2106410+stsoe@users.noreply.github.com>
1 parent fc9fb79 commit f8e923a

8 files changed

Lines changed: 47 additions & 31 deletions

File tree

src/CMake/config/version-git.h.in

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved.
3+
#ifndef XRT_VERSION_GIT_H_
4+
#define XRT_VERSION_GIT_H_
5+
6+
#include "xrt/detail/version-slim.h"
7+
8+
static const char xrt_build_version_branch[] = "@XRT_BRANCH@";
9+
10+
static const char xrt_build_version_hash[] = "@XRT_HASH@";
11+
12+
static const char xrt_build_version_hash_date[] = "@XRT_HASH_DATE@";
13+
14+
static const char xrt_modified_files[] = "@XRT_MODIFIED_FILES@";
15+
16+
#define XRT_DRIVER_VERSION "@XRT_VERSION_STRING@,@XRT_HASH@"
17+
#define XRT_PATCH @XRT_VERSION_PATCH@
18+
#define XRT_HEAD_COMMITS @XRT_HEAD_COMMITS@
19+
#define XRT_BRANCH_COMMITS @XRT_BRANCH_COMMITS@
20+
21+
#endif
22+

src/CMake/config/version.h.in

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// Copyright (C) 2019-2021 Xilinx, Inc. All rights reserved.
3-
// Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
3+
// Copyright (C) 2023-2026 Advanced Micro Devices, Inc. All rights reserved.
44
#ifndef XRT_VERSION_H_
55
#define XRT_VERSION_H_
66

77
#include "xrt/detail/version-slim.h"
8-
9-
static const char xrt_build_version_branch[] = "@XRT_BRANCH@";
10-
11-
static const char xrt_build_version_hash[] = "@XRT_HASH@";
12-
13-
static const char xrt_build_version_hash_date[] = "@XRT_HASH_DATE@";
8+
#include "xrt/detail/version-git.h"
149

1510
static const char xrt_build_version_date_rfc[] = "@XRT_DATE_RFC@";
1611

1712
static const char xrt_build_version_date[] = "@XRT_DATE@";
1813

19-
static const char xrt_modified_files[] = "@XRT_MODIFIED_FILES@";
20-
21-
#define XRT_DRIVER_VERSION "@XRT_VERSION_STRING@,@XRT_HASH@"
22-
#define XRT_PATCH @XRT_VERSION_PATCH@
23-
#define XRT_HEAD_COMMITS @XRT_HEAD_COMMITS@
24-
#define XRT_BRANCH_COMMITS @XRT_BRANCH_COMMITS@
25-
2614
#ifdef __cplusplus
2715
#include <iostream>
2816
#include <string>

src/CMake/version.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ configure_file(
101101
${PROJECT_BINARY_DIR}/gen/xrt/detail/version-slim.h
102102
)
103103

104+
configure_file(
105+
${XRT_SOURCE_DIR}/CMake/config/version-git.h.in
106+
${PROJECT_BINARY_DIR}/gen/xrt/detail/version-git.h
107+
)
108+
104109
configure_file(
105110
${XRT_SOURCE_DIR}/CMake/config/version.h.in
106111
${PROJECT_BINARY_DIR}/gen/xrt/detail/version.h
@@ -177,6 +182,7 @@ if (XRT_ALVEO AND (NOT XRT_EDGE) AND (NOT WIN32))
177182
DESTINATION ${XRT_DKMS_INSTALL_DIR}/driver/include
178183
COMPONENT ${XRT_DEV_COMPONENT})
179184
install(FILES
185+
${PROJECT_BINARY_DIR}/gen/xrt/detail/version-git.h
180186
${PROJECT_BINARY_DIR}/gen/xrt/detail/version-slim.h
181187
DESTINATION ${XRT_DKMS_INSTALL_DIR}/driver/include/xrt/detail
182188
COMPONENT ${XRT_DEV_COMPONENT})

src/runtime_src/core/common/api/xrt_version.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#define XRT_API_SOURCE // exporting xrt_version.h
77
#define XRT_CORE_COMMON_SOURCE // in same dll as core_common
88
#include "core/include/xrt/experimental/xrt_version.h"
9-
#include "xrt/detail/version.h"
9+
#include "xrt/detail/version-git.h"
1010

1111
#ifdef major
1212
# undef major

src/runtime_src/core/common/message.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "config_reader.h"
88
#include "utils.h"
99

10-
#include "xrt/detail/version.h"
10+
#include "xrt/detail/version-git.h"
1111

1212
#include <map>
1313
#include <fstream>
@@ -179,7 +179,7 @@ file_dispatch(const std::string &file)
179179
handle.open(file.c_str());
180180
handle << "XRT build version: " << xrt_build_version << "\n";
181181
handle << "Build hash: " << xrt_build_version_hash << "\n";
182-
handle << "Build date: " << xrt_build_version_date << "\n";
182+
handle << "Build hash date: " << xrt_build_version_hash_date << "\n";
183183
handle << "Git branch: " << xrt_build_version_branch<< "\n";
184184
handle << "[" << xrt_core::timestamp() << "]" << "\n";
185185
handle << "PID: " << xrt_core::utils::get_pid() << "\n";
@@ -209,7 +209,7 @@ console_dispatch()
209209
{
210210
std::cerr << "XRT build version: " << xrt_build_version << "\n";
211211
std::cerr << "Build hash: " << xrt_build_version_hash << "\n";
212-
std::cerr << "Build date: " << xrt_build_version_date << "\n";
212+
std::cerr << "Build hash date: " << xrt_build_version_hash_date << "\n";
213213
std::cerr << "Git branch: " << xrt_build_version_branch<< "\n";
214214
std::cerr << "PID: " << xrt_core::utils::get_pid() << "\n";
215215
std::cerr << "UID: " << get_userid() << "\n";

src/runtime_src/core/common/sysinfo.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55
#include "detail/sysinfo.h"
66
#include "system.h"
77

8-
#include "xrt/detail/version.h"
8+
#include "xrt/detail/version-git.h"
99

1010
namespace xrt_core::sysinfo {
1111

1212
void
1313
get_xrt_info(boost::property_tree::ptree& pt)
1414
{
15-
pt.put("version", xrt_build_version);
16-
pt.put("branch", xrt_build_version_branch);
17-
pt.put("hash", xrt_build_version_hash);
18-
pt.put("build_date", xrt_build_version_date);
15+
pt.put("version", xrt_build_version);
16+
pt.put("branch", xrt_build_version_branch);
17+
pt.put("hash", xrt_build_version_hash);
18+
pt.put("build_hash_date", xrt_build_version_hash_date);
1919
xrt_core::get_driver_info(pt);
2020
}
2121

2222
void
2323
get_xrt_build_info(boost::property_tree::ptree& pt)
2424
{
25-
pt.put("version", xrt_build_version);
26-
pt.put("branch", xrt_build_version_branch);
27-
pt.put("hash", xrt_build_version_hash);
28-
pt.put("build_date", xrt_build_version_date);
25+
pt.put("version", xrt_build_version);
26+
pt.put("branch", xrt_build_version_branch);
27+
pt.put("hash", xrt_build_version_hash);
28+
pt.put("build_hash_date", xrt_build_version_hash_date);
2929
}
3030

3131
void

src/runtime_src/core/tools/common/XBUtilities.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,13 +814,13 @@ fill_xrt_versions(const boost::property_tree::ptree& pt_xrt,
814814

815815
auto branch = pt_xrt.get<std::string>("branch", "N/A");
816816
auto hash = pt_xrt.get<std::string>("hash", "N/A");
817-
auto build_date = pt_xrt.get<std::string>("build_date", "N/A");
817+
auto build_hash_date = pt_xrt.get<std::string>("build_hash_date", "N/A");
818818
if (!branch.empty() && !boost::iequals(branch, "N/A"))
819819
output << boost::format(" %-20s : %s\n") % "Branch" % branch;
820820
if (!hash.empty() && !boost::iequals(hash, "N/A"))
821821
output << boost::format(" %-20s : %s\n") % "Hash" % hash;
822-
if (!build_date.empty() && !boost::iequals(build_date, "N/A"))
823-
output << boost::format(" %-20s : %s\n") % "Hash Date" % build_date;
822+
if (!build_hash_date.empty() && !boost::iequals(build_hash_date, "N/A"))
823+
output << boost::format(" %-20s : %s\n") % "Hash Date" % build_hash_date;
824824

825825
const boost::property_tree::ptree& available_drivers = pt_xrt.get_child("drivers", empty_ptree);
826826
for(auto& drv : available_drivers) {

src/runtime_src/core/tools/xbtracer/src/wrapper/tracer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <memory>
1313
#include <mutex>
1414

15-
#include "xrt/detail/version.h"
15+
#include "xrt/detail/version-git.h"
1616
#include "wrapper/tracer.h"
1717
#ifdef _WIN32
1818
#include "core/common/windows/win_utils.h"

0 commit comments

Comments
 (0)