The GCC configured with --enable-default-pie gives: === libstdc++ tests === Running target unix FAIL: 19_diagnostics/stacktrace/entry.cc execution test FAIL: 19_diagnostics/stacktrace/stacktrace.cc execution test libstdc++-v3/testsuite/19_diagnostics/stacktrace/entry.cc:39: void test_members(): Assertion 'e1.source_line() == (__LINE__ - 5)' failed. libstdc++-v3/testsuite/19_diagnostics/stacktrace/stacktrace.cc:132: void test_assign(): Assertion 's0.at(0).source_line() == (__LINE__ - 4)' failed. In both cases source_line() methods return 0. Also, the -fno-pie option cannot be used when linking these tescases: /usr/bin/ld: /tmp/ccv2BTff.o: relocation R_X86_64_32 against symbol `_ZNSt16stacktrace_entry14_S_err_handlerEPvPKci' can not be used when making a PIE object; recompile with -fPIE
Hmm, is libbacktrace not working with PIE applications ...
(In reply to Rimvydas (RJ) from comment #0) > The GCC configured with --enable-default-pie gives: > > === libstdc++ tests === > > Running target unix > FAIL: 19_diagnostics/stacktrace/entry.cc execution test > FAIL: 19_diagnostics/stacktrace/stacktrace.cc execution test > > libstdc++-v3/testsuite/19_diagnostics/stacktrace/entry.cc:39: void > test_members(): Assertion 'e1.source_line() == (__LINE__ - 5)' failed. > libstdc++-v3/testsuite/19_diagnostics/stacktrace/stacktrace.cc:132: void > test_assign(): Assertion 's0.at(0).source_line() == (__LINE__ - 4)' failed. > > In both cases source_line() methods return 0. > > Also, the -fno-pie option cannot be used when linking these tescases: > /usr/bin/ld: /tmp/ccv2BTff.o: relocation R_X86_64_32 against symbol > `_ZNSt16stacktrace_entry14_S_err_handlerEPvPKci' can not be used when making > a PIE object; recompile with -fPIE You need to use both -no-pie and -fno-pie. -fno-pie only tells the compiler not to emit code for PIE, -no-pie tells the linker not to link the code for PIE.
Confirm the issue anyway, I saw it several times recently.
*** Bug 112322 has been marked as a duplicate of this bug. ***
Maybe related to PR112263 but I'm not sure.
(In reply to Xi Ruoyao from comment #5) > Maybe related to PR112263 but I'm not sure. Can confirm that with patch posted at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112263#c7 the stacktrace.cc testsuite testcases (for both -std=gnu++23 and -std=gnu++26) now able to pass execution tests when gcc is built with ./configure --enable-bootstrap --enable-default-pie --- libstdc++-v3/src/libbacktrace/Makefile.orig +++ libstdc++-v3/src/libbacktrace/Makefile @@ -232,3 +232,3 @@ AWK = gawk -BACKTRACE_CPPFLAGS = -DHAVE_ATOMIC_FUNCTIONS=1 -DHAVE_SYNC_FUNCTIONS=1 -DHAVE_FCNTL=1 -DBACKTRACE_ELF_SIZE=64 +BACKTRACE_CPPFLAGS = -D_GNU_SOURCE -DHAVE_ATOMIC_FUNCTIONS=1 -DHAVE_SYNC_FUNCTIONS=1 -DHAVE_DL_ITERATE_PHDR=1 -DHAVE_FCNTL=1 -DBACKTRACE_ELF_SIZE=64 BACKTRACE_SUPPORTED = 1
Great, let's close it as a dup then. *** This bug has been marked as a duplicate of bug 112263 ***
The master branch has been updated by Ian Lance Taylor <ian@gcc.gnu.org>: https://gcc.gnu.org/g:2b64e4a54042fb8f75f1c1429eb1c13afb9fa118 commit r14-5173-g2b64e4a54042fb8f75f1c1429eb1c13afb9fa118 Author: Ian Lance Taylor <iant@golang.org> Date: Mon Nov 6 15:09:18 2023 -0800 libstdc++: use -D_GNU_SOURCE when building libbacktrace PR libbacktrace/111315 PR libbacktrace/112263 * acinclude.m4: Set -D_GNU_SOURCE in BACKTRACE_CPPFLAGS and when grepping link.h for dl_iterate_phdr. * configure: Regenerate.
The releases/gcc-13 branch has been updated by Ian Lance Taylor <ian@gcc.gnu.org>: https://gcc.gnu.org/g:8484e3479fe80aebdc4a2406473aef906055b4f8 commit r13-8006-g8484e3479fe80aebdc4a2406473aef906055b4f8 Author: Ian Lance Taylor <iant@golang.org> Date: Mon Nov 6 15:12:05 2023 -0800 libstdc++: use -D_GNU_SOURCE when building libbacktrace PR libbacktrace/111315 PR libbacktrace/112263 * acinclude.m4: Set -D_GNU_SOURCE in BACKTRACE_CPPFLAGS and when grepping link.h for dl_iterate_phdr. * configure: Regenerate.
The releases/gcc-12 branch has been updated by Ian Lance Taylor <ian@gcc.gnu.org>: https://gcc.gnu.org/g:56909c9d4842925749cd9e061ef4afa0501f85e9 commit r12-9961-g56909c9d4842925749cd9e061ef4afa0501f85e9 Author: Ian Lance Taylor <iant@golang.org> Date: Mon Nov 6 15:12:41 2023 -0800 libstdc++: use -D_GNU_SOURCE when building libbacktrace PR libbacktrace/111315 PR libbacktrace/112263 * acinclude.m4: Set -D_GNU_SOURCE in BACKTRACE_CPPFLAGS and when grepping link.h for dl_iterate_phdr. * configure: Regenerate.