From 2a636651729cec997a433ce8e363c6344130944e Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Wed, 3 Jan 2024 13:00:42 -0800 Subject: Avoid a empty library build failure on Apple platforms https://github.com/abseil/abseil-cpp/issues/1465 reports that some CMake builds on Apply platforms issue ``` warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: archive library: libabsl_bad_any_cast_impl.a the table of contents is empty (no object file members in the library define global symbols) ``` Our CMake build handles this problem for header-only libraries by not building a library at all. For some libraries, for example our polyfills, the library is only conditionally empty. In these libraries, I added a single char variable on Apple platforms as a workaround. I have been able to reproduce the warnings reported in https://github.com/abseil/abseil-cpp/issues/1465, but they don't fail the build for me. I don't see them any more after this change. PiperOrigin-RevId: 595480705 Change-Id: Ie48637e84ebae2f2aea4e2de83b146f30f6a76b9 --- absl/log/log_entry.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'absl/log/log_entry.cc') diff --git a/absl/log/log_entry.cc b/absl/log/log_entry.cc index 19c3b3f1..fe58a576 100644 --- a/absl/log/log_entry.cc +++ b/absl/log/log_entry.cc @@ -25,5 +25,17 @@ constexpr int LogEntry::kNoVerbosityLevel; constexpr int LogEntry::kNoVerboseLevel; #endif +// https://github.com/abseil/abseil-cpp/issues/1465 +// CMake builds on Apple platforms error when libraries are empty. +// Our CMake configuration can avoid this error on header-only libraries, +// but since this library is conditionally empty, including a single +// variable is an easy workaround. +#ifdef __APPLE__ +namespace log_internal { +extern const char kAvoidEmptyLogEntryLibraryWarning; +const char kAvoidEmptyLogEntryLibraryWarning = 0; +} // namespace log_internal +#endif // __APPLE__ + ABSL_NAMESPACE_END } // namespace absl -- cgit v1.2.3