Skip to content

Commit

Permalink
Fix riegeli for Protobuf 5
Browse files Browse the repository at this point in the history
  • Loading branch information
xhochy committed Oct 11, 2024
1 parent 1222b8d commit c78ba99
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 25 deletions.
17 changes: 13 additions & 4 deletions recipe/patches/0018-add-absl_string_view-target.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
From de7577313810f2e4f91f5f1e8bdbc7c5d947b6ef Mon Sep 17 00:00:00 2001
From 3d79a13204bb6fa626dc1cb82e03506280a53590 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <[email protected]>
Date: Sun, 12 May 2024 18:45:03 +1100
Subject: [PATCH 18/27] add absl_string_view target

---
third_party/absl/system.absl.strings.BUILD | 12 ++++++++++++
1 file changed, 12 insertions(+)
third_party/absl/system.absl.strings.BUILD | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/third_party/absl/system.absl.strings.BUILD b/third_party/absl/system.absl.strings.BUILD
index d04776c9..573d6c2f 100644
index d04776c9..9f537def 100644
--- a/third_party/absl/system.absl.strings.BUILD
+++ b/third_party/absl/system.absl.strings.BUILD
@@ -2,6 +2,18 @@ load("@rules_cc//cc:defs.bzl", "cc_library")
Expand All @@ -30,3 +30,12 @@ index d04776c9..573d6c2f 100644
cc_library(
name = "strings",
linkopts = ["-labsl_strings"],
@@ -26,7 +38,7 @@ cc_library(

cc_library(
name = "cord",
- linkopts = ["-labsl_cord", "-labsl_cordz_functions", "-labsl_cordz_info"],
+ linkopts = ["-labsl_cord", "-labsl_cordz_functions", "-labsl_cordz_info", "-labsl_cord_internal"],
deps = [
":str_format",
"//absl/container:compressed_tuple",
2 changes: 1 addition & 1 deletion recipe/patches/0019-add-absl_nullability-target.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 1ba1e57b78c37b0cd3353dceaa4633f4d98779a1 Mon Sep 17 00:00:00 2001
From c1ab28a6ca9909f0310cac9008569a5df03ef4a1 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <[email protected]>
Date: Sun, 12 May 2024 19:30:44 +1100
Subject: [PATCH 19/27] add absl_nullability target
Expand Down
2 changes: 1 addition & 1 deletion recipe/patches/0020-add-absl_prefetch-target.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From de106a1019f8d47896738692a9f526489783775f Mon Sep 17 00:00:00 2001
From 16b223f630d00a46d1c90ad129924afb6f7143e4 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <[email protected]>
Date: Sun, 12 May 2024 22:29:25 +1100
Subject: [PATCH 20/27] add absl_prefetch target
Expand Down
2 changes: 1 addition & 1 deletion recipe/patches/0021-add-absl_die_if_null-target.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 01f2b9b583f3627d3dde023e613bf1e96f2bc348 Mon Sep 17 00:00:00 2001
From cf4e36f47e874278b60c2fdab575bfb33fe803ac Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <[email protected]>
Date: Sun, 12 May 2024 22:46:04 +1100
Subject: [PATCH 21/27] add absl_die_if_null target
Expand Down
2 changes: 1 addition & 1 deletion recipe/patches/0022-add-absl_crc32c-targets.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 19016020cd8fbe94920856f5f6ffc3f515a05f39 Mon Sep 17 00:00:00 2001
From 3d268a099e1a3f62922c913f049f503fb77ad613 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <[email protected]>
Date: Mon, 13 May 2024 09:41:09 +1100
Subject: [PATCH 22/27] add absl_crc32c targets
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From fee7bf5d49a6c767aec631980b749e9e76bd9828 Mon Sep 17 00:00:00 2001
From 63e72374d50094425d0675059c2b11e3c95d3135 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <[email protected]>
Date: Mon, 13 May 2024 23:36:48 +1100
Subject: [PATCH 23/27] add kernel_timeout_internal target
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 834f80850258a7c03d83e5d6304acef4f6c950a6 Mon Sep 17 00:00:00 2001
From a89bade09f737a1cd5f7e2ee7ec26b38dfb771dd Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <[email protected]>
Date: Sun, 19 May 2024 20:52:35 +1100
Subject: [PATCH 24/27] work around for warning that clang falsely treats as
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 8f47db96664195da6c7b86d9d19365e41ebda763 Mon Sep 17 00:00:00 2001
From ed916a2d3c5399dbf6c71b1f6f7f07b8b1ddb8fc Mon Sep 17 00:00:00 2001
From: "Uwe L. Korn" <[email protected]>
Date: Fri, 12 Jul 2024 12:52:38 +0000
Subject: [PATCH 25/27] Hardcode BUILD_PREFIX in build_pip_package
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 1aa996a04bafcb8b1413c2aa4cdefae82d94bf29 Mon Sep 17 00:00:00 2001
From c3205a7e020e1e9ee30581b2b869ed83746136b7 Mon Sep 17 00:00:00 2001
From: "Uwe L. Korn" <[email protected]>
Date: Tue, 16 Jul 2024 17:18:23 +0200
Subject: [PATCH 26/27] Only link to sparse_core_layout_proto_cc headers
Expand Down
143 changes: 130 additions & 13 deletions recipe/patches/0027-Protobuf-5-compatability.patch
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
From e283895ada7da065acdc494d1ae7a4f78f1b3191 Mon Sep 17 00:00:00 2001
From d98ec2c4eb0a0b58f0003d3b9d7ba7aeb413fe78 Mon Sep 17 00:00:00 2001
From: "Uwe L. Korn" <[email protected]>
Date: Thu, 10 Oct 2024 19:59:31 +0200
Subject: [PATCH 27/27] Protobuf 5 compatability

---
.../compiler/mlir/lite/python/jax_to_tfl_flatbuffer.cc | 2 +-
.../compiler/mlir/tensorflow/utils/parse_text_proto.cc | 2 +-
tensorflow/core/debug/debug_io_utils.cc | 4 ++++
tensorflow/core/ir/importexport/parse_text_proto.cc | 2 +-
tensorflow/core/profiler/convert/hlo_to_tools_data.cc | 4 ++++
.../core/profiler/convert/xplane_to_memory_profile.cc | 4 ++++
.../core/profiler/convert/xplane_to_tools_data.cc | 8 ++++++++
tensorflow/core/util/proto/proto_utils.cc | 10 +++++-----
tensorflow/core/util/proto/proto_utils.h | 4 ++--
.../tools/proto_text/gen_proto_text_functions.cc | 4 ++--
.../tsl/tsl/platform/default/human_readable_json.cc | 4 ++++
11 files changed, 36 insertions(+), 12 deletions(-)
.../mlir/lite/python/jax_to_tfl_flatbuffer.cc | 2 +-
.../mlir/tensorflow/utils/parse_text_proto.cc | 2 +-
tensorflow/core/debug/debug_io_utils.cc | 4 ++
.../core/ir/importexport/parse_text_proto.cc | 2 +-
.../profiler/convert/hlo_to_tools_data.cc | 4 ++
.../convert/xplane_to_memory_profile.cc | 4 ++
.../profiler/convert/xplane_to_tools_data.cc | 8 +++
tensorflow/core/util/proto/proto_utils.cc | 10 ++--
tensorflow/core/util/proto/proto_utils.h | 4 +-
.../proto_text/gen_proto_text_functions.cc | 4 +-
tensorflow/workspace2.bzl | 4 ++
...Migrate-from-AddError-to-RecordError.patch | 33 ++++++++++++
...y-with-protobuf-v26-migrate-from-dep.patch | 52 +++++++++++++++++++
.../platform/default/human_readable_json.cc | 4 ++
14 files changed, 125 insertions(+), 12 deletions(-)
create mode 100644 third_party/0001-Migrate-from-AddError-to-RecordError.patch
create mode 100644 third_party/0002-Fix-compatibility-with-protobuf-v26-migrate-from-dep.patch

diff --git a/tensorflow/compiler/mlir/lite/python/jax_to_tfl_flatbuffer.cc b/tensorflow/compiler/mlir/lite/python/jax_to_tfl_flatbuffer.cc
index ed968b54..71e16db6 100644
Expand Down Expand Up @@ -191,6 +196,118 @@ index 406e6641..d97eae73 100644
LOG(FATAL) << "Unexpected error at " << filename << "@" << line << ":"
<< column << " - " << message;
}
diff --git a/tensorflow/workspace2.bzl b/tensorflow/workspace2.bzl
index dc78011d..a4faad8f 100644
--- a/tensorflow/workspace2.bzl
+++ b/tensorflow/workspace2.bzl
@@ -870,6 +870,10 @@ def _tf_repositories():
name = "riegeli",
sha256 = "1d216d5c97fa60632143d209a1bb48c2a83788efdb876902e7bbc06396d5ee1f",
strip_prefix = "riegeli-5d75119232cd4f6db8dfa69a1503289f050e9643",
+ patch_file = [
+ "//third_party:0001-Migrate-from-AddError-to-RecordError.patch",
+ "//third_party:0002-Fix-compatibility-with-protobuf-v26-migrate-from-dep.patch",
+ ],
urls = tf_mirror_urls("https://github.com/google/riegeli/archive/5d75119232cd4f6db8dfa69a1503289f050e9643.zip"),
)

diff --git a/third_party/0001-Migrate-from-AddError-to-RecordError.patch b/third_party/0001-Migrate-from-AddError-to-RecordError.patch
new file mode 100644
index 00000000..0ed75ee8
--- /dev/null
+++ b/third_party/0001-Migrate-from-AddError-to-RecordError.patch
@@ -0,0 +1,33 @@
+From e75b32516c67dbcb0cd1a698d6700c3d7bd85a35 Mon Sep 17 00:00:00 2001
+From: Compression Team <[email protected]>
+Date: Fri, 31 May 2024 18:20:47 +0200
+Subject: [PATCH 1/2] Migrate from AddError() to RecordError()
+
+In Protobuf v22 RecordError() has been introduced and AddError() deprecated.
+In Protobuf v26 AddError() has been removed.
+
+PiperOrigin-RevId: 639057502
+---
+ riegeli/records/record_reader.cc | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/riegeli/records/record_reader.cc b/riegeli/records/record_reader.cc
+index 499432ab..f4d90cea 100644
+--- a/riegeli/records/record_reader.cc
++++ b/riegeli/records/record_reader.cc
+@@ -62,9 +62,9 @@ namespace riegeli {
+ class RecordsMetadataDescriptors::ErrorCollector
+ : public google::protobuf::DescriptorPool::ErrorCollector {
+ public:
+- void AddError(const std::string& filename, const std::string& element_name,
+- const google::protobuf::Message* descriptor,
+- ErrorLocation location, const std::string& message) override {
++ void RecordError(absl::string_view filename, absl::string_view element_name,
++ const google::protobuf::Message* descriptor,
++ ErrorLocation location, absl::string_view message) override {
+ descriptors_->Fail(absl::InvalidArgumentError(
+ absl::StrCat("Error in file ", filename, ", element ", element_name,
+ ": ", message)));
+--
+2.34.1
+
diff --git a/third_party/0002-Fix-compatibility-with-protobuf-v26-migrate-from-dep.patch b/third_party/0002-Fix-compatibility-with-protobuf-v26-migrate-from-dep.patch
new file mode 100644
index 00000000..b5af8d2d
--- /dev/null
+++ b/third_party/0002-Fix-compatibility-with-protobuf-v26-migrate-from-dep.patch
@@ -0,0 +1,52 @@
+From 96dccef7210d7e182446b2db7424b16f44a66dd0 Mon Sep 17 00:00:00 2001
+From: Marcin Kowalczyk <[email protected]>
+Date: Tue, 4 Jun 2024 16:50:59 +0200
+Subject: [PATCH 2/2] =?UTF-8?q?Fix=20compatibility=20with=20protobuf=20v26?=
+ =?UTF-8?q?+:=20migrate=20from=20deprecated=20`AddError()`=20to=20`RecordE?=
+ =?UTF-8?q?rror()`=20also=20in=20text=20parser=E2=80=99s=20`ErrorCollector?=
+ =?UTF-8?q?`.?=
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+PiperOrigin-RevId: 640152285
+---
+ riegeli/messages/text_parse.cc | 6 +++---
+ riegeli/messages/text_parse.h | 4 ++--
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/riegeli/messages/text_parse.cc b/riegeli/messages/text_parse.cc
+index 94a28180..5089c728 100644
+--- a/riegeli/messages/text_parse.cc
++++ b/riegeli/messages/text_parse.cc
+@@ -35,9 +35,9 @@ namespace riegeli {
+
+ namespace messages_internal {
+
+-void StringErrorCollector::AddError(int line,
+- google::protobuf::io::ColumnNumber column,
+- const std::string& message) {
++void StringErrorCollector::RecordError(
++ int line, google::protobuf::io::ColumnNumber column,
++ absl::string_view message) {
+ if (line >= 0) {
+ absl::StrAppend(&errors_, "\nAt ", line + 1, ":", column + 1, ": ",
+ message);
+diff --git a/riegeli/messages/text_parse.h b/riegeli/messages/text_parse.h
+index e6bb4db2..ee234ec8 100644
+--- a/riegeli/messages/text_parse.h
++++ b/riegeli/messages/text_parse.h
+@@ -39,8 +39,8 @@ namespace messages_internal {
+
+ class StringErrorCollector : public google::protobuf::io::ErrorCollector {
+ public:
+- void AddError(int line, google::protobuf::io::ColumnNumber column,
+- const std::string& message) override;
++ void RecordError(int line, google::protobuf::io::ColumnNumber column,
++ absl::string_view message) override;
+
+ absl::string_view errors() const { return errors_; }
+
+--
+2.34.1
+
diff --git a/third_party/xla/third_party/tsl/tsl/platform/default/human_readable_json.cc b/third_party/xla/third_party/tsl/tsl/platform/default/human_readable_json.cc
index 4f70c155..ae746f33 100644
--- a/third_party/xla/third_party/tsl/tsl/platform/default/human_readable_json.cc
Expand Down

0 comments on commit c78ba99

Please sign in to comment.