Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 1cf6b108882669f1b20c18fb5f2d6dff0fc83296 Mon Sep 17 00:00:00 2001
From eadfee17e7d3a1c1bb2a0ff8585772b40331ebd7 Mon Sep 17 00:00:00 2001
From: Jan Tojnar <jtojnar@gmail.com>
Date: Sat, 24 Dec 2022 15:31:51 +0100
Subject: [PATCH 1/4] libbacktrace: avoid libtool wrapping tests
Expand All @@ -21,7 +21,7 @@ https://autotools.info/libtool/wrappers.html
1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index c53cbae..6eab991 100644
index 3d67909..06ccf3f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -107,6 +107,8 @@ check_DATA =
Expand Down Expand Up @@ -90,7 +90,7 @@ index c53cbae..6eab991 100644
unittest_LDADD = libbacktrace.la

BUILDTESTS += unittest
@@ -253,7 +263,7 @@ if HAVE_OBJCOPY_DEBUGLINK
@@ -254,7 +264,7 @@ if HAVE_OBJCOPY_DEBUGLINK

b2test_SOURCES = $(btest_SOURCES)
b2test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
Expand All @@ -99,7 +99,7 @@ index c53cbae..6eab991 100644
b2test_LDADD = libbacktrace_elf_for_test.la

check_PROGRAMS += b2test
@@ -263,7 +273,7 @@ if HAVE_DWZ
@@ -264,7 +274,7 @@ if HAVE_DWZ

b3test_SOURCES = $(btest_SOURCES)
b3test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
Expand All @@ -108,55 +108,55 @@ index c53cbae..6eab991 100644
b3test_LDADD = libbacktrace_elf_for_test.la

check_PROGRAMS += b3test
@@ -276,6 +286,7 @@ endif HAVE_ELF
@@ -278,6 +288,7 @@ endif HAVE_ELF

btest_SOURCES = btest.c testlib.c
btest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O
+btest_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
btest_LDADD = libbacktrace.la

BUILDTESTS += btest
@@ -330,6 +341,7 @@ endif HAVE_DWZ
@@ -332,6 +343,7 @@ endif HAVE_DWZ

stest_SOURCES = stest.c
stest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+stest_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
stest_LDADD = libbacktrace.la

BUILDTESTS += stest
@@ -352,6 +364,7 @@ if HAVE_ELF
@@ -354,6 +366,7 @@ if HAVE_ELF

ztest_SOURCES = ztest.c testlib.c
ztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
+ztest_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
ztest_LDADD = libbacktrace.la
ztest_alloc_LDADD = libbacktrace_alloc.la

@@ -371,6 +384,7 @@ BUILDTESTS += ztest_alloc
@@ -373,6 +386,7 @@ BUILDTESTS += ztest_alloc

zstdtest_SOURCES = zstdtest.c testlib.c
zstdtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
+zstdtest_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
zstdtest_LDADD = libbacktrace.la
zstdtest_alloc_LDADD = libbacktrace_alloc.la

@@ -392,6 +406,7 @@ endif HAVE_ELF
@@ -394,6 +408,7 @@ endif HAVE_ELF

edtest_SOURCES = edtest.c edtest2_build.c testlib.c
edtest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+edtest_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
edtest_LDADD = libbacktrace.la

BUILDTESTS += edtest
@@ -422,6 +437,7 @@ BUILDTESTS += ttest
@@ -424,6 +439,7 @@ BUILDTESTS += ttest

ttest_SOURCES = ttest.c testlib.c
ttest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -pthread
+ttest_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
ttest_LDADD = libbacktrace.la

if USE_DSYMUTIL
@@ -460,12 +476,12 @@ if HAVE_COMPRESSED_DEBUG
@@ -472,12 +488,12 @@ if HAVE_COMPRESSED_DEBUG

ctestg_SOURCES = btest.c testlib.c
ctestg_CFLAGS = $(libbacktrace_TEST_CFLAGS)
Expand All @@ -171,7 +171,7 @@ index c53cbae..6eab991 100644
ctesta_LDADD = libbacktrace.la

BUILDTESTS += ctestg ctesta
@@ -474,7 +490,7 @@ if HAVE_COMPRESSED_DEBUG_ZSTD
@@ -486,7 +502,7 @@ if HAVE_COMPRESSED_DEBUG_ZSTD

ctestzstd_SOURCES = btest.c testlib.c
ctestzstd_CFLAGS = $(libbacktrace_TEST_CFLAGS)
Expand All @@ -180,15 +180,15 @@ index c53cbae..6eab991 100644
ctestzstd_LDADD = libbacktrace.la

BUILDTESTS += ctestzstd
@@ -521,6 +537,7 @@ endif
@@ -533,6 +549,7 @@ endif

mtest_SOURCES = mtest.c testlib.c
mtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O
+mtest_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
mtest_LDADD = libbacktrace.la

BUILDTESTS += mtest
@@ -553,6 +570,7 @@ if HAVE_ELF
@@ -565,6 +582,7 @@ if HAVE_ELF

xztest_SOURCES = xztest.c testlib.c
xztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
Expand All @@ -197,5 +197,5 @@ index c53cbae..6eab991 100644

xztest_alloc_SOURCES = $(xztest_SOURCES)
--
2.38.1
2.43.1

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From f409ee343fe6cdc059bb411746f27a515aec66a8 Mon Sep 17 00:00:00 2001
From 2ceaa9bc8a9a0c8a02806a92e19bd21b3fccf3a0 Mon Sep 17 00:00:00 2001
From: Jan Tojnar <jtojnar@gmail.com>
Date: Sat, 24 Dec 2022 16:46:18 +0100
Subject: [PATCH 2/4] libbacktrace: Allow configuring debug dir
Expand All @@ -14,13 +14,13 @@ the path can be changed. The same flag is supported by gdb:

https://github.com/bminor/binutils-gdb/blob/095f84c7e3cf85cd68c657c46b80be078f336bc9/gdb/configure.ac#L113-L115
---
Makefile.am | 11 ++++++-----
Makefile.am | 13 +++++++------
configure.ac | 8 ++++++++
elf.c | 4 ++--
3 files changed, 16 insertions(+), 7 deletions(-)
3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 6eab991..da443c1 100644
index 06ccf3f..6304faa 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,7 +33,8 @@ ACLOCAL_AMFLAGS = -I config
Expand Down Expand Up @@ -53,7 +53,7 @@ index 6eab991..da443c1 100644
$(SED) "s%$$SEARCH%$$REPLACE%" \
$< \
> $@.tmp
@@ -468,7 +469,7 @@ endif HAVE_OBJCOPY_DEBUGLINK
@@ -474,13 +475,13 @@ endif HAVE_OBJCOPY_DEBUGLINK

%_buildid: %
./install-debuginfo-for-buildid.sh \
Expand All @@ -62,8 +62,15 @@ index 6eab991..da443c1 100644
$<
$(OBJCOPY) --strip-debug $< $@

%_buildidfull: %
./install-debuginfo-for-buildid.sh \
- "$(TEST_BUILD_ID_DIR)" \
+ "$(TEST_DEBUG_DIR)/.build-id" \
$<
$(OBJCOPY) --strip-all $< $@

diff --git a/configure.ac b/configure.ac
index 7f122cb..bb590ab 100644
index 69304ea..aeb2ee9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,6 +67,14 @@ AM_MAINTAINER_MODE
Expand All @@ -82,7 +89,7 @@ index 7f122cb..bb590ab 100644
# the wrong, non-multilib-adjusted value will be used in multilibs.
# As a side effect, we have to subst CFLAGS ourselves.
diff --git a/elf.c b/elf.c
index e82ecc5..8b1189c 100644
index 3ef07bb..21fbe4f 100644
--- a/elf.c
+++ b/elf.c
@@ -856,7 +856,7 @@ elf_readlink (struct backtrace_state *state, const char *filename,
Expand All @@ -104,5 +111,5 @@ index e82ecc5..8b1189c 100644
const char * const suffix = ".debug";
const size_t suffix_len = strlen (suffix);
--
2.38.1
2.43.1

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From de122af5382d8017cae63bdee946206c6c6c23ab Mon Sep 17 00:00:00 2001
From 47c3503938c863d55c835463d8815b5fa4ab8326 Mon Sep 17 00:00:00 2001
From: Jan Tojnar <jtojnar@gmail.com>
Date: Sat, 24 Dec 2022 20:19:27 +0100
Subject: [PATCH 3/4] libbacktrace: Support multiple build id directories
Expand All @@ -16,7 +16,7 @@ to debug data installed using distribution’s package manager.
1 file changed, 36 insertions(+), 21 deletions(-)

diff --git a/elf.c b/elf.c
index 8b1189c..65c647a 100644
index 21fbe4f..ccffa95 100644
--- a/elf.c
+++ b/elf.c
@@ -865,12 +865,12 @@ elf_readlink (struct backtrace_state *state, const char *filename,
Expand All @@ -34,7 +34,7 @@ index 8b1189c..65c647a 100644
const size_t prefix_len = strlen (prefix);
const char * const suffix = ".debug";
const size_t suffix_len = strlen (suffix);
@@ -6936,27 +6936,42 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
@@ -6947,27 +6947,42 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
if (buildid_data != NULL)
{
int d;
Expand All @@ -53,9 +53,9 @@ index 8b1189c..65c647a 100644
- elf_release_view (state, &debuglink_view, error_callback, data);
- if (debugaltlink_view_valid)
- elf_release_view (state, &debugaltlink_view, error_callback, data);
- ret = elf_add (state, "", d, NULL, 0, base_address, error_callback,
- data, fileline_fn, found_sym, found_dwarf, NULL, 0,
- 1, NULL, 0);
- ret = elf_add (state, "", d, NULL, 0, base_address, opd,
- error_callback, data, fileline_fn, found_sym,
- found_dwarf, NULL, 0, 1, NULL, 0);
- if (ret < 0)
- backtrace_close (d, error_callback, data);
- else if (descriptor >= 0)
Expand All @@ -81,9 +81,9 @@ index 8b1189c..65c647a 100644
+ elf_release_view (state, &debuglink_view, error_callback, data);
+ if (debugaltlink_view_valid)
+ elf_release_view (state, &debugaltlink_view, error_callback, data);
+ ret = elf_add (state, "", d, NULL, 0, base_address, error_callback,
+ data, fileline_fn, found_sym, found_dwarf, NULL, 0,
+ 1, NULL, 0);
+ ret = elf_add (state, "", d, NULL, 0, base_address, opd,
+ error_callback, data, fileline_fn, found_sym,
+ found_dwarf, NULL, 0, 1, NULL, 0);
+ if (ret < 0)
+ backtrace_close (d, error_callback, data);
+ else if (descriptor >= 0)
Expand All @@ -97,5 +97,5 @@ index 8b1189c..65c647a 100644

if (buildid_view_valid)
--
2.38.1
2.43.1

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From a3b7510e4c9e7201a4301f2a45d8569b06354607 Mon Sep 17 00:00:00 2001
From 884ef7c843be906d62e4240c2a0e885dcd5a5726 Mon Sep 17 00:00:00 2001
From: Jan Tojnar <jtojnar@gmail.com>
Date: Sat, 24 Dec 2022 20:30:22 +0100
Subject: [PATCH 4/4] libbacktrace: Support NIX_DEBUG_INFO_DIRS environment
Expand All @@ -13,10 +13,10 @@ Let’s make debug data lookup work on NixOS just like in gdb.
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/elf.c b/elf.c
index 65c647a..5c8abc0 100644
index ccffa95..e86950d 100644
--- a/elf.c
+++ b/elf.c
@@ -6935,11 +6935,18 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
@@ -6946,11 +6946,18 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,

if (buildid_data != NULL)
{
Expand All @@ -38,5 +38,5 @@ index 65c647a..5c8abc0 100644
debug_dir = strtok (debug_directories, ":");
while (debug_dir != NULL)
--
2.38.1
2.43.1

10 changes: 3 additions & 7 deletions pkgs/development/libraries/libbacktrace/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

stdenv.mkDerivation {
pname = "libbacktrace";
version = "unstable-2023-11-30";
version = "0-unstable-2024-03-02";

src = fetchFromGitHub {
owner = "ianlancetaylor";
repo = "libbacktrace";
rev = "14818b7783eeb9a56c3f0fca78cefd3143f8c5f6";
sha256 = "DQZQsqzeQ/0v87bfqs6sXqS2M5Tunc1OydTWRSB3PCw=";
rev = "28824f2cc9069e3fdc39d3702acdf753e35c41b4";
sha256 = "1k1O1GT22hZAWPF8NYP0y4qe+e3pGfzT9Mz2TH+H/v4=";
};

patches = [
Expand All @@ -41,10 +41,6 @@ stdenv.mkDerivation {
(lib.enableFeature enableShared "shared")
];

# Workaround upstream testsuite failure in multithreaded setup:
# https://github.com/ianlancetaylor/libbacktrace/issues/118#issuecomment-1974850483
env.XZ_OPT = "--threads=1";

doCheck = stdenv.isLinux && !stdenv.hostPlatform.isMusl;

passthru = {
Expand Down