push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,201 @@
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
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When `--enable-shared` is used, libtool will produce shell scripts
instead of programs, preventing separate debug info from being generated:
objcopy --only-keep-debug btest btest_gnudebuglink.debug
objcopy: btest: file format not recognized
make[2]: *** [Makefile:2615: btest_gnudebuglink] Error 1
Lets make it properly set rpath with `-no-install` flag,
so that wrappers are not needed, as mentioned on
https://autotools.info/libtool/wrappers.html
---
Makefile.am | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 3d67909..06ccf3f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -107,6 +107,8 @@ check_DATA =
# Flags to use when compiling test programs.
libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
+libbacktrace_TEST_LDFLAGS = -no-install
+
if USE_DSYMUTIL
%.dSYM: %
@@ -171,48 +173,56 @@ xcoff_%.c: xcoff.c
test_elf_32_SOURCES = test_format.c testlib.c
test_elf_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_elf_32_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
test_elf_32_LDADD = libbacktrace_noformat.la elf_32.lo
BUILDTESTS += test_elf_32
test_elf_64_SOURCES = test_format.c testlib.c
test_elf_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_elf_64_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
test_elf_64_LDADD = libbacktrace_noformat.la elf_64.lo
BUILDTESTS += test_elf_64
test_macho_SOURCES = test_format.c testlib.c
test_macho_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_macho_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
test_macho_LDADD = libbacktrace_noformat.la macho.lo
BUILDTESTS += test_macho
test_xcoff_32_SOURCES = test_format.c testlib.c
test_xcoff_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_xcoff_32_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo
BUILDTESTS += test_xcoff_32
test_xcoff_64_SOURCES = test_format.c testlib.c
test_xcoff_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_xcoff_64_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
test_xcoff_64_LDADD = libbacktrace_noformat.la xcoff_64.lo
BUILDTESTS += test_xcoff_64
test_pecoff_SOURCES = test_format.c testlib.c
test_pecoff_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_pecoff_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
test_pecoff_LDADD = libbacktrace_noformat.la pecoff.lo
BUILDTESTS += test_pecoff
test_unknown_SOURCES = test_format.c testlib.c
test_unknown_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_unknown_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
test_unknown_LDADD = libbacktrace_noformat.la unknown.lo
BUILDTESTS += test_unknown
unittest_SOURCES = unittest.c testlib.c
unittest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+unittest_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
unittest_LDADD = libbacktrace.la
BUILDTESTS += unittest
@@ -254,7 +264,7 @@ if HAVE_OBJCOPY_DEBUGLINK
b2test_SOURCES = $(btest_SOURCES)
b2test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-b2test_LDFLAGS = -Wl,--build-id
+b2test_LDFLAGS = -Wl,--build-id $(libbacktrace_TEST_LDFLAGS)
b2test_LDADD = libbacktrace_elf_for_test.la
check_PROGRAMS += b2test
@@ -264,7 +274,7 @@ if HAVE_DWZ
b3test_SOURCES = $(btest_SOURCES)
b3test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-b3test_LDFLAGS = -Wl,--build-id
+b3test_LDFLAGS = -Wl,--build-id $(libbacktrace_TEST_LDFLAGS)
b3test_LDADD = libbacktrace_elf_for_test.la
check_PROGRAMS += b3test
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -472,12 +488,12 @@ if HAVE_COMPRESSED_DEBUG
ctestg_SOURCES = btest.c testlib.c
ctestg_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu
+ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu $(libbacktrace_TEST_LDFLAGS)
ctestg_LDADD = libbacktrace.la
ctesta_SOURCES = btest.c testlib.c
ctesta_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi
+ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi $(libbacktrace_TEST_LDFLAGS)
ctesta_LDADD = libbacktrace.la
BUILDTESTS += ctestg ctesta
@@ -486,7 +502,7 @@ if HAVE_COMPRESSED_DEBUG_ZSTD
ctestzstd_SOURCES = btest.c testlib.c
ctestzstd_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-ctestzstd_LDFLAGS = -Wl,--compress-debug-sections=zstd
+ctestzstd_LDFLAGS = -Wl,--compress-debug-sections=zstd $(libbacktrace_TEST_LDFLAGS)
ctestzstd_LDADD = libbacktrace.la
BUILDTESTS += ctestzstd
@@ -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
@@ -565,6 +582,7 @@ if HAVE_ELF
xztest_SOURCES = xztest.c testlib.c
xztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
+xztest_LDFLAGS = $(libbacktrace_TEST_LDFLAGS)
xztest_LDADD = libbacktrace.la
xztest_alloc_SOURCES = $(xztest_SOURCES)
--
2.43.1

View File

@@ -0,0 +1,115 @@
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
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
On platforms that do not use FHS like NixOS or GNU Guix,
the build-id directories are not under `/usr/lib/debug`.
Lets add `--with-separate-debug-dir` configure flag so that
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 | 13 +++++++------
configure.ac | 8 ++++++++
elf.c | 4 ++--
3 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 06ccf3f..6304faa 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,7 +33,8 @@ ACLOCAL_AMFLAGS = -I config
AM_CPPFLAGS =
-AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG)
+AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG) \
+ -DSYSTEM_DEBUG_DIR=\"$(SEPARATE_DEBUG_DIR)\"
include_HEADERS = backtrace.h backtrace-supported.h
@@ -134,7 +135,7 @@ libbacktrace_noformat_la_DEPENDENCIES = $(libbacktrace_noformat_la_LIBADD)
if HAVE_ELF
if HAVE_OBJCOPY_DEBUGLINK
-TEST_BUILD_ID_DIR=$(abs_builddir)/usr/lib/debug/.build-id/
+TEST_DEBUG_DIR=$(abs_builddir)/usr/lib/debug
check_LTLIBRARIES += libbacktrace_elf_for_test.la
@@ -143,8 +144,8 @@ libbacktrace_elf_for_test_la_LIBADD = $(BACKTRACE_FILE) elf_for_test.lo \
$(VIEW_FILE) $(ALLOC_FILE)
elf_for_test.c: elf.c
- SEARCH='^#define SYSTEM_BUILD_ID_DIR.*$$'; \
- REPLACE="#define SYSTEM_BUILD_ID_DIR \"$(TEST_BUILD_ID_DIR)\""; \
+ SEARCH='^#define BUILD_ID_DIR.*$$'; \
+ REPLACE='\0\n#undef SYSTEM_DEBUG_DIR\n#define SYSTEM_DEBUG_DIR "$(TEST_DEBUG_DIR)"'; \
$(SED) "s%$$SEARCH%$$REPLACE%" \
$< \
> $@.tmp
@@ -474,13 +475,13 @@ endif HAVE_OBJCOPY_DEBUGLINK
%_buildid: %
./install-debuginfo-for-buildid.sh \
- "$(TEST_BUILD_ID_DIR)" \
+ "$(TEST_DEBUG_DIR)/.build-id" \
$<
$(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 69304ea..aeb2ee9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,6 +67,14 @@ AM_MAINTAINER_MODE
AC_ARG_WITH(target-subdir,
[ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
+AC_ARG_WITH(separate-debug-dir,
+[ --with-separate-debug-dir=DEBUGDIR Look for global separate debug info in this path @<:@LIBDIR/debug@:>@],
+[separate_debug_dir=$withval],
+[separate_debug_dir=$libdir/debug])
+
+SEPARATE_DEBUG_DIR=$separate_debug_dir
+AC_SUBST(SEPARATE_DEBUG_DIR)
+
# We must force CC to /not/ be precious variables; otherwise
# 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 3ef07bb..21fbe4f 100644
--- a/elf.c
+++ b/elf.c
@@ -856,7 +856,7 @@ elf_readlink (struct backtrace_state *state, const char *filename,
}
}
-#define SYSTEM_BUILD_ID_DIR "/usr/lib/debug/.build-id/"
+#define BUILD_ID_DIR "/.build-id/"
/* Open a separate debug info file, using the build ID to find it.
Returns an open file descriptor, or -1.
@@ -870,7 +870,7 @@ elf_open_debugfile_by_buildid (struct backtrace_state *state,
backtrace_error_callback error_callback,
void *data)
{
- const char * const prefix = SYSTEM_BUILD_ID_DIR;
+ const char * const prefix = SYSTEM_DEBUG_DIR BUILD_ID_DIR;
const size_t prefix_len = strlen (prefix);
const char * const suffix = ".debug";
const size_t suffix_len = strlen (suffix);
--
2.43.1

View File

@@ -0,0 +1,101 @@
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
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
gdb supports multiple debug directories separated by colons:
https://github.com/bminor/binutils-gdb/blob/fcbfb25dcca625a7f999ec51d48b6fc3a32123c3/gdb/build-id.c#L136-L142
This is useful for example when using dwarffs in addition
to debug data installed using distributions package manager.
---
elf.c | 57 ++++++++++++++++++++++++++++++++++++---------------------
1 file changed, 36 insertions(+), 21 deletions(-)
diff --git a/elf.c b/elf.c
index 21fbe4f..ccffa95 100644
--- a/elf.c
+++ b/elf.c
@@ -865,12 +865,12 @@ elf_readlink (struct backtrace_state *state, const char *filename,
when the build ID is known is in /usr/lib/debug/.build-id. */
static int
-elf_open_debugfile_by_buildid (struct backtrace_state *state,
+elf_open_debugfile_by_buildid (const char * const prefix,
+ struct backtrace_state *state,
const char *buildid_data, size_t buildid_size,
backtrace_error_callback error_callback,
void *data)
{
- const char * const prefix = SYSTEM_DEBUG_DIR BUILD_ID_DIR;
const size_t prefix_len = strlen (prefix);
const char * const suffix = ".debug";
const size_t suffix_len = strlen (suffix);
@@ -6947,27 +6947,42 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
if (buildid_data != NULL)
{
int d;
+ char debug_directories[strlen(SYSTEM_DEBUG_DIR) + 1];
+ char *debug_dir;
- d = elf_open_debugfile_by_buildid (state, buildid_data, buildid_size,
- error_callback, data);
- if (d >= 0)
- {
- int ret;
+ strcpy(debug_directories, SYSTEM_DEBUG_DIR);
- elf_release_view (state, &buildid_view, error_callback, data);
- if (debuglink_view_valid)
- 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, 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)
- backtrace_close (descriptor, error_callback, data);
- return ret;
- }
+ debug_dir = strtok (debug_directories, ":");
+ while (debug_dir != NULL)
+ {
+ char prefix[strlen(debug_dir) + strlen(BUILD_ID_DIR) + 1];
+ strcpy(prefix, debug_dir);
+ strcat(prefix, BUILD_ID_DIR);
+
+ d = elf_open_debugfile_by_buildid (prefix, state, buildid_data, buildid_size,
+ error_callback, data);
+
+ if (d >= 0)
+ {
+ int ret;
+
+ elf_release_view (state, &buildid_view, error_callback, data);
+ if (debuglink_view_valid)
+ 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, 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)
+ backtrace_close (descriptor, error_callback, data);
+ return ret;
+ }
+
+ debug_dir = strtok (NULL, ":");
+ }
}
if (buildid_view_valid)
--
2.43.1

View File

@@ -0,0 +1,42 @@
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
variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Lets make debug data lookup work on NixOS just like in gdb.
---
elf.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/elf.c b/elf.c
index ccffa95..e86950d 100644
--- a/elf.c
+++ b/elf.c
@@ -6946,11 +6946,18 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
if (buildid_data != NULL)
{
+ const char *debug_directories_immutable;
+ const char *nix_debug = getenv ("NIX_DEBUG_INFO_DIRS");
+ if (nix_debug != NULL)
+ debug_directories_immutable = nix_debug;
+ else
+ debug_directories_immutable = SYSTEM_DEBUG_DIR;
+
int d;
- char debug_directories[strlen(SYSTEM_DEBUG_DIR) + 1];
+ char debug_directories[strlen(debug_directories_immutable) + 1];
char *debug_dir;
- strcpy(debug_directories, SYSTEM_DEBUG_DIR);
+ strcpy(debug_directories, debug_directories_immutable);
debug_dir = strtok (debug_directories, ":");
while (debug_dir != NULL)
--
2.43.1

View File

@@ -0,0 +1,57 @@
{
stdenv,
lib,
fetchFromGitHub,
enableStatic ? stdenv.hostPlatform.isStatic,
enableShared ? !stdenv.hostPlatform.isStatic,
unstableGitUpdater,
autoreconfHook,
}:
stdenv.mkDerivation {
pname = "libbacktrace";
version = "0-unstable-2024-03-02";
src = fetchFromGitHub {
owner = "ianlancetaylor";
repo = "libbacktrace";
rev = "28824f2cc9069e3fdc39d3702acdf753e35c41b4";
sha256 = "1k1O1GT22hZAWPF8NYP0y4qe+e3pGfzT9Mz2TH+H/v4=";
};
patches = [
# Fix tests with shared library.
# https://github.com/ianlancetaylor/libbacktrace/pull/99
./0001-libbacktrace-avoid-libtool-wrapping-tests.patch
# Support multiple debug dirs.
# https://github.com/ianlancetaylor/libbacktrace/pull/100
./0002-libbacktrace-Allow-configuring-debug-dir.patch
./0003-libbacktrace-Support-multiple-build-id-directories.patch
# Support NIX_DEBUG_INFO_DIRS environment variable.
./0004-libbacktrace-Support-NIX_DEBUG_INFO_DIRS-environment.patch
];
nativeBuildInputs = [
autoreconfHook
];
configureFlags = [
(lib.enableFeature enableStatic "static")
(lib.enableFeature enableShared "shared")
];
doCheck = stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isMusl;
passthru = {
updateScript = unstableGitUpdater { };
};
meta = with lib; {
description = "C library that may be linked into a C/C++ program to produce symbolic backtraces";
homepage = "https://github.com/ianlancetaylor/libbacktrace";
maintainers = with maintainers; [ twey ];
license = with licenses; [ bsd3 ];
};
}