All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Derk <linux@alanderk.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Alan Maguire <alan.maguire@oracle.com>
Cc: dwarves@vger.kernel.org, bpf@vger.kernel.org,
	rust-for-linux@vger.kernel.org
Subject: [PATCH dwarves v2 0/2] dwarf_loader: Fix --lang_exclude on merged CUs
Date: Sat, 10 Oct 2026 00:52:25 +0000	[thread overview]
Message-ID: <20261010005227.976-1-linux@alanderk.com> (raw)

Two fixes for --lang_exclude when CUs are merged, as for LTO objects.

Patch 1 takes the merged CU's language from a CU that is kept, so that
excluding the language of the first CU no longer drops the whole
object. With LTO, this is what makes BTF generation fail for kernel
modules that mix Rust and C.

Patch 2 fixes a second bug from the same commit, which I found while
testing userspace LTO objects after sending v1. With clang LTO, a type
such as int is emitted once and shared through DW_FORM_ref_addr, so
skipping the excluded CUs left references into them dangling: pahole
crashed printing such members, and -J encoded them as void. Patch 2
loads the types that kept CUs use from the excluded CUs. Output without
--lang_exclude does not change, and neither does the BTF of the LTO
kernels I tested.

Patch 1 exposes this bug in one more link order. For a C++ object
linked before a C one, pahole used to drop the C types without any
error; with patch 1 alone it keeps them, and then crashes printing them,
or encodes them as void with -J. Please apply the two together.

As far as I know, patch 1 removes the last thing that keeps the kernel's
RUST option off when LTO and BTF are both on. Once these fixes are in a
release, I'd like to propose relaxing that dependency to something like:

  depends on !DEBUG_INFO_BTF || (PAHOLE_HAS_LANG_EXCLUDE && (!LTO || PAHOLE_VERSION >= 133))

assuming they land in 1.33. The kernel tests in patch 1 ran with
"&& !LTO" dropped from that line, hence the Cc to rust-for-linux.

Changes in v2:
- Add patch 2.
- Patch 1 is unchanged; its note about the Kconfig follow-up moved here.

v1: https://lore.kernel.org/all/20261009201032.40105-1-linux@alanderk.com/

Alan Derk (2):
  dwarf_loader: Take the merged CU language from a CU that is kept
  dwarf_loader: Load types that kept CUs use from excluded CUs

 dwarf_loader.c                  | 129 +++++++++++++++++++++++++++-----
 tests/lang_exclude_lto_refs.sh  |  76 +++++++++++++++++++
 tests/lang_exclude_merged_cu.sh |  67 +++++++++++++++++
 3 files changed, 253 insertions(+), 19 deletions(-)
 create mode 100755 tests/lang_exclude_lto_refs.sh
 create mode 100755 tests/lang_exclude_merged_cu.sh


base-commit: 1e342ac44979748bcf5bb37f84ea055e7f4d7184
-- 
2.55.0


             reply	other threads:[~2026-10-10  0:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10  0:52 Alan Derk [this message]
2026-10-10  0:52 ` [PATCH dwarves v2 1/2] dwarf_loader: Take the merged CU language from a CU that is kept Alan Derk
2026-10-10  0:52 ` [PATCH dwarves v2 2/2] dwarf_loader: Load types that kept CUs use from excluded CUs Alan Derk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261010005227.976-1-linux@alanderk.com \
    --to=linux@alanderk.com \
    --cc=acme@kernel.org \
    --cc=alan.maguire@oracle.com \
    --cc=bpf@vger.kernel.org \
    --cc=dwarves@vger.kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.