Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Undefined reference to std::char_traits<>
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
waffle87
n00b
n00b


Joined: 29 Mar 2022
Posts: 8

PostPosted: Sat Nov 30, 2024 5:40 pm    Post subject: Undefined reference to std::char_traits<> Reply with quote

Hello. I have been having trouble emerging any packages that contain the following C++ code:
Code:
std::char_traits<unsigned char>

There are three possible outcomes I have found:
1. Building under GCC usually compiles successfully, but fails with linking errors.
2. Building under GCC "succeeds", but software consistently fails to run and generally just seg faults.
2. Building under Clang consistently produces the following errors.

What is puzzling is I am able to manually build these packages' code without error using both GCC and Clang. So far, I have attempted re-emerging sys-libs/libcxx and sys-libs/libcxxabi, but no dice. Here is the output of emerge --info: https://dpaste.com/DEY4EPSJ5

Here is an excerpt from trying to build app-text/doxygen with Clang:

Code:

/usr/include/c++/v1/string:820:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>'
  820 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
/var/tmp/portage/app-text/doxygen-1.12.0/work/doxygen-1.12.0/src/qcstring.h:120:21: note: in instantiation of template class 'std::basic_string<unsigned char>' requested here
  120 |       m_rep.resize(s.size());
      |                     ^
/usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^


Cheers
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3939

PostPosted: Sat Nov 30, 2024 6:02 pm    Post subject: Reply with quote

Likely same as Bug report.

Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Back to top
View user's profile Send private message
waffle87
n00b
n00b


Joined: 29 Mar 2022
Posts: 8

PostPosted: Sat Nov 30, 2024 6:27 pm    Post subject: Reply with quote

Ah thanks for the speedy response. So I suppose this is LLVM related bug — is there any reason GCC fails to build this? Is it more or less the same deprecation?

For example trying to build gui-wm/hyprland under GCC:
Code:

g++  -o hyprctl/hyprctl hyprctl/hyprctl.p/main.cpp.o -Wl,--as-needed -Wl,--no-undefined -march=znver2 -O2 -pipe -Wl,--as-needed /usr/lib64/libhyprutils.so
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: hyprctl/hyprctl.p/main.cpp.o: in function `main':
main.cpp:(.text.startup+0x6e7): undefined reference to `Hyprutils::String::isNumber(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: main.cpp:(.text.startup+0xa11): undefined reference to `Hyprutils::String::isNumber(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
collect2: error: ld returned 1 exit status
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22753

PostPosted: Sat Nov 30, 2024 7:03 pm    Post subject: Reply with quote

This does not appear to be a deprecation issue. It looks like the LLVM headers are just wrong. It forward declares a symbol, then tries to use it without first defining it.

The gcc problem is different. Is /usr/lib64/libhyprutils.so built with gcc's standard library in the shown output? The shown symbols depend on standard library names. Using a gcc standard library name on one side and a clang standard library name on the other side is fragile at best.
Back to top
View user's profile Send private message
waffle87
n00b
n00b


Joined: 29 Mar 2022
Posts: 8

PostPosted: Sat Nov 30, 2024 7:32 pm    Post subject: Reply with quote

I'm quite sure /usr/lib64/libhyprutils.so has been built purely with GCC: (please let me know if there's a better way to confirm)
Code:

$ objdump -x /usr/lib64/libhyprutils.so.0.2.6

/usr/lib64/libhyprutils.so.0.2.6:     file format elf64-x86-64
/usr/lib64/libhyprutils.so.0.2.6
architecture: i386:x86-64, flags 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
start address 0x0000000000000000

...

Version References:
  required from libgcc_s.so.1:
    0x09275f60 0x00 10 GCC_4.3.0
    0x0b792650 0x00 07 GCC_3.0
  required from libm.so.6:
    0x09691a75 0x00 04 GLIBC_2.2.5
  required from libstdc++.so.6:
    0x0297f870 0x00 17 GLIBCXX_3.4.20
    0x0bafd179 0x00 15 CXXABI_1.3.9
    0x0297f871 0x00 13 GLIBCXX_3.4.21
    0x0297f841 0x00 12 GLIBCXX_3.4.31
    0x0297f868 0x00 11 GLIBCXX_3.4.18
    0x056bafd3 0x00 09 CXXABI_1.3
    0x0297f864 0x00 08 GLIBCXX_3.4.14
    0x0297f876 0x00 06 GLIBCXX_3.4.26
    0x08922974 0x00 05 GLIBCXX_3.4
    0x0297f879 0x00 03 GLIBCXX_3.4.29
  required from libc.so.6:
    0x0d696914 0x00 16 GLIBC_2.4
    0x06969194 0x00 14 GLIBC_2.14
    0x09691a75 0x00 02 GLIBC_2.2.5


I have also specified in /etc/portage/package.env to build both hyprland and hyprutils with GCC tools:
Code:

gui-wm/hyprland compiler-gcc
gui-libs/hyprutils compiler-gcc
Back to top
View user's profile Send private message
waffle87
n00b
n00b


Joined: 29 Mar 2022
Posts: 8

PostPosted: Sat Nov 30, 2024 8:15 pm    Post subject: Reply with quote

Hyprland compiles successfully under Clang (somehow), but fails to start using dbus-run-session Hyprland due to what appears to be the same original errors:

(I've ensured all libraries and the like have been built with the same compiler)
Code:

Backtrace:
   # | Hyprland(_Z12getBacktracev+0x67) [0x5563ec534d57]
      getBacktrace()
      ??:0
   #1 | Hyprland(_ZN13CrashReporter18createAndSaveCrashEi+0x1cff) [0x5563ec49221f]
      CrashReporter::createAndSaveCrash(int)
      ??:0
   #2 | Hyprland(_Z25handleUnrecoverableSignali+0x60) [0x5563ec3e85f0]
      handleUnrecoverableSignal(int)
      ??:0
   #3 | /usr/lib64/libc.so.6(+0x3ccd0) [0x7f20ecebdcd0]
      ??
      ??:0
   #4 | /usr/lib64/libaquamarine.so.4(_ZN10Aquamarine17CDRMAtomicRequest6commitEj+0x5b) [0x7f20edb1dfdb]
      ??
      ??:0
   #5 | /usr/lib64/libaquamarine.so.4(_ZN10Aquamarine14CDRMAtomicImpl5resetEv+0x273) [0x7f20edb1fe23]
      ??
      ??:0
   #6 | /usr/lib64/libaquamarine.so.4(_ZN10Aquamarine11CDRMBackend5startEv+0x18) [0x7f20edae02d8]
      ??
      ??:0
   #7 | /usr/lib64/libaquamarine.so.4(_ZN10Aquamarine8CBackend5startEv+0xeb) [0x7f20edaa806b]
      ??
      ??:0
   #8 | Hyprland(_ZN11CCompositor10initServerENSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEi+0x732) [0x5563ec3eb042]
      CCompositor::initServer(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, int)
      ??:0
   #9 | Hyprland(main+0xc27) [0x5563ec577427]
      main
      ??:0
   #1 | /usr/lib64/libc.so.6(+0x263ee) [0x7f20ecea73ee]
      ??
      ??:0
   #11 | /usr/lib64/libc.so.6(__libc_start_main+0x89) [0x7f20ecea74a9]
      ??
      ??:0
   #12 | Hyprland(_start+0x25) [0x5563ec397ee5]
      _start
      ??:0
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum