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

Missing abseil linkage in libprotobuf.a #19375

Open
bojle opened this issue Nov 23, 2024 · 11 comments
Open

Missing abseil linkage in libprotobuf.a #19375

bojle opened this issue Nov 23, 2024 · 11 comments
Labels

Comments

@bojle
Copy link

bojle commented Nov 23, 2024

What version of protobuf and what language are you using?
Version: v28.0 (checkout out from github)
Language: C++

What operating system (Linux, Windows, ...) and version?
Linux, Ubuntu (22.04)

What runtime / compiler are you using (e.g., python version or gcc version)
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

What did you do?

I am trying to create an executable that is linked statically with
libprotobuf-lite.a, compiled from source (not the one available in /usr/lib),
but face linker errors from abseil not being linked statically with
libprotobuf-lite.a

Steps to reproduce the behavior:

  1. Create a fresh directory, in it

  2. Download the onnx proto definition

wget 'https://raw.githubusercontent.com/onnx/onnx/refs/heads/main/onnx/onnx.proto3'
  1. Get protobuf v28.0 and build it
git clone https://github.com/protocolbuffers/protobuf/ --depth 1 --recursive -b v28.0
cd protobuf
mkdir build
cmake -B build
cmake --build build -j $(nproc --all)

this should create libprotbuf-lite.a in the build directory

  1. Use the protoc built in step 3, to create onnx.proto3.pb.{h,cc}
./protobuf/build/protoc --cpp_out=. onnx.proto3
  1. Create the driver
// a.cpp

#include "onnx.proto3.pb.h"
#include <fstream>
#include <iostream>

int main() {
        onnx::ModelProto mp;
        std::ifstream ifp("vgg.onnx");
        mp.ParseFromIstream(&ifp);
        std::cout << mp.ir_version() << '\n';
}
// Makefile

INC = -I protobuf/src/ -I protobuf/third_party/abseil-cpp/
ABSL = protobuf/build/third_party/abseil-cpp/absl/
LIBS = ${ABSL}/log/*.a ${ABSL}/base/*.a ${ABSL}/container/*.a ${ABSL}/crc/*.a ${ABSL}/debugging/*.a ${ABSL}/flags/*.a ${ABSL}/hash/*.a ${ABSL}/log/*.a ${ABSL}/numeric/*.a ${ABSL}/profiling/*.a ${ABSL}/random/*.a ${ABSL}/status/*.a ${ABSL}/strings/*.a ${ABSL}/synchronization/*.a ${ABSL}/time/*.a ${ABSL}/types/*.a


all: a.cpp onnx.proto3.pb.o
        g++ ${INC} a.cpp onnx.proto3.pb.o protobuf/build/libprotobuf-lite.a ${LIBS} -o a

onnx.proto3.pb.o: onnx.proto3.pb.cc
        g++ -c ${INC} $^ -o $@
  1. Build the driver
make

What did you expect to see

Expected the executable to be built completely without any linker errors.

What did you see instead?

Compilation terminates with these absl errors:

/usr/bin/ld: protobuf/build/libprotobuf-lite.a(generated_message_tctable_lite.cc.o): in function `google::protobuf::internal::TcParser::FastSS1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)':
generated_message_tctable_lite.cc:(.text+0x148d4): undefined reference to `utf8_range::IsStructurallyValid(std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: protobuf/build/libprotobuf-lite.a(generated_message_tctable_lite.cc.o): in function `google::protobuf::internal::TcParser::FastSS2(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)':
generated_message_tctable_lite.cc:(.text+0x14c4c): undefined reference to `utf8_range::IsStructurallyValid(std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: protobuf/build/libprotobuf-lite.a(generated_message_tctable_lite.cc.o): in function `google::protobuf::internal::TcParser::FastUS1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)':
generated_message_tctable_lite.cc:(.text+0x14fc8): undefined reference to `utf8_range::IsStructurallyValid(std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: protobuf/build/libprotobuf-lite.a(generated_message_tctable_lite.cc.o): in function `google::protobuf::internal::TcParser::FastUS2(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)':
generated_message_tctable_lite.cc:(.text+0x15370): undefined reference to `utf8_range::IsStructurallyValid(std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: protobuf/build/libprotobuf-lite.a(generated_message_tctable_lite.cc.o): in function `google::protobuf::internal::TcParser::MpVerifyUtf8(std::basic_string_view<char, std::char_traits<char> >, google::protobuf::internal::TcParseTableBase const*, google::protobuf::internal::TcParseTableBase::FieldEntry const&, unsigned short)':
generated_message_tctable_lite.cc:(.text+0x18b5c): undefined reference to `utf8_range::IsStructurallyValid(std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: protobuf/build/libprotobuf-lite.a(generated_message_tctable_lite.cc.o):generated_message_tctable_lite.cc:(.text+0x18bd0): more undefined references to `utf8_range::IsStructurallyValid(std::basic_string_view<char, std::char_traits<char> >)' follow
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_stacktrace.a(stacktrace.cc.o): in function `GetKernelRtSigreturnAddress()::{lambda(int)#1}::operator()(int) const':
stacktrace.cc:(.text+0x3c): undefined reference to `absl::lts_20240116::debugging_internal::VDSOSupport::LookupSymbol(char const*, char const*, int, absl::lts_20240116::debugging_internal::ElfMemImage::SymbolInfo*) const'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_stacktrace.a(stacktrace.cc.o): in function `GetKernelRtSigreturnAddress()':
stacktrace.cc:(.text+0xb4): undefined reference to `absl::lts_20240116::debugging_internal::VDSOSupport::VDSOSupport()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_stacktrace.a(stacktrace.cc.o): in function `void** NextStackFrame<true, true>(void**, void const*, StackInfo const*)':
stacktrace.cc:(.text+0xfb0): undefined reference to `absl::lts_20240116::debugging_internal::AddressIsReadable(void const*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_stacktrace.a(stacktrace.cc.o): in function `void** NextStackFrame<false, true>(void**, void const*, StackInfo const*)':
stacktrace.cc:(.text+0x1300): undefined reference to `absl::lts_20240116::debugging_internal::AddressIsReadable(void const*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_symbolize.a(symbolize.cc.o): in function `absl::lts_20240116::InitializeSymbolizer(char const*)':
symbolize.cc:(.text+0xc): undefined reference to `absl::lts_20240116::debugging_internal::VDSOSupport::Init()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_symbolize.a(symbolize.cc.o): in function `absl::lts_20240116::debugging_internal::(anonymous namespace)::InitSigSafeArena()':
symbolize.cc:(.text+0x1a8): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::NewArena(unsigned int)'
/usr/bin/ld: symbolize.cc:(.text+0x1ec): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::DeleteArena(absl::lts_20240116::base_internal::LowLevelAlloc::Arena*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_symbolize.a(symbolize.cc.o): in function `absl::lts_20240116::debugging_internal::(anonymous namespace)::AddrMap::~AddrMap()':
symbolize.cc:(.text+0x25c): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Free(void*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_symbolize.a(symbolize.cc.o): in function `absl::lts_20240116::debugging_internal::(anonymous namespace)::AddrMap::Add()':
symbolize.cc:(.text+0x37c): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::AllocWithArena(unsigned long, absl::lts_20240116::base_internal::LowLevelAlloc::Arena*)'
/usr/bin/ld: symbolize.cc:(.text+0x3d4): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Free(void*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_symbolize.a(symbolize.cc.o): in function `absl::lts_20240116::debugging_internal::(anonymous namespace)::Symbolizer::CopyString(char const*)':
symbolize.cc:(.text+0x4f0): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::AllocWithArena(unsigned long, absl::lts_20240116::base_internal::LowLevelAlloc::Arena*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_symbolize.a(symbolize.cc.o): in function `absl::lts_20240116::debugging_internal::AllocateSymbolizer()':
symbolize.cc:(.text+0x618): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::AllocWithArena(unsigned long, absl::lts_20240116::base_internal::LowLevelAlloc::Arena*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_symbolize.a(symbolize.cc.o): in function `absl::lts_20240116::debugging_internal::FreeSymbolizer(absl::lts_20240116::debugging_internal::(anonymous namespace)::Symbolizer*)':
symbolize.cc:(.text+0x6a8): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Free(void*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_symbolize.a(symbolize.cc.o): in function `absl::lts_20240116::debugging_internal::(anonymous namespace)::Symbolizer::~Symbolizer()':
symbolize.cc:(.text+0x820): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Free(void*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_symbolize.a(symbolize.cc.o): in function `absl::lts_20240116::debugging_internal::(anonymous namespace)::Symbolizer::ClearAddrMap()':
symbolize.cc:(.text+0x274c): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Free(void*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_symbolize.a(symbolize.cc.o): in function `absl::lts_20240116::debugging_internal::DemangleInplace(char*, unsigned long, char*, unsigned long)':
symbolize.cc:(.text+0x2a10): undefined reference to `absl::lts_20240116::debugging_internal::Demangle(char const*, char*, unsigned long)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_symbolize.a(symbolize.cc.o): in function `absl::lts_20240116::debugging_internal::(anonymous namespace)::Symbolizer::InsertSymbolInCache(void const*, char const*)':
symbolize.cc:(.text+0x2db4): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Free(void*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_symbolize.a(symbolize.cc.o): in function `absl::lts_20240116::debugging_internal::(anonymous namespace)::Symbolizer::GetUncachedSymbol(void const*)':
symbolize.cc:(.text+0x3624): undefined reference to `absl::lts_20240116::debugging_internal::VDSOSupport::VDSOSupport()'
/usr/bin/ld: symbolize.cc:(.text+0x364c): undefined reference to `absl::lts_20240116::debugging_internal::VDSOSupport::LookupSymbolByAddress(void const*, absl::lts_20240116::debugging_internal::ElfMemImage::SymbolInfo*) const'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_symbolize.a(symbolize.cc.o): in function `absl::lts_20240116::debugging_internal::RegisterFileMappingHint(void const*, void const*, unsigned long, char const*)':
symbolize.cc:(.text+0x3c50): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::AllocWithArena(unsigned long, absl::lts_20240116::base_internal::LowLevelAlloc::Arena*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//debugging/libabsl_symbolize.a(symbolize.cc.o): in function `absl::lts_20240116::base_internal::SpinLock::Unlock()':
symbolize.cc:(.text._ZN4absl12lts_2024011613base_internal8SpinLock6UnlockEv[_ZN4absl12lts_2024011613base_internal8SpinLock6UnlockEv]+0x98): undefined reference to `absl::lts_20240116::base_internal::SpinLock::SlowUnlock(unsigned int)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//hash/libabsl_hash.a(hash.cc.o): in function `absl::lts_20240116::hash_internal::MixingHashState::CombineLargeContiguousImpl32(unsigned long, unsigned char const*, unsigned long)':
hash.cc:(.text+0x30): undefined reference to `absl::lts_20240116::hash_internal::CityHash32(char const*, unsigned long)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//hash/libabsl_hash.a(hash.cc.o): in function `absl::lts_20240116::hash_internal::MixingHashState::CombineContiguousImpl(unsigned long, unsigned char const*, unsigned long, std::integral_constant<int, 4>)':
hash.cc:(.text._ZN4absl12lts_2024011613hash_internal15MixingHashState21CombineContiguousImplEmPKhmSt17integral_constantIiLi4EE[_ZN4absl12lts_2024011613hash_internal15MixingHashState21CombineContiguousImplEmPKhmSt17integral_constantIiLi4EE]+0x78): undefined reference to `absl::lts_20240116::hash_internal::CityHash32(char const*, unsigned long)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cord.a(cord.cc.o): in function `absl::lts_20240116::Cord::SetCrcCordState(absl::lts_20240116::crc_internal::CrcCordState)':
cord.cc:(.text+0x2a80): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::CrcCordState(absl::lts_20240116::crc_internal::CrcCordState&&)'
/usr/bin/ld: cord.cc:(.text+0x2a9c): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::~CrcCordState()'
/usr/bin/ld: cord.cc:(.text+0x2af0): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::CrcCordState(absl::lts_20240116::crc_internal::CrcCordState&&)'
/usr/bin/ld: cord.cc:(.text+0x2b0c): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::~CrcCordState()'
/usr/bin/ld: cord.cc:(.text+0x2b58): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::CrcCordState(absl::lts_20240116::crc_internal::CrcCordState&&)'
/usr/bin/ld: cord.cc:(.text+0x2b74): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::~CrcCordState()'
/usr/bin/ld: cord.cc:(.text+0x2ba0): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::~CrcCordState()'
/usr/bin/ld: cord.cc:(.text+0x2bb4): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::~CrcCordState()'
/usr/bin/ld: cord.cc:(.text+0x2bc8): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::~CrcCordState()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cord.a(cord.cc.o): in function `absl::lts_20240116::Cord::SetExpectedChecksum(unsigned int)':
cord.cc:(.text+0x2c3c): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::CrcCordState()'
/usr/bin/ld: cord.cc:(.text+0x2c94): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::CrcCordState(absl::lts_20240116::crc_internal::CrcCordState&&)'
/usr/bin/ld: cord.cc:(.text+0x2cac): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::~CrcCordState()'
/usr/bin/ld: cord.cc:(.text+0x2cb4): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::~CrcCordState()'
/usr/bin/ld: cord.cc:(.text+0x2ce0): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::~CrcCordState()'
/usr/bin/ld: cord.cc:(.text+0x2cf0): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::~CrcCordState()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cord.a(cord.cc.o): in function `absl::lts_20240116::Cord::ExpectedChecksum() const':
cord.cc:(.text+0x2e24): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::Checksum() const'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cord.a(cord.cc.o): in function `absl::lts_20240116::DumpNode(absl::lts_20240116::cord_internal::CordRep*, bool, std::ostream*, int)':
cord.cc:(.text+0x4fa0): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::Checksum() const'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cord.a(cord.cc.o): in function `absl::lts_20240116::cord_internal::CordRepCrc::~CordRepCrc()':
cord.cc:(.text._ZN4absl12lts_2024011613cord_internal10CordRepCrcD2Ev[_ZN4absl12lts_2024011613cord_internal10CordRepCrcD5Ev]+0x14): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::~CrcCordState()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cord_internal.a(cord_rep_crc.cc.o): in function `absl::lts_20240116::cord_internal::CordRepCrc::New(absl::lts_20240116::cord_internal::CordRep*, absl::lts_20240116::crc_internal::CrcCordState)':
cord_rep_crc.cc:(.text+0x7c): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::operator=(absl::lts_20240116::crc_internal::CrcCordState&&)'
/usr/bin/ld: cord_rep_crc.cc:(.text+0x11c): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::operator=(absl::lts_20240116::crc_internal::CrcCordState&&)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cord_internal.a(cord_rep_crc.cc.o): in function `absl::lts_20240116::cord_internal::CordRepCrc::CordRepCrc()':
cord_rep_crc.cc:(.text._ZN4absl12lts_2024011613cord_internal10CordRepCrcC2Ev[_ZN4absl12lts_2024011613cord_internal10CordRepCrcC5Ev]+0x1c): undefined reference to `absl::lts_20240116::crc_internal::CrcCordState::CrcCordState()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cordz_functions.a(cordz_functions.cc.o): in function `absl::lts_20240116::cord_internal::cordz_should_profile_slow()':
cordz_functions.cc:(.text+0xa4): undefined reference to `absl::lts_20240116::profiling_internal::ExponentialBiased::GetStride(long)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cordz_info.a(cordz_info.cc.o): in function `absl::lts_20240116::cord_internal::CordzInfo::Head(absl::lts_20240116::cord_internal::CordzSnapshot const&)':
cordz_info.cc:(.text+0x910): undefined reference to `absl::lts_20240116::cord_internal::CordzHandle::DiagnosticsHandleIsSafeToInspect(absl::lts_20240116::cord_internal::CordzHandle const*) const'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cordz_info.a(cordz_info.cc.o): in function `absl::lts_20240116::cord_internal::CordzInfo::Next(absl::lts_20240116::cord_internal::CordzSnapshot const&) const':
cordz_info.cc:(.text+0xa44): undefined reference to `absl::lts_20240116::cord_internal::CordzHandle::DiagnosticsHandleIsSafeToInspect(absl::lts_20240116::cord_internal::CordzHandle const*) const'
/usr/bin/ld: cordz_info.cc:(.text+0xa68): undefined reference to `absl::lts_20240116::cord_internal::CordzHandle::DiagnosticsHandleIsSafeToInspect(absl::lts_20240116::cord_internal::CordzHandle const*) const'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cordz_info.a(cordz_info.cc.o): in function `absl::lts_20240116::cord_internal::CordzInfo::CordzInfo(absl::lts_20240116::cord_internal::CordRep*, absl::lts_20240116::cord_internal::CordzInfo const*, absl::lts_20240116::cord_internal::CordzUpdateTracker::MethodIdentifier)':
cordz_info.cc:(.text+0xfb0): undefined reference to `absl::lts_20240116::cord_internal::CordzHandle::~CordzHandle()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cordz_info.a(cordz_info.cc.o): in function `absl::lts_20240116::cord_internal::CordzInfo::~CordzInfo()':
cordz_info.cc:(.text+0x1030): undefined reference to `absl::lts_20240116::cord_internal::CordzHandle::~CordzHandle()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cordz_info.a(cordz_info.cc.o): in function `absl::lts_20240116::cord_internal::CordzInfo::Untrack()':
cordz_info.cc:(.text+0x1384): undefined reference to `absl::lts_20240116::cord_internal::CordzHandle::SafeToDelete() const'
/usr/bin/ld: cordz_info.cc:(.text+0x1400): undefined reference to `absl::lts_20240116::cord_internal::CordzHandle::Delete(absl::lts_20240116::cord_internal::CordzHandle*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cordz_info.a(cordz_info.cc.o): in function `absl::lts_20240116::base_internal::SpinLock::Lock()':
cordz_info.cc:(.text._ZN4absl12lts_2024011613base_internal8SpinLock4LockEv[_ZN4absl12lts_2024011613base_internal8SpinLock4LockEv]+0x2c): undefined reference to `absl::lts_20240116::base_internal::SpinLock::SlowLock()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cordz_info.a(cordz_info.cc.o): in function `absl::lts_20240116::cord_internal::CordzHandle::CordzHandle()':
cordz_info.cc:(.text._ZN4absl12lts_2024011613cord_internal11CordzHandleC2Ev[_ZN4absl12lts_2024011613cord_internal11CordzHandleC5Ev]+0x14): undefined reference to `absl::lts_20240116::cord_internal::CordzHandle::CordzHandle(bool)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_cordz_info.a(cordz_info.cc.o):(.data.rel.ro._ZTIN4absl12lts_2024011613cord_internal9CordzInfoE[_ZTIN4absl12lts_2024011613cord_internal9CordzInfoE]+0x10): undefined reference to `typeinfo for absl::lts_20240116::cord_internal::CordzHandle'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//strings/libabsl_str_format_internal.a(float_conversion.cc.o): in function `absl::lts_20240116::str_format_internal::(anonymous namespace)::Decomposed<long double> absl::lts_20240116::str_format_internal::(anonymous namespace)::Decompose<long double>(long double)':
float_conversion.cc:(.text+0x3e88): undefined reference to `absl::lts_20240116::uint128::uint128(long double)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(mutex.cc.o): in function `absl::lts_20240116::EnsureSynchEvent(std::atomic<long>*, char const*, long, long)':
mutex.cc:(.text+0x758): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Free(void*)'
/usr/bin/ld: mutex.cc:(.text+0x850): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Alloc(unsigned long)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(mutex.cc.o): in function `absl::lts_20240116::UnrefSynchEvent(absl::lts_20240116::SynchEvent*)':
mutex.cc:(.text+0x968): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Free(void*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(mutex.cc.o): in function `absl::lts_20240116::LocksHeldAlloc()':
mutex.cc:(.text+0xd28): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Alloc(unsigned long)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(mutex.cc.o): in function `absl::lts_20240116::Mutex::InternalAttemptToUseMutexInFatalSignalHandler()':
mutex.cc:(.text+0xe64): undefined reference to `absl::lts_20240116::base_internal::CurrentThreadIdentityIfPresent()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(mutex.cc.o): in function `absl::lts_20240116::GetGraphIdLocked(absl::lts_20240116::Mutex*)':
mutex.cc:(.text+0x1f94): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Alloc(unsigned long)'
/usr/bin/ld: mutex.cc:(.text+0x1fb0): undefined reference to `absl::lts_20240116::synchronization_internal::GraphCycles::GraphCycles()'
/usr/bin/ld: mutex.cc:(.text+0x1fd0): undefined reference to `absl::lts_20240116::synchronization_internal::GraphCycles::GetId(void*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(mutex.cc.o): in function `absl::lts_20240116::(anonymous namespace)::ScopedDeadlockReportBuffers::ScopedDeadlockReportBuffers()':
mutex.cc:(.text+0x2890): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Alloc(unsigned long)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(mutex.cc.o): in function `absl::lts_20240116::(anonymous namespace)::ScopedDeadlockReportBuffers::~ScopedDeadlockReportBuffers()':
mutex.cc:(.text+0x28c0): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Free(void*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(mutex.cc.o): in function `absl::lts_20240116::DeadlockCheck(absl::lts_20240116::Mutex*)':
mutex.cc:(.text+0x29bc): undefined reference to `absl::lts_20240116::synchronization_internal::GraphCycles::UpdateStackTrace(absl::lts_20240116::synchronization_internal::GraphId, int, int (*)(void**, int))'
/usr/bin/ld: mutex.cc:(.text+0x29fc): undefined reference to `absl::lts_20240116::synchronization_internal::GraphCycles::Ptr(absl::lts_20240116::synchronization_internal::GraphId)'
/usr/bin/ld: mutex.cc:(.text+0x2a24): undefined reference to `absl::lts_20240116::synchronization_internal::GraphCycles::InsertEdge(absl::lts_20240116::synchronization_internal::GraphId, absl::lts_20240116::synchronization_internal::GraphId)'
/usr/bin/ld: mutex.cc:(.text+0x2afc): undefined reference to `absl::lts_20240116::synchronization_internal::GraphCycles::Ptr(absl::lts_20240116::synchronization_internal::GraphId)'
/usr/bin/ld: mutex.cc:(.text+0x2c04): undefined reference to `absl::lts_20240116::synchronization_internal::GraphCycles::FindPath(absl::lts_20240116::synchronization_internal::GraphId, absl::lts_20240116::synchronization_internal::GraphId, int, absl::lts_20240116::synchronization_internal::GraphId*) const'
/usr/bin/ld: mutex.cc:(.text+0x2c40): undefined reference to `absl::lts_20240116::synchronization_internal::GraphCycles::Ptr(absl::lts_20240116::synchronization_internal::GraphId)'
/usr/bin/ld: mutex.cc:(.text+0x2c6c): undefined reference to `absl::lts_20240116::synchronization_internal::GraphCycles::GetStackTrace(absl::lts_20240116::synchronization_internal::GraphId, void***)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(mutex.cc.o): in function `absl::lts_20240116::Mutex::ForgetDeadlockInfo()':
mutex.cc:(.text+0x2f30): undefined reference to `absl::lts_20240116::synchronization_internal::GraphCycles::RemoveNode(void*)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(mutex.cc.o): in function `absl::lts_20240116::synchronization_internal::GetOrCreateCurrentThreadIdentity()':
mutex.cc:(.text._ZN4absl12lts_2024011624synchronization_internal32GetOrCreateCurrentThreadIdentityEv[_ZN4absl12lts_2024011624synchronization_internal32GetOrCreateCurrentThreadIdentityEv]+0x8): undefined reference to `absl::lts_20240116::base_internal::CurrentThreadIdentityIfPresent()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(mutex.cc.o): in function `absl::lts_20240116::base_internal::CycleClock::LoadCycleClockSource()':
mutex.cc:(.text._ZN4absl12lts_2024011613base_internal10CycleClock20LoadCycleClockSourceEv[_ZN4absl12lts_2024011613base_internal10CycleClock20LoadCycleClockSourceEv]+0xc): undefined reference to `absl::lts_20240116::base_internal::CycleClock::cycle_clock_source_'
/usr/bin/ld: mutex.cc:(.text._ZN4absl12lts_2024011613base_internal10CycleClock20LoadCycleClockSourceEv[_ZN4absl12lts_2024011613base_internal10CycleClock20LoadCycleClockSourceEv]+0x10): undefined reference to `absl::lts_20240116::base_internal::CycleClock::cycle_clock_source_'
/usr/bin/ld: mutex.cc:(.text._ZN4absl12lts_2024011613base_internal10CycleClock20LoadCycleClockSourceEv[_ZN4absl12lts_2024011613base_internal10CycleClock20LoadCycleClockSourceEv]+0x38): undefined reference to `absl::lts_20240116::base_internal::CycleClock::cycle_clock_source_'
/usr/bin/ld: mutex.cc:(.text._ZN4absl12lts_2024011613base_internal10CycleClock20LoadCycleClockSourceEv[_ZN4absl12lts_2024011613base_internal10CycleClock20LoadCycleClockSourceEv]+0x3c): undefined reference to `absl::lts_20240116::base_internal::CycleClock::cycle_clock_source_'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(mutex.cc.o): in function `absl::lts_20240116::base_internal::CycleClock::Now()':
mutex.cc:(.text._ZN4absl12lts_2024011613base_internal10CycleClock3NowEv[_ZN4absl12lts_2024011613base_internal10CycleClock3NowEv]+0x1c): undefined reference to `absl::lts_20240116::base_internal::UnscaledCycleClock::Now()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(mutex.cc.o): in function `absl::lts_20240116::base_internal::CycleClock::Frequency()':
mutex.cc:(.text._ZN4absl12lts_2024011613base_internal10CycleClock9FrequencyEv[_ZN4absl12lts_2024011613base_internal10CycleClock9FrequencyEv]+0x8): undefined reference to `absl::lts_20240116::base_internal::UnscaledCycleClock::Frequency()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(create_thread_identity.cc.o): in function `absl::lts_20240116::synchronization_internal::ReclaimThreadIdentity(void*)':
create_thread_identity.cc:(.text+0x40): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Free(void*)'
/usr/bin/ld: create_thread_identity.cc:(.text+0x44): undefined reference to `absl::lts_20240116::base_internal::ClearCurrentThreadIdentity()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(create_thread_identity.cc.o): in function `absl::lts_20240116::synchronization_internal::NewThreadIdentity()':
create_thread_identity.cc:(.text+0x32c): undefined reference to `absl::lts_20240116::base_internal::LowLevelAlloc::Alloc(unsigned long)'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(create_thread_identity.cc.o): in function `absl::lts_20240116::synchronization_internal::CreateThreadIdentity()':
create_thread_identity.cc:(.text+0x3a4): undefined reference to `absl::lts_20240116::base_internal::SetCurrentThreadIdentity(absl::lts_20240116::base_internal::ThreadIdentity*, void (*)(void*))'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(futex_waiter.cc.o): in function `absl::lts_20240116::synchronization_internal::FutexWaiter::WaitUntil(std::atomic<int>*, int, absl::lts_20240116::synchronization_internal::KernelTimeout)':
futex_waiter.cc:(.text+0x98): undefined reference to `absl::lts_20240116::synchronization_internal::KernelTimeout::MakeRelativeTimespec() const'
/usr/bin/ld: futex_waiter.cc:(.text+0xbc): undefined reference to `absl::lts_20240116::synchronization_internal::KernelTimeout::MakeAbsTimespec() const'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//synchronization/libabsl_synchronization.a(waiter_base.cc.o): in function `absl::lts_20240116::synchronization_internal::WaiterBase::MaybeBecomeIdle()':
waiter_base.cc:(.text+0x8): undefined reference to `absl::lts_20240116::base_internal::CurrentThreadIdentityIfPresent()'
/usr/bin/ld: protobuf/build/third_party/abseil-cpp/absl//time/libabsl_time.a(duration.cc.o): in function `absl::lts_20240116::(anonymous namespace)::SafeMultiply<absl::lts_20240116::uint128>::operator()(absl::lts_20240116::uint128, absl::lts_20240116::uint128) const':
duration.cc:(.text+0x4750): undefined reference to `absl::lts_20240116::kuint128max'
/usr/bin/ld: duration.cc:(.text+0x4754): undefined reference to `absl::lts_20240116::kuint128max'
/usr/bin/ld: duration.cc:(.text+0x4780): undefined reference to `absl::lts_20240116::kuint128max'
/usr/bin/ld: duration.cc:(.text+0x4784): undefined reference to `absl::lts_20240116::kuint128max'

Anything else we should know about your project / environment

Initially i was not linking absl .a libs explicitly assuming them to be fully linked in the libprotobuf-lite.a. Upon checking
out all the issues similar to this, I started linking absl. The linker error still persist even after linking absl libs fully.

The system is a very barebone linux image with no other absl/protobuf. Here's ldd for protoc,

$ ldd protobuf/build/protoc
	linux-vdso.so.1 (0x0000007f9413a000)
	libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000007f92fe0000)
	libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007f92f40000)
	libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000007f92f10000)
	libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f92d60000)
	/lib/ld-linux-aarch64.so.1 (0x0000007f94101000)
@bojle bojle added the untriaged auto added to all issues by default when created. label Nov 23, 2024
@bojle
Copy link
Author

bojle commented Nov 23, 2024

@mkruskal-google could you look at this?

@acozzette
Copy link
Member

Have you tried using pkg-config to get the list of .a files to link against? I believe that should provide the full list, or that doesn't work then it's a bug we should fix.

@acozzette acozzette added cmake and removed untriaged auto added to all issues by default when created. labels Nov 25, 2024
@bojle
Copy link
Author

bojle commented Nov 26, 2024

I tried with pkg-config:

  1. How do i statically link absl with my program through pkg-config? I see that a .private field should be present in the pc files in order to link that lib statically but none of the absl pc files contain it. Seems its only possible to have shared linkage through pkg-config.
  2. I notice the the absl pkg-config lists libraries that are simply not being built (i.e. i cannot find a .a for that lib in build dir). Total libs through pkg-config (ls -1 lib/pkgconfig | grep absl | wc -l) are 185. Libs that are actually built (find protobuf/third_party/abseil-cpp/absl/ | grep ".a$" | wc -l) 87.

@bojle
Copy link
Author

bojle commented Nov 26, 2024

I grepped for libs mentioned in pkgconfig to see if they are present in build/, following are the pc files of libs not being built, i suppose. Some, such as absl_absl_check are empty i.e. pkg-config --libs on them does not return anything other than -L{libdir} but others such as absl_log_internal_check_impl are probably not built (I could not find a .a for them).

absl_absl_check
absl_absl_log
absl_absl_vlog_is_on
absl_algorithm_container
absl_algorithm
absl_any_invocable
absl_any
absl_atomic_hook
absl_base_internal
absl_bind_front
absl_bits
absl_btree
absl_charset
absl_check
absl_cleanup_internal
absl_cleanup
absl_common_policy_traits
absl_compare
absl_compressed_tuple
absl_config
absl_container_common
absl_container_memory
absl_cordz_statistics
absl_cordz_update_scope
absl_cordz_update_tracker
absl_core_headers
absl_dynamic_annotations
absl_endian
absl_errno_saver
absl_fast_type_id
absl_fixed_array
absl_flags_path_util
absl_flat_hash_map
absl_flat_hash_set
absl_function_ref
absl_hash_function_defaults
absl_hash_policy_traits
absl_hashtable_debug_hooks
absl_hashtable_debug
absl_has_ostream_operator
absl_if_constexpr
absl_inlined_vector_internal
absl_inlined_vector
absl_layout
absl_log_internal_append_truncated
absl_log_internal_check_impl
absl_log_internal_config
absl_log_internal_flags
absl_log_internal_log_impl
absl_log_internal_nullstream
absl_log_internal_strip
absl_log_internal_structured
absl_log_internal_voidify
absl_log_sink_registry
absl_log_streamer
absl_log_structured
absl_memory
absl_meta
absl_node_hash_map
absl_node_hash_set
absl_node_slot_policy
absl_no_destructor
absl_non_temporal_arm_intrinsics
absl_non_temporal_memcpy
absl_nullability
absl_numeric
absl_numeric_representation
absl_optional
absl_overload
absl_prefetch
absl_pretty_function
absl_random_bit_gen_ref
absl_random_internal_distribution_caller
absl_random_internal_fastmath
absl_random_internal_fast_uniform_bits
absl_random_internal_generate_real
absl_random_internal_iostream_state_saver
absl_random_internal_mock_helpers
absl_random_internal_nonsecure_base
absl_random_internal_pcg_engine
absl_random_internal_randen_engine
absl_random_internal_salted_seed_seq
absl_random_internal_traits
absl_random_internal_uniform_helper
absl_random_internal_wide_multiply
absl_random_random
absl_raw_hash_map
absl_sample_recorder
absl_span
absl_test_allocator
absl_type_traits
absl_utility
absl_variant
absl_vlog_is_on

For now, I've resorted to using protobuf v21.12 as it has no dependence on abseil (it works) but i would like not to be stuck with a 2 year old version of this lib.

@acozzette
Copy link
Member

I would expect that pkg-config --libs --static protobuf-lite should give you the full list of flags you would need to statically link everything.

I suspect that the reason some of the Abseil .pc files don't have a corresponding .a file is just that some of them are headers only. But I don't think you need to worry about that since the command above should provide the correct flags in any case.

@amlamarra
Copy link

Anyone solve this issue? I've tried everything under the sun and I've been struggling with this for 2 weeks now.

@duki
Copy link

duki commented Dec 17, 2024

Can't compile on multiple systems because of this.

@amlamarra
Copy link

This is what fixed it for me: #19494 (comment)

@duki
Copy link

duki commented Dec 20, 2024

Maybe the real libabsl were the friends we made on this journey.

@bojle
Copy link
Author

bojle commented Dec 20, 2024

correction: maybe the real libabsl_2024121627637371928 were the friends we made on this journey

@duki
Copy link

duki commented Dec 20, 2024

I have succeeded in compiling using cmake only and added protobuf support to my existing project using a local gRPC installation instead of protobuf.

I have succeeded in compiling libprotobuf using cmake by manually compiling libabsl by setting two testing flags to OFF. I have had trouble linking and am giving up for now.

What caused this issue?
Did libabseil make some changes in the meantime? Was it triggered by a change in cmakes find_package configuration for libprotobuf or libabsl or libgtest?
Is it the protobuf team for not wanting to tamper with the build system for libprotobuf as to not cause a problem upstream?
Is there a secret Bazel agenda at play here? Is the adoption od protobuf supposed to be tied to the adoption of grpc?

Or was I just one command line argument away from success?

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

No branches or pull requests

4 participants