mirror of
https://github.com/openembedded/meta-openembedded.git
synced 2026-07-16 16:27:27 +00:00
android-tools: fix build with libstdc++ and current C++ frontends
Two build failures occur with the default clang/lld toolchain (and with
gcc) when compiling android-tools 35.0.2:
1. The bundled fmtlib 10.2.0 validates FMT_STRING() inside a consteval
basic_format_string constructor whose parse path evaluates
"format_str_.remove_prefix(detail::to_unsigned(it - begin()))". Current
C++ frontends reject that iterator subtraction as a non-constant
subexpression:
error: call to consteval function
'fmt::basic_format_string<...>::basic_format_string<FMT_COMPILE_STRING,0>'
is not a constant expression
Define FMT_CONSTEVAL to empty so fmt drops the consteval qualifier and
validates format strings via its runtime path instead.
2. adb's IOVector::coalesce() static_asserts that its Block collection type
is standard-layout. Block holds a std::unique_ptr<char[]>, which is
standard-layout under LLVM libc++ (AOSP's runtime) but not under GNU
libstdc++, so the assertion fails for libstdc++ based toolchains:
packages/modules/adb/types.h:235:27: error: static assertion failed due
to requirement 'std::is_standard_layout<Block>()'
The assertion does not protect the memcpy it guards (which writes into
plain char storage), so drop it.
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
|||||||
|
From 1cbe4eb212f9be35e89eb7f43160c7e0ec35524c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Khem Raj <raj.khem@gmail.com>
|
||||||
|
Date: Wed, 24 Jun 2026 17:50:54 -0700
|
||||||
|
Subject: [PATCH] adb: drop non-portable std::is_standard_layout assertion in
|
||||||
|
IOVector::coalesce
|
||||||
|
|
||||||
|
IOVector::coalesce() asserts that the destination collection type is
|
||||||
|
standard-layout before memcpy'ing the coalesced payload into it:
|
||||||
|
|
||||||
|
static_assert(std::is_standard_layout<decltype(result)>());
|
||||||
|
|
||||||
|
The default collection type is Block, which holds a std::unique_ptr<char[]>
|
||||||
|
member. unique_ptr is standard-layout in LLVM libc++ (what AOSP builds
|
||||||
|
against) but not in GNU libstdc++, so the assertion fails for any
|
||||||
|
libstdc++ based toolchain (gcc, or clang with the default C++ runtime):
|
||||||
|
|
||||||
|
packages/modules/adb/types.h:235:27: error: static assertion failed due
|
||||||
|
to requirement 'std::is_standard_layout<Block>()'
|
||||||
|
|
||||||
|
The assertion does not protect the memcpy, which only writes into the
|
||||||
|
contiguous char storage exposed via Block::operator[]; Block being
|
||||||
|
standard-layout is irrelevant to its correctness. Drop the assertion so
|
||||||
|
the code builds with libstdc++.
|
||||||
|
|
||||||
|
Upstream-Status: Pending
|
||||||
|
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||||
|
---
|
||||||
|
packages/modules/adb/types.h | 1 -
|
||||||
|
1 file changed, 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/packages/modules/adb/types.h b/packages/modules/adb/types.h
|
||||||
|
index 18c8e13..2ed006a 100644
|
||||||
|
--- a/packages/modules/adb/types.h
|
||||||
|
+++ b/packages/modules/adb/types.h
|
||||||
|
@@ -232,7 +232,6 @@ struct IOVector {
|
||||||
|
|
||||||
|
size_t offset = 0;
|
||||||
|
iterate_blocks([&offset, &result](const char* data, size_t len) {
|
||||||
|
- static_assert(std::is_standard_layout<decltype(result)>());
|
||||||
|
memcpy(&result[offset], data, len);
|
||||||
|
offset += len;
|
||||||
|
});
|
||||||
@@ -55,6 +55,7 @@ SRC_URI = "https://deb.debian.org/debian/pool/main/a/android-platform-tools/andr
|
|||||||
file://0008-adb-GCC-compatibility-fixes-for-usb_linux-and-sysdep.patch \
|
file://0008-adb-GCC-compatibility-fixes-for-usb_linux-and-sysdep.patch \
|
||||||
file://0009-libbase-include-stdint.h-in-hex.cpp.patch \
|
file://0009-libbase-include-stdint.h-in-hex.cpp.patch \
|
||||||
file://0010-adbd-make-systemd-sd_notify-conditional-on-HAVE_SYSTEMD.patch \
|
file://0010-adbd-make-systemd-sd_notify-conditional-on-HAVE_SYSTEMD.patch \
|
||||||
|
file://0011-adb-drop-non-portable-is_standard_layout-assertion.patch \
|
||||||
"
|
"
|
||||||
|
|
||||||
SRC_URI[orig.md5sum] = "352376965cdef7bd7505d8fefdd43d50"
|
SRC_URI[orig.md5sum] = "352376965cdef7bd7505d8fefdd43d50"
|
||||||
@@ -79,7 +80,12 @@ SYSTEMD_PACKAGES = "${PN}-adbd"
|
|||||||
SYSTEMD_SERVICE:${PN}-adbd = "android-tools-adbd.service"
|
SYSTEMD_SERVICE:${PN}-adbd = "android-tools-adbd.service"
|
||||||
|
|
||||||
CFLAGS:append = " -fPIC -std=gnu2x"
|
CFLAGS:append = " -fPIC -std=gnu2x"
|
||||||
CXXFLAGS:append = " -fPIC -std=gnu++20 -D_Nonnull= -D_Nullable= -I${STAGING_INCDIR}/boringssl"
|
# The bundled fmtlib 10.2.0 validates FMT_STRING() inside a consteval
|
||||||
|
# basic_format_string constructor whose parse path evaluates "it - begin()",
|
||||||
|
# which current C++ frontends reject as a non-constant subexpression. Define
|
||||||
|
# FMT_CONSTEVAL to empty so format-string checking falls back to fmt's runtime
|
||||||
|
# path instead of the broken compile-time one.
|
||||||
|
CXXFLAGS:append = " -fPIC -std=gnu++20 -D_Nonnull= -D_Nullable= -I${STAGING_INCDIR}/boringssl -DFMT_CONSTEVAL="
|
||||||
LDFLAGS:append = " -fPIC -L${STAGING_LIBDIR}/android"
|
LDFLAGS:append = " -fPIC -L${STAGING_LIBDIR}/android"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user