From a1038beb9e87f91071012c9e744eb1ef3d6d2474 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 29 Sep 2026 06:01:34 +0000 Subject: [PATCH] perfetto: avoid getprogname() macro clobbering its own fallback The bundled liblog/libbase compat shim defines a getprogname() fallback macro and then immediately redefines program_invocation_name using it in a way that collides with musl's own declaration. Fix the ordering/guard so the two definitions don't conflict. AI-Generated: Uses Claude Code Signed-off-by: Khem Raj --- meta-oe/recipes-devtools/perfetto/perfetto.bb | 1 + ...me-macro-clobbering-its-own-fallback.patch | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 meta-oe/recipes-devtools/perfetto/perfetto/0002-Avoid-getprogname-macro-clobbering-its-own-fallback.patch diff --git a/meta-oe/recipes-devtools/perfetto/perfetto.bb b/meta-oe/recipes-devtools/perfetto/perfetto.bb index 978a8611cc..f21b983a2b 100644 --- a/meta-oe/recipes-devtools/perfetto/perfetto.bb +++ b/meta-oe/recipes-devtools/perfetto/perfetto.bb @@ -27,6 +27,7 @@ SRC_URI:append = " \ git://chromium.googlesource.com/external/github.com/google/re2.git;nobranch=1;protocol=https;destsuffix=${BB_GIT_DEFAULT_DESTSUFFIX}/buildtools/re2;name=re2 \ \ file://0001-Remove-check_build_deps-build-steps.patch \ + file://0002-Avoid-getprogname-macro-clobbering-its-own-fallback.patch \ " SRCREV_bionic = "a0d0355105cb9d4a4b5384897448676133d7b8e2" diff --git a/meta-oe/recipes-devtools/perfetto/perfetto/0002-Avoid-getprogname-macro-clobbering-its-own-fallback.patch b/meta-oe/recipes-devtools/perfetto/perfetto/0002-Avoid-getprogname-macro-clobbering-its-own-fallback.patch new file mode 100644 index 0000000000..20a06c4e19 --- /dev/null +++ b/meta-oe/recipes-devtools/perfetto/perfetto/0002-Avoid-getprogname-macro-clobbering-its-own-fallback.patch @@ -0,0 +1,58 @@ +From: Khem Raj +Date: Mon, 29 Sep 2026 01:59:00 +0000 +Subject: [PATCH] buildtools: don't let the musl getprogname() macro clobber + its own fallback definition + +On musl, the recipe passes -Dgetprogname()=program_invocation_name via +TUNE_CCARGS so callers of getprogname() resolve to musl's +program_invocation_name. But android-logging's logger_write.cpp and +android-libbase's logging.cpp each already provide their own +"static const char* getprogname()" fallback for any non-Apple, +non-Bionic target (which includes musl-linux). The function-like macro +textually matches this definition's "getprogname()" declarator too, +rewriting it into "program_invocation_name" and turning what should be +a function definition into an ill-typed brace-initialized variable +definition of type "const char*", which then conflicts with musl's own +"extern char *program_invocation_name" declaration: + + error: redefinition of 'program_invocation_name' with a different + type: 'const char *' vs 'char *' + +Guard each fallback definition with "&& !defined(getprogname)" so it +is skipped when the build already supplies getprogname() as a macro, +leaving the existing __APPLE__/__BIONIC__ exclusions untouched for +platforms that don't define the macro. + +Upstream-Status: Pending +Signed-off-by: Khem Raj +--- +--- a/buildtools/android-logging/liblog/logger_write.cpp 2026-09-29 01:58:46.064186639 +0000 ++++ b/buildtools/android-logging/liblog/logger_write.cpp 2026-09-29 01:58:46.065218637 +0000 +@@ -109,7 +109,11 @@ + } + + // BSD-based systems like Android/macOS have getprogname(). Others need us to provide one. +-#if !defined(__APPLE__) && !defined(__BIONIC__) ++// Skip this on platforms where the build already provides getprogname() as a macro ++// (e.g. musl builds define -Dgetprogname()=program_invocation_name), since the macro ++// would otherwise rewrite this very definition's "getprogname()" declarator into ++// "program_invocation_name", clashing with musl's own char* extern declaration. ++#if !defined(__APPLE__) && !defined(__BIONIC__) && !defined(getprogname) + static const char* getprogname() { + #ifdef _WIN32 + static bool first = true; +--- a/buildtools/android-libbase/logging.cpp 2026-09-29 01:58:46.066054793 +0000 ++++ b/buildtools/android-libbase/logging.cpp 2026-09-29 01:58:46.067074541 +0000 +@@ -62,7 +62,11 @@ + namespace base { + + // BSD-based systems like Android/macOS have getprogname(). Others need us to provide one. +-#if !defined(__APPLE__) && !defined(__BIONIC__) ++// Skip this on platforms where the build already provides getprogname() as a macro ++// (e.g. musl builds define -Dgetprogname()=program_invocation_name), since the macro ++// would otherwise rewrite this very definition's "getprogname()" declarator into ++// "program_invocation_name", clashing with musl's own char* extern declaration. ++#if !defined(__APPLE__) && !defined(__BIONIC__) && !defined(getprogname) + static const char* getprogname() { + #ifdef _WIN32 + static bool first = true;