[PATCH 18/31] pahole: Fix parse_btf_features("all") being a silent no-op

Arnaldo Carvalho de Melo <[email protected]> Wed, 29 Jul 2026 16:07:18 -0300
Newsgroups org.kernel.vger.dwarves,org.kernel.vger.bpf
Message-ID <[email protected]>
From: Arnaldo Carvalho de Melo <[email protected]>

"all" was not recognized as a feature name, so
parse_btf_features("all") silently did nothing — no features were
enabled and no error was reported.

Add btf_features__enable_all() that enables every feature in the
btf_features[] table, and wire it into parse_btf_features() both as
a standalone value and as a token in comma-separated lists.

Before: --btf_features=all silently enabled nothing.
After:  --btf_features=all enables all features in the table.

Fixes: 7bc9b9975545ab53 ("pahole: Add --btf_features support")
Assisted-by: Claude:claude-sonnet-4-5
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
 pahole.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/pahole.c b/pahole.c
index 0e2acc35d6d679f0..a6012e6a157293e9 100644
--- a/pahole.c
+++ b/pahole.c
@@ -1299,6 +1299,22 @@ static void btf_features__enable_default(void)
 	}
 }
 
+static void btf_features__enable_all(void)
+{
+	for (size_t i = 0; i < ARRAY_SIZE(btf_features); i++) {
+		/* distilled_base requires a --btf_base argument to
+		 * provide the base BTF that btf__distill_base() will
+		 * split against.  Enabling it unconditionally causes
+		 * btf_encoder__encode() to call btf__distill_base()
+		 * on standalone objects like vmlinux, which returns
+		 * -EINVAL and makes pahole fail fatally.  Users who
+		 * want distilled_base must request it explicitly. */
+		if (btf_features[i].conf_value == &conf_load.btf_gen_distilled_base)
+			continue;
+		enable_btf_feature(&btf_features[i]);
+	}
+}
+
 /* Translate --btf_features=feature1[,feature2] into conf_load values.
  * Explicitly ignores unrecognized features to allow future specification
  * of new opt-in features.
@@ -1315,6 +1331,11 @@ static void parse_btf_features(const char *features, bool strict)
 		return;
 	}
 
+	if (strcmp(features, "all") == 0) {
+		btf_features__enable_all();
+		return;
+	}
+
 	// Adding extra features to the set of standard features.
 	if (strstarts(features, "+")) {
 		btf_features__enable_default();
@@ -1332,6 +1353,8 @@ static void parse_btf_features(const char *features, bool strict)
 			 */
 			if (strcmp(feature_name, "default") == 0) {
 				btf_features__enable_default();
+			} else if (strcmp(feature_name, "all") == 0) {
+				btf_features__enable_all();
 			} else if (strict) {
 				fprintf(stderr, "Feature '%s' in '%s' is not supported.  Supported BTF features are:\n",
 					feature_name, features);
-- 
2.55.0