public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/105678] New: Undefined reference to stacktrace standard library
@ 2022-05-20 19:14 fcolecumberri at hotmail dot com
  2022-05-20 19:23 ` [Bug libstdc++/105678] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: fcolecumberri at hotmail dot com @ 2022-05-20 19:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105678

            Bug ID: 105678
           Summary: Undefined reference to stacktrace standard library
           Product: gcc
           Version: 12.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fcolecumberri at hotmail dot com
  Target Milestone: ---

I'm trying to test the stacktrace C++23 feature by creating the next program:

```c++
#include <stacktrace>

int main(){
        std::stacktrace::current();
        return 0;
}
```

using the next g++:

```
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/franky/Descargas/gcc-libs/src/gcc/configure
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-bootstrap
--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-linker-build-id --enable-lto
--enable-multilib --enable-plugin --enable-shared --enable-threads=posix
--disable-libssp --disable-libstdcxx-pch --disable-werror
--with-build-config=bootstrap-lto --enable-link-serialization=1
--enable-libstdcxx-backtrace=yes
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.1.0 (GCC)
```

Notice I added the `--enable-libstdcxx-backtrace=yes`

with this command:

```bash
g++ -std=gnu++2b cpp_file.cpp
```

And I get the next output:

```
/usr/bin/ld: a-cpp_file.o: in function `std::stacktrace_entry::_S_init()':
cpp_file.cpp:(.text._ZNSt16stacktrace_entry7_S_initEv[_ZNSt16stacktrace_entry7_S_initEv]+0x4a):
undefined reference to `__glibcxx_backtrace_create_state'
/usr/bin/ld: a-cpp_file.o: in function
`std::basic_stacktrace<std::allocator<std::stacktrace_entry>
>::current(std::allocator<std::stacktrace_entry> const&)':
cpp_file.cpp:(.text._ZNSt16basic_stacktraceISaISt16stacktrace_entryEE7currentERKS1_[_ZNSt16basic_stacktraceISaISt16stacktrace_entryEE7currentERKS1_]+0x70):
undefined reference to `__glibcxx_backtrace_simple'
collect2: error: ld returned 1 exit status
```

Maybe I am missing something, maybe the documentation is missing something, or
maybe this is still very experimental.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/105678] Undefined reference to stacktrace standard library
  2022-05-20 19:14 [Bug libstdc++/105678] New: Undefined reference to stacktrace standard library fcolecumberri at hotmail dot com
@ 2022-05-20 19:23 ` pinskia at gcc dot gnu.org
  2022-05-20 19:27 ` fcolecumberri at hotmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-20 19:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105678

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect it is missing from the linker script for versioning.
Using -static-libstdc++ should be a workaround.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/105678] Undefined reference to stacktrace standard library
  2022-05-20 19:14 [Bug libstdc++/105678] New: Undefined reference to stacktrace standard library fcolecumberri at hotmail dot com
  2022-05-20 19:23 ` [Bug libstdc++/105678] " pinskia at gcc dot gnu.org
@ 2022-05-20 19:27 ` fcolecumberri at hotmail dot com
  2022-05-23  8:51 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: fcolecumberri at hotmail dot com @ 2022-05-20 19:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105678

--- Comment #2 from Francisco <fcolecumberri at hotmail dot com> ---
just tried

```bash
 g++ -std=gnu++2b -static-libstdc++ cpp_file.cpp
```

but same result.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/105678] Undefined reference to stacktrace standard library
  2022-05-20 19:14 [Bug libstdc++/105678] New: Undefined reference to stacktrace standard library fcolecumberri at hotmail dot com
  2022-05-20 19:23 ` [Bug libstdc++/105678] " pinskia at gcc dot gnu.org
  2022-05-20 19:27 ` fcolecumberri at hotmail dot com
@ 2022-05-23  8:51 ` redi at gcc dot gnu.org
  2022-05-23  8:52 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2022-05-23  8:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105678

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |documentation
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-05-23
     Ever confirmed|0                           |1

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
As documented at https://gcc.gnu.org/gcc-12/changes.html#libstdcxx "requires
linking to an extra library"..

You need -lstdc++_libbacktrace although I haven't put that in the libstdc++
manual yet, and the name of that library might change (it should at least be
consistent with the --enable-libstdcxx-blah configure option to build it, and
currently they're not consistent, which was dumb of me).

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/105678] Undefined reference to stacktrace standard library
  2022-05-20 19:14 [Bug libstdc++/105678] New: Undefined reference to stacktrace standard library fcolecumberri at hotmail dot com
                   ` (2 preceding siblings ...)
  2022-05-23  8:51 ` redi at gcc dot gnu.org
@ 2022-05-23  8:52 ` redi at gcc dot gnu.org
  2022-05-23 19:47 ` fcolecumberri at hotmail dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2022-05-23  8:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105678

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Francisco from comment #0)
> Maybe I am missing something, 

Yes, you need to link to the extra lib that gets built by the extra configure
option you gave.

> maybe the documentation is missing something,

Yes, it is.

> or maybe this is still very experimental.

Yes, it is.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/105678] Undefined reference to stacktrace standard library
  2022-05-20 19:14 [Bug libstdc++/105678] New: Undefined reference to stacktrace standard library fcolecumberri at hotmail dot com
                   ` (3 preceding siblings ...)
  2022-05-23  8:52 ` redi at gcc dot gnu.org
@ 2022-05-23 19:47 ` fcolecumberri at hotmail dot com
  2022-05-23 19:50 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: fcolecumberri at hotmail dot com @ 2022-05-23 19:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105678

--- Comment #5 from Francisco <fcolecumberri at hotmail dot com> ---
I have no idea of what's happening, I have tried

```bash
g++ -std=gnu++2b -lstdc++_libbacktrace cpp_file.cpp
```

and

```bash
g++ -std=gnu++2b -L/usr/lib/libstdc++_libbacktrace.a cpp_file.cpp
```

(also tried with -static-libstdc++)

and I just got the same result.

However if I use `readelf` over /usr/lib/libstdc++_libbacktrace.a I can see the
symbols there.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/105678] Undefined reference to stacktrace standard library
  2022-05-20 19:14 [Bug libstdc++/105678] New: Undefined reference to stacktrace standard library fcolecumberri at hotmail dot com
                   ` (4 preceding siblings ...)
  2022-05-23 19:47 ` fcolecumberri at hotmail dot com
@ 2022-05-23 19:50 ` pinskia at gcc dot gnu.org
  2022-05-23 20:16 ` fcolecumberri at hotmail dot com
  2022-05-23 21:12 ` redi at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-23 19:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105678

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Try:
g++ -std=gnu++2b cpp_file.cpp -lstdc++_libbacktrace 

That is put the library after the source file. Static libraries are always
order depedendent.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/105678] Undefined reference to stacktrace standard library
  2022-05-20 19:14 [Bug libstdc++/105678] New: Undefined reference to stacktrace standard library fcolecumberri at hotmail dot com
                   ` (5 preceding siblings ...)
  2022-05-23 19:50 ` pinskia at gcc dot gnu.org
@ 2022-05-23 20:16 ` fcolecumberri at hotmail dot com
  2022-05-23 21:12 ` redi at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: fcolecumberri at hotmail dot com @ 2022-05-23 20:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105678

Francisco <fcolecumberri at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #7 from Francisco <fcolecumberri at hotmail dot com> ---
NOW IT COMPILE!!!

(And now I have learned a new thing about static linking)

Then it crashes on `segmentation fault (core dumped)`,

since I know this is still experimental, I assume this is on the expected
scope.

Thanks a lot.

I am going to mark it as resolved since the `Undefined reference` stuff is
resolved.

Thanks

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/105678] Undefined reference to stacktrace standard library
  2022-05-20 19:14 [Bug libstdc++/105678] New: Undefined reference to stacktrace standard library fcolecumberri at hotmail dot com
                   ` (6 preceding siblings ...)
  2022-05-23 20:16 ` fcolecumberri at hotmail dot com
@ 2022-05-23 21:12 ` redi at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2022-05-23 21:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105678

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
         Resolution|FIXED                       |---

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
http://c-faq.com/lib/libsearch.html is the reference I usually give.

I'm reopening this until I've updated the docs.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-05-23 21:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-20 19:14 [Bug libstdc++/105678] New: Undefined reference to stacktrace standard library fcolecumberri at hotmail dot com
2022-05-20 19:23 ` [Bug libstdc++/105678] " pinskia at gcc dot gnu.org
2022-05-20 19:27 ` fcolecumberri at hotmail dot com
2022-05-23  8:51 ` redi at gcc dot gnu.org
2022-05-23  8:52 ` redi at gcc dot gnu.org
2022-05-23 19:47 ` fcolecumberri at hotmail dot com
2022-05-23 19:50 ` pinskia at gcc dot gnu.org
2022-05-23 20:16 ` fcolecumberri at hotmail dot com
2022-05-23 21:12 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).