This patch is sitting in master-next for some time already and is probably 
spending a minute or two of everyone's time on each patch review call.
Let's try to do a decision whether to merge it or drop it.
I (without asking or rewording via AI) think this:

I see following ways how to approach this clang-tidy problem:
- make clang-tidy architecture aware upstream
- add these flags to tell it the architecture (what this patch proposes and 
what was present in scarthgap)
- add it only to recipes which use clang-tidy (or other similar clang tools)

clang-tidy (and this also applies to some other clang support tools) is in 
principle architecture independent.
Linter should not care about build arch, correct?, it just needs to know the 
paths to sources.
So imho making it architecture dependent would go in a wrong direction, 
probably wasting time of whoever develops this and upstream clang maintainers.

Explicit set of architecture globally looks like a better choice.
Yocto currently does not set the triplet in build flags, because it's hardcoded 
in toolchain and thus "it works" (however as we see here, only in 99.9% of 
cases)
For clang compiler it's a no-op (the value is the same as value that it has 
hardcoded during its compilation).
And it helps all "arch-independent" clang tools to find the right headers.

Having a special handling for clang-tidy in all recipes using it is certainly 
possible, but seems to be sub-par.
Yocto should support clang-tidy workflows natively.

Best Regards,
  Peter

> -----Original Message-----
> From: Marko, Peter (FT D EU SK BFS1) <[email protected]>
> Sent: Thursday, August 20, 2026 10:11 PM
> To: [email protected]
> Cc: Khem Raj <[email protected]>; Marko, Peter (FT D EU SK BFS1)
> <[email protected]>
> Subject: [PATCH v2] toolchain/clang: prepend target host-sys to
> HOST_CC_ARCH
> 
> From: Peter Marko <[email protected]>
> 
> This assignment was present in scarthgap meta-clang.
> * commit adding it: [1]
> * commit removing it from native case: [2]
> * it was removed completely when migrating clang to oe-core
> 
> After migration from scarthgap to wrynose (or current master), clang
> extra tools like clang-tidy do not work anymore.
> 
> This restores the state before migration from meta-clang to oe-core.
> 
> Test recipe used for fix validation:
> 
> test-recipe.bb:
>   SUMMARY = "clang-tidy demonstration program"
>   SECTION = "examples"
>   HOMEPAGE = "n/a"
>   LICENSE = "GPL-2.0-only"
>   LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-
> 2.0-only;md5=801f80980d171dd6425610833a22dbe6"
>   SRC_URI = "file://CMakeLists.txt file://hello-world.cpp"
>   S = "${UNPACKDIR}"
>   TOOLCHAIN = "clang"
>   inherit cmake
> 
> CMakeLists.txt
>   project(hello-world)
>   cmake_minimum_required(VERSION 3.5)
>   find_program(CLANG_TIDY NAMES clang-tidy)
>   set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY}" "--checks=*")
>   add_executable(${PROJECT_NAME} hello-world.cpp)
> 
> hello-world.cpp
>   #include <iostream>
>   int main() {
>     std::cout << "Hello World!";
>     return 0;
>   }
> 
> [1] https://github.com/kraj/meta-
> clang/commit/503aa977b27be0506fb6ac21fbf9e8b049b82247
> [2] https://github.com/kraj/meta-
> clang/commit/6da0abaa33b458a37b97f42e3755245e3220bf27
> 
> Signed-off-by: Peter Marko <[email protected]>
> ---
> v2:
> * removed native variant, which will make it equivalent to pre-move mota-clang
> * remove unuseful AI explanation from commit message
> 
>  meta/classes/toolchain/clang.bbclass | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/meta/classes/toolchain/clang.bbclass
> b/meta/classes/toolchain/clang.bbclass
> index 9a3cd0e584..f6b554d210 100644
> --- a/meta/classes/toolchain/clang.bbclass
> +++ b/meta/classes/toolchain/clang.bbclass
> @@ -34,6 +34,10 @@ LDFLAGS:append:class-nativesdk:x86-64 = " -Wl,-
> dynamic-linker,${base_libdir}/ld-
>  LDFLAGS:append:class-nativesdk:aarch64 = " -Wl,-dynamic-
> linker,${base_libdir}/ld-linux-aarch64.so.1"
>  LDFLAGS:append:class-cross-canadian = " -Wl,-dynamic-
> linker,${base_libdir}/placeholder/to/be/rewritten/by/sdk/installer"
> 
> +# helps extra tools like clang-tidy to find arch-specific macros and headers 
> in a
> cross compile environment
> +HOST_CC_ARCH:prepend:class-target = "-target ${HOST_SYS} "
> +HOST_CC_ARCH:prepend:class-nativesdk = "-target ${HOST_SYS} "
> +
>  # do_populate_sysroot needs STRIP, do_package_qa needs OBJDUMP
>  POPULATESYSROOTDEPS:append:class-target = " llvm-
> native:do_populate_sysroot"
> 
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#246760): 
https://lists.openembedded.org/g/openembedded-core/message/246760
Mute This Topic: https://lists.openembedded.org/mt/120852316/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to