Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build broken on Arch Linux with ABSL_ASSUME errors from protobuf headers #353

Open
colatkinson opened this issue Jul 26, 2023 · 3 comments

Comments

@colatkinson
Copy link

The issue appears to be coming from an incompatibility between the system-provided version of protobuf and the vendored version of abseil.

Modifying the CMake file to use the system abseil instead seems to fix the issue. I have attached a hacky proof-of-concept patch below.

For reference, the system-provided version of protobuf is 23.4, and the system-provided abseil-cpp is 20230125.3. The bloaty commit I'm building is 2757d3e (latest main as of this writing).

Patch that fixes the build:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5a843b9..d90a548 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -157,7 +157,6 @@ endif()
 
 include_directories(.)
 include_directories(src)
-include_directories(third_party/abseil-cpp)
 include_directories("${CMAKE_CURRENT_BINARY_DIR}/src")
 
 # Baseline build flags.
@@ -244,27 +243,6 @@ add_library(libbloaty STATIC
     src/util.cc
     src/util.h
     src/webassembly.cc
-    # Until Abseil has a proper CMake build system
-    third_party/abseil-cpp/absl/base/internal/raw_logging.cc # Grrrr...
-    third_party/abseil-cpp/absl/base/internal/throw_delegate.cc
-    third_party/abseil-cpp/absl/debugging/internal/demangle.cc
-    third_party/abseil-cpp/absl/numeric/int128.cc
-    third_party/abseil-cpp/absl/strings/ascii.cc
-    third_party/abseil-cpp/absl/strings/charconv.cc
-    third_party/abseil-cpp/absl/strings/escaping.cc
-    third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc
-    third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc
-    third_party/abseil-cpp/absl/strings/internal/escaping.cc
-    third_party/abseil-cpp/absl/strings/internal/memutil.cc
-    third_party/abseil-cpp/absl/strings/internal/utf8.cc
-    third_party/abseil-cpp/absl/strings/match.cc
-    third_party/abseil-cpp/absl/strings/numbers.cc
-    third_party/abseil-cpp/absl/strings/str_cat.cc
-    third_party/abseil-cpp/absl/strings/string_view.cc
-    third_party/abseil-cpp/absl/strings/str_split.cc
-    third_party/abseil-cpp/absl/strings/substitute.cc
-    third_party/abseil-cpp/absl/types/bad_optional_access.cc
-    # One source file, no special build system needed.
     third_party/demumble/third_party/libcxxabi/cxa_demangle.cpp
     )
 set_property(TARGET libbloaty PROPERTY FOLDER "bloaty")

The errors are generally of the form

FAILED: CMakeFiles/libbloaty.dir/src/macho.cc.o 
/usr/bin/c++ -DUSE_RE2 -D_LIBCXXABI_FUNC_VIS="" -I/usr/include/capstone -I/tmp/bloaty/. -I/tmp/bloaty/src -I/tmp/bloaty/third_party/abseil-cpp -I/tmp/bloaty/build/src -I/tmp/bloaty/third_party/googletest/googletest/include -I/tmp/bloaty/third_party/googletest/googlemock/include -W -Wall -Wno-sign-compare -fdiagnostics-color=always -O2 -g1 -std=gnu++17 -MD -MT CMakeFiles/libbloaty.dir/src/macho.cc.o -MF CMakeFiles/libbloaty.dir/src/macho.cc.o.d -o CMakeFiles/libbloaty.dir/src/macho.cc.o -c /tmp/bloaty/src/macho.cc
In file included from /usr/include/google/protobuf/implicit_weak_message.h:39,
                 from /usr/include/google/protobuf/generated_message_util.h:55,
                 from /tmp/bloaty/build/src/bloaty.pb.h:27,
                 from /tmp/bloaty/src/bloaty.h:39,
                 from /tmp/bloaty/src/macho.cc:17:
/usr/include/google/protobuf/repeated_field.h: In member function ‘void google::protobuf::RepeatedField< <template-parameter-1-1> >::Add(Element)’:
/usr/include/google/protobuf/repeated_field.h:674:3: error: there are no arguments to ‘ABSL_ASSUME’ that depend on a template parameter, so a declaration of ‘ABSL_ASSUME’ must be available [-fpermissive]
  674 |   ABSL_ASSUME(new_size == current_size_);
      |   ^~~~~~~~~~~

A complete build log is provided here: err-log.txt

For my 2¢ on a more complete fix: Arch does provide pkg-config files for abseil, so it should be possible to check for its presence as a system library that way. Alternatively, could just add a BLOATY_PREFER_SYSTEM_ABSL flag, like in #352.

Please let me know if any additional info would be helpful, or if this is a downstream bug of some kind.

@jmaselbas
Copy link

hi, i am having the same issue, also on arch with protobuf 23.4 and abseil-cpp 20230125.3

@cschramm
Copy link

The underlying issue seems to be that bloaty ships its own abseil LTS 20211102 while it happily accepts any system-provided protobuf. That means that such a protobuf has to be compatible with that abseil version so that anything newer than 21.12 does not work.

@cjdb
Copy link

cjdb commented Feb 19, 2024

The AUR package for bloaty-git provides a patch that might be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants