Skip to content

Commit

Permalink
Fix bazel build
Browse files Browse the repository at this point in the history
  • Loading branch information
kavyasree committed Dec 27, 2024
1 parent 4141b76 commit 0a897ff
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
102 changes: 102 additions & 0 deletions SPECS/tensorflow/Fix-bazel-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
From 70a3386b744d3c3289c5c726efa2cd19b0736880 Mon Sep 17 00:00:00 2001
From: kavyasree <[email protected]>
Date: Fri, 27 Dec 2024 11:04:33 +0530
Subject: [PATCH] Fix-bazel-build

---
file_windows.cc | 53 ++++++++++++++++---
1 file changed, 45 insertions(+), 8 deletions(-)

diff --git a/file_windows.cc b/file_windows.cc
index 5798ffacf..9c45e9260 100755
--- a/file_windows.cc
+++ b/file_windows.cc
@@ -118,16 +118,56 @@ class WindowsFileMtime : public IFileMtime {
bool SetToDistantFuture(const Path& path) override;

private:
+ // 1 year in FILETIME.
+ static const ULARGE_INTEGER kOneYear;
// 9 years in the future.
const FILETIME near_future_;
// 10 years in the future.
const FILETIME distant_future_;

- static FILETIME GetNow();
- static FILETIME GetFuture(WORD years);
+ static ULARGE_INTEGER&& OneYearDelay();
+ static const FILETIME GetNow();
+ static const FILETIME GetFuture(WORD years);
static bool Set(const Path& path, FILETIME time);
};

+const ULARGE_INTEGER WindowsFileMtime::kOneYear =
+ std::move(WindowsFileMtime::OneYearDelay());
+ULARGE_INTEGER&& WindowsFileMtime::OneYearDelay() {
+ SYSTEMTIME now;
+ GetSystemTime(&now);
+ now.wMonth = 1;
+ now.wDayOfWeek = 0;
+ now.wDay = 1;
+ now.wHour = 0;
+ now.wMinute = 0;
+ now.wSecond = 0;
+ now.wMilliseconds = 0;
+ FILETIME now_ft;
+ if (!::SystemTimeToFileTime(&now, &now_ft)) {
+ string err = GetLastErrorString();
+ BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)
+ << "WindowsFileMtime::OneYearDelay: SystemTimeToFileTime 1 failed: "
+ << err;
+ }
+ ULARGE_INTEGER t1;
+ t1.LowPart = now_ft.dwLowDateTime;
+ t1.HighPart = now_ft.dwHighDateTime;
+ now.wYear++;
+ if (!::SystemTimeToFileTime(&now, &now_ft)) {
+ string err = GetLastErrorString();
+ BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)
+ << "WindowsFileMtime::OneYearDelay: SystemTimeToFileTime 2 failed: "
+ << err;
+ }
+ ULARGE_INTEGER t2;
+ t2.LowPart = now_ft.dwLowDateTime;
+ t2.HighPart = now_ft.dwHighDateTime;
+ t2.QuadPart -= t1.QuadPart;
+ return std::move(t2);
+}
+
+
bool WindowsFileMtime::IsUntampered(const Path& path) {
if (path.IsEmpty() || path.IsNull()) {
return false;
@@ -205,23 +245,20 @@ bool WindowsFileMtime::Set(const Path& path, FILETIME time) {
/* lpLastWriteTime */ &time) == TRUE;
}

-FILETIME WindowsFileMtime::GetNow() {
+const FILETIME WindowsFileMtime::GetNow() {
FILETIME now;
GetSystemTimeAsFileTime(&now);
return now;
}

-FILETIME WindowsFileMtime::GetFuture(WORD years) {
+const FILETIME WindowsFileMtime::GetFuture(WORD years) {
FILETIME result;
GetSystemTimeAsFileTime(&result);

- // 1 year in FILETIME.
- constexpr ULONGLONG kOneYear = 365ULL * 24 * 60 * 60 * 10'000'000;
-
ULARGE_INTEGER result_value;
result_value.LowPart = result.dwLowDateTime;
result_value.HighPart = result.dwHighDateTime;
- result_value.QuadPart += kOneYear * years;
+ result_value.QuadPart += kOneYear.QuadPart * years;
result.dwLowDateTime = result_value.LowPart;
result.dwHighDateTime = result_value.HighPart;
return result;
--
2.34.1

5 changes: 5 additions & 0 deletions SPECS/tensorflow/tensorflow.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Patch0: CVE-2023-33976.patch

# Patch for Source1
Patch1000: CVE-2024-7264.patch
Patch1001: Fix-bazel-build.patch
BuildRequires: bazel
BuildRequires: binutils
BuildRequires: build-essential
Expand Down Expand Up @@ -121,6 +122,10 @@ pushd /root/.cache/bazel/_bazel_$USER/$MD5_HASH/external/curl/lib/vtls/
patch -p1 < %{PATCH1000}
popd

pushd /root/.cache/bazel/_bazel_$USER/install/c04b9c960391bacd94430ffe20db8729/embedded_tools/src/main/cpp/util/
patch -p1 < %{PATCH1001}
popd

ln -s %{_bindir}/python3 %{_bindir}/python
# Remove the .bazelversion file so that latest bazel version available will be used to build TensorFlow.
rm .bazelversion
Expand Down

0 comments on commit 0a897ff

Please sign in to comment.