Bug 2220896 - undefined reference for libstdc++ symbol when using GCC toolset 11
Summary: undefined reference for libstdc++ symbol when using GCC toolset 11
Keywords:
Status: VERIFIED
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: gcc
Version: 8.6
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Marek Polacek
QA Contact: Václav Kadlčík
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-07-06 13:05 UTC by Paulo Andrade
Modified: 2023-07-19 08:18 UTC (History)
7 users (show)

Fixed In Version: gcc-toolset-11-gcc-11.2.1-9.2.el8_6
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 105671 0 P2 RESOLVED [11 Regression] Unexplained "undefined reference" error 2023-07-06 13:05:28 UTC
Red Hat Issue Tracker RHELPLAN-161685 0 None None None 2023-07-06 13:06:03 UTC

Description Paulo Andrade 2023-07-06 13:05:29 UTC
User is experiencing the upstream issue.

$ scl enable gcc-toolset-11 bash
$ tar jxf boost_1_79_0.tar.bz2
$ cd boost_1_79_0
$ ./bootstrap.sh
...

$ cat ../user-config.jam
using gcc : : g++ : <cxxflags>"-flto" ;
$ ./b2 --with-program_options link=static --user-config=$PWD/../user-config.jam
...

$ cd ..
$ cat test.cpp
#include <boost/asio/spawn.hpp>
#include <boost/program_options.hpp>
#include <iostream>

int
main()
{
    auto generic = boost::program_options::options_description{};
    std::cout << generic;
}

$  g++ -o /dev/null test.cpp -Iboost_1_79_0 boost_1_79_0/stage/lib/libboost_program_options.a -Os -flto
/opt/rh/gcc-toolset-11/root/usr/bin/ld: /tmp/ccx7yv55.ltrans0.ltrans.o: in function `boost::program_options::options_description::get_option_column_width() const':
<artificial>:(.text+0x2449): undefined reference to `std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::_M_high_mark() const'
/opt/rh/gcc-toolset-11/root/usr/bin/ld: /tmp/ccx7yv55.ltrans0.ltrans.o: in function `boost::program_options::(anonymous namespace)::format_one(std::ostream&, boost::program_options::option_description const&, unsigned int, unsigned int) [clone .constprop.0]':
<artificial>:(.text+0x2822): undefined reference to `std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::_M_high_mark() const'
/opt/rh/gcc-toolset-11/root/usr/bin/ld: <artificial>:(.text+0x28bf): undefined reference to `std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::_M_high_mark() const'
/opt/rh/gcc-toolset-11/root/usr/bin/ld: <artificial>:(.text+0x376f): undefined reference to `std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::_M_high_mark() const'
collect2: error: ld returned 1 exit status


  Manually adding 
  I can reproduce the issue, and adding https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=libstdc%2B%2B-v3/include/std/sstream;h=bc7d636e702ea4352a182cc521fd32a06ca31b6f;hp=bb25c2c69a94f8fc325289ab7267e91c5b846121;hb=d47c4f0f1da0aa84097878b82e100d08deb6d950;hpb=6666ca1ab44ad8a61e2b916cf4173fe452b78ed6
to /opt/rh/gcc-toolset-11/root/usr/include/c++/11/sstream corrects the problem.

Comment 1 Marek Polacek 2023-07-06 15:51:37 UTC
The fix is in 11.4 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105671#c9 so I think it makes sense to backport it.


Note You need to log in before you can comment on or make changes to this bug.