Skip to content

[Bug]: Undefined symbol referenced from absl::lts_20240722::log_internal::LogMessage::operator<<(unsigned long) #1747

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

Closed
Chekov2k opened this issue Aug 24, 2024 · 4 comments

Comments

@Chekov2k
Copy link

Describe the issue

I'm trying to use protobuf 27.3 which uses abseil 20240722.0 on Mac OS X Sonoma 14.6.1 and llvm 18.1.8 or gcc 14.1.0 (all installed using homebrew). I'm getting this undefined symbol (my code is compile with C++23 standard):

Undefined symbols for architecture arm64:
 "__ZN4absl12lts_2024072212log_internal10LogMessagelsImTnNSt3__19enable_ifIXntsr4absl16HasAbslStringifyIT_EE5valueEiE4typeELi0EEERS2_RKS6_", referenced from:
      absl::lts_20240722::log_internal::LogMessage::operator<<(unsigned long) in engine.pb.cc.o

I have been trying to narrow down the cause and only found one other report of someone having a similar issue (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=280885). As far as I can tell, I am following all the advised linking steps for protobut and abseil (tried adding all of the abseil libs as well just to be sure and still the same issue). I tried changing the CXX standard used for compilation of protobuf and abseil to CXX23 as well and still get the same error.

In our CI we get the same undefined symbol if we try and use llvm 18.1 or gcc 14.1 on linux (abseil and protobuf being compiled with the standard OS compiler for Ubuntu 22.04).

Does someone have an idea of what the issue might be or what I should try next? Everything works fine if I stick with llvm 17.0.6 or gcc 13.3.0.

Steps to reproduce the problem

Using protoc to generate C++ protobuf bindings

What version of Abseil are you using?

20240722

What operating system and version are you using?

Mac OS X Sonoma 14.6.1 arm64v8 or. Ubuntu 22.04 amd64

What compiler and version are you using?

Issues with llvm 18.1.8 and gcc 14.1.0 using C++23 standard
Fine with llvm 17.0.6 and gcc 13.3.0 using C++23 standard

What build system are you using?

cmake 3.30.2

Additional context

No response

@derekmauro
Copy link
Member

Probably related reports:
#1743
llvm/llvm-project#102443

@Chekov2k
Copy link
Author

@derekmauro Thank you very much for pointing out these other reports. The llvm one provides a workaround using
-fclang-abi-compat=17. Much appreciated!

@4kangjc
Copy link

4kangjc commented Sep 3, 2024

Adding the following code to your source file can also temporarily solve this problem

#include "absl/base/config.h"

namespace absl {

ABSL_NAMESPACE_BEGIN

namespace log_internal {

template LogMessage& LogMessage::operator<<(const char& v);
template LogMessage& LogMessage::operator<<(const signed char& v);
template LogMessage& LogMessage::operator<<(const unsigned char& v);
template LogMessage& LogMessage::operator<<(const short& v);           // NOLINT
template LogMessage& LogMessage::operator<<(const unsigned short& v);  // NOLINT
template LogMessage& LogMessage::operator<<(const int& v);
template LogMessage& LogMessage::operator<<(const unsigned int& v);
template LogMessage& LogMessage::operator<<(const long& v);           // NOLINT
template LogMessage& LogMessage::operator<<(const unsigned long& v);  // NOLINT
template LogMessage& LogMessage::operator<<(const long long& v);      // NOLINT
template LogMessage& LogMessage::operator<<(
    const unsigned long long& v);  // NOLINT
template LogMessage& LogMessage::operator<<(void* const& v);
template LogMessage& LogMessage::operator<<(const void* const& v);
template LogMessage& LogMessage::operator<<(const float& v);
template LogMessage& LogMessage::operator<<(const double& v);
template LogMessage& LogMessage::operator<<(const bool& v);

}  // namespace log_internal

ABSL_NAMESPACE_END

}  // namespace absl

@Chekov2k
Copy link
Author

Chekov2k commented Sep 3, 2024

Thank you!

@Chekov2k Chekov2k closed this as completed Sep 3, 2024
Partmedia added a commit to Partmedia/cl-protobufs that referenced this issue Oct 11, 2024
Royna2544 added a commit to Royna2544/c_cpp_telegrambot that referenced this issue Dec 2, 2024
donn added a commit to efabless/openlane2 that referenced this issue Dec 8, 2024
peterjunpark pushed a commit to peterjunpark/rdc that referenced this issue Mar 12, 2025
Please see:
- abseil/abseil-cpp#1747
- llvm/llvm-project#102443

When GRPC is compiled with different compiler from RDC - ABI broke.
Possibly because some templates were not instantiated.
Setting '-fclang-abi-compat=17' fixes the issue.

Change-Id: Ic6409cf413c87b135f334e5b03145cb1c63356d4

Signed-off-by: Galantsev, Dmitrii <[email protected]>
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
@derekmauro @Chekov2k @4kangjc and others