diff mbox series

[meta-darwin,08/21] libdispatch-native, libtapi-native, cctools-port-crosssdk: fix ineffective clang selection

Message ID 20261014141209.488034-8-ecordonnier@snap.com
State New
Headers show
Series [meta-darwin,01/21] meta-darwin: bump layer series to wrynose (6.0.3) | expand

Commit Message

Etienne Cordonnier Oct. 14, 2026, 2:10 p.m. UTC
From: Etienne Cordonnier <ecordonnier@snap.com>

TOOLCHAIN:class-native / TOOLCHAIN:class-crosssdk never actually selects
clang for these recipes: native.bbclass (and cross.bbclass, inherited by
crosssdk.bbclass) unconditionally set CC/AR/AS to ${BUILD_CC}/${BUILD_AR}/
${BUILD_AS}, which come from TOOLCHAIN_NATIVE, not TOOLCHAIN. As a result
these recipes were silently compiling with plain host gcc and rejecting
all the clang-specific -W flags/module maps in their build systems.
Matches an existing fix already applied for meta-hawaii's spk-cli
recipe (see its TOOLCHAIN_NATIVE comment).

COMPILER_RT:class-* and LIBCPLUSPLUS:class-* are also not real
variables consumed anywhere in OE-core - dead code left over from the
same misunderstanding. clang-native.bbclass already unconditionally
forces --rtlib=libgcc --unwindlib=libgcc, but nothing turns on
-stdlib=libc++ automatically, so libtapi-native and cctools-port-crosssdk
(both C++) need it set directly via CXXFLAGS/LDFLAGS.

Keep only the short, non-obvious warning in the recipe comments
(TOOLCHAIN:class-* has no effect, use TOOLCHAIN_NATIVE); the full
mechanism explanation belongs here, not in comments that will drift as
the toolchain evolves.

Actually exercising clang for these recipes for the first time surfaces
two more build breaks, fixed here too:

- libdispatch-native's src/event/event_epoll.c does
  "dmn->dmn_events & ~dmn->dmn_disarmed_events" returning uint32_t;
  harmless under -Wsign-conversion but fatal under this recipe's
  -Werror.
- cctools/include/stuff/bool.h declares "enum bool { FALSE, TRUE };",
  which fails to parse under C23 (bool is a reserved keyword there, not
  a macro). clang's default C dialect defaults to gnu23 absent an
  explicit -std=, which is what surfaces this now that
  cctools-port-crosssdk actually builds with clang.

AI-Generated: Claude Sonnet 5

Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
 .../cctools-port/cctools-port-crosssdk_1010.6.bb   | 14 +++++++++++---
 .../libdispatch/libdispatch-native_git.bb          |  9 ++++++++-
 .../libtapi/libtapi-native_1300.6.5.bb             |  8 +++++---
 3 files changed, 24 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/recipes-devtools/cctools-port/cctools-port-crosssdk_1010.6.bb b/recipes-devtools/cctools-port/cctools-port-crosssdk_1010.6.bb
index 3abeb02..dcd5d01 100644
--- a/recipes-devtools/cctools-port/cctools-port-crosssdk_1010.6.bb
+++ b/recipes-devtools/cctools-port/cctools-port-crosssdk_1010.6.bb
@@ -23,9 +23,17 @@  DEPENDS += " \
     libcxx-native \
 "
 
-TOOLCHAIN:class-crosssdk = "clang"
-COMPILER_RT:class-crosssdk = "-rtlib=libgcc --unwindlib=libgcc"
-LIBCPLUSPLUS:class-crosssdk = "-stdlib=libc++ -lc++abi"
+# Selects clang for the native build; TOOLCHAIN:class-crosssdk has no effect here.
+# -stdlib=libc++ isn't added automatically, so this is C++ and needs it set directly.
+TOOLCHAIN_NATIVE = "clang"
+CXXFLAGS:append:class-crosssdk = " -stdlib=libc++"
+LDFLAGS:append:class-crosssdk = " -stdlib=libc++"
+
+# cctools' own include/stuff/bool.h declares "enum bool { FALSE, TRUE };",
+# which is a hard syntax error under C23, where bool is a reserved keyword
+# rather than a macro. Pin the C dialect to a pre-C23 standard rather than
+# relying on clang's default (gnu23 as of this clang version).
+CFLAGS:append:class-crosssdk = " -std=gnu17"
 
 EXTRA_OECONF:append = " \
     --with-llvm-config=${STAGING_DIR_NATIVE}/usr/bin/llvm-config \
diff --git a/recipes-devtools/libdispatch/libdispatch-native_git.bb b/recipes-devtools/libdispatch/libdispatch-native_git.bb
index c7dadd0..a3a1b2e 100644
--- a/recipes-devtools/libdispatch/libdispatch-native_git.bb
+++ b/recipes-devtools/libdispatch/libdispatch-native_git.bb
@@ -19,4 +19,11 @@  DEPENDS += " \
 "
 
 TC_CXX_RUNTIME:class-native = "llvm"
-TOOLCHAIN:class-native = "clang"
+
+# Selects clang for the native build; TOOLCHAIN:class-native has no effect here.
+TOOLCHAIN_NATIVE = "clang"
+
+# src/event/event_epoll.c (the Linux epoll port) hits a benign sign-conversion
+# warning on a plain bitmask op; upstream's own -Werror -Wsign-conversion
+# combo doesn't exempt it.
+CFLAGS:append:class-native = " -Wno-error=sign-conversion"
diff --git a/recipes-devtools/libtapi/libtapi-native_1300.6.5.bb b/recipes-devtools/libtapi/libtapi-native_1300.6.5.bb
index 5442f39..545aa59 100644
--- a/recipes-devtools/libtapi/libtapi-native_1300.6.5.bb
+++ b/recipes-devtools/libtapi/libtapi-native_1300.6.5.bb
@@ -24,9 +24,11 @@  DEPENDS += " \
     libcxx-native \
 "
 
-TOOLCHAIN:class-native = "clang"
-COMPILER_RT:class-native = "-rtlib=libgcc --unwindlib=libgcc"
-LIBCPLUSPLUS:class-native = "-stdlib=libc++ -lc++abi"
+# Selects clang for the native build; TOOLCHAIN:class-native has no effect here.
+# -stdlib=libc++ isn't added automatically, so this is C++ and needs it set directly.
+TOOLCHAIN_NATIVE = "clang"
+CXXFLAGS:append:class-native = " -stdlib=libc++"
+LDFLAGS:append:class-native = " -stdlib=libc++"
 
 CXXFLAGS += " \
     -I${S}/projects/clang/include \