From 81c0ec381a34891c4e25dade6d3ad06448313546 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Thu, 6 Jun 2024 14:38:43 -0700 Subject: [PATCH] Avoid calling absl::InitializeLog in protoc with MSVC The recent github runner image update changes the MSVC version, and InitializeLog now crashes in optimized builds. Until Abseil works with MSVC, we can just log to stderr in protoc. PiperOrigin-RevId: 641024759 --- protos/protos_extension_lock_test.cc | 4 ++++ src/google/protobuf/compiler/main.cc | 3 +++ src/google/protobuf/compiler/main_no_generators.cc | 3 +++ 3 files changed, 10 insertions(+) diff --git a/protos/protos_extension_lock_test.cc b/protos/protos_extension_lock_test.cc index 9c2444b606..cc02bc57d5 100644 --- a/protos/protos_extension_lock_test.cc +++ b/protos/protos_extension_lock_test.cc @@ -102,6 +102,8 @@ void TestConcurrentExtensionAccess(::protos::ExtensionRegistry registry) { test_theme(); test_theme_extension(); } +#ifndef _MSC_VER +// TODO Re-enable this once github runner issue is resolved. TEST(CppGeneratedCode, ConcurrentAccessDoesNotRaceBothLazy) { ::upb::Arena arena; @@ -120,5 +122,7 @@ TEST(CppGeneratedCode, ConcurrentAccessDoesNotRaceBothEager) { {{&theme, &ThemeExtension::theme_extension}, arena}); } +#endif // _MSC_VER + } // namespace } // namespace protos_generator::test::protos diff --git a/src/google/protobuf/compiler/main.cc b/src/google/protobuf/compiler/main.cc index a5c7537f4d..7b2f5dca4b 100644 --- a/src/google/protobuf/compiler/main.cc +++ b/src/google/protobuf/compiler/main.cc @@ -35,7 +35,10 @@ namespace protobuf { namespace compiler { int ProtobufMain(int argc, char* argv[]) { +#ifndef _MSC_VER + // TODO Re-enable this once github runner issue is resolved. absl::InitializeLog(); +#endif // !_MSC_VER CommandLineInterface cli; cli.AllowPlugins("protoc-"); diff --git a/src/google/protobuf/compiler/main_no_generators.cc b/src/google/protobuf/compiler/main_no_generators.cc index 83a44e8b4c..82ba9238ee 100644 --- a/src/google/protobuf/compiler/main_no_generators.cc +++ b/src/google/protobuf/compiler/main_no_generators.cc @@ -19,7 +19,10 @@ namespace compiler { // This is a version of protoc that has no built-in code generators. // See go/protobuf-toolchain-protoc int ProtocMain(int argc, char* argv[]) { +#ifndef _MSC_VER + // TODO Re-enable this once github runner issue is resolved. absl::InitializeLog(); +#endif // !_MSC_VER CommandLineInterface cli; cli.AllowPlugins("protoc-");