diff mbox series

[meta-oe] thin-provisioning-tools: add target and sysroot to bindgen flags

Message ID 20250227120412.1465709-1-skandigraun@gmail.com
State Accepted
Headers show
Series [meta-oe] thin-provisioning-tools: add target and sysroot to bindgen flags | expand

Commit Message

Gyorgy Sarvari Feb. 27, 2025, 12:04 p.m. UTC
BUILD_CFLAGS doesn't contain information about the recipe sysroot nor about the target
system - and in case these are not specified for bindgen, then it builds against
the build system's headers, using the build system's arch.

Specify these attributes in BINDGEN_EXTRA_CLANG_ARGS to use the correct headers.

Fixes the following do_compile error:

|   /usr/include/linux/types.h:5:10: fatal error: 'asm/types.h' file not found
|   thread 'main' panicked at /yocto/sandbox/build/tmp/work/cortexa72-poky-linux/thin-provisioning-tools/1.1.0/sources-unpack/cargo_home/bitbake/devicemapper-sys-0.3.0/build.rs:24:10:
|   Could not generate dm.h bindings: ClangDiagnostic("/usr/include/linux/types.h:5:10: fatal error: 'asm/types.h' file not found\n")

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
 .../thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Khem Raj Feb. 27, 2025, 4:33 p.m. UTC | #1
On Thu, Feb 27, 2025 at 4:04 AM Gyorgy Sarvari via lists.openembedded.org
<skandigraun=gmail.com@lists.openembedded.org> wrote:

> BUILD_CFLAGS doesn't contain information about the recipe sysroot nor
> about the target
> system - and in case these are not specified for bindgen, then it builds
> against
> the build system's headers, using the build system's arch.
>
> Specify these attributes in BINDGEN_EXTRA_CLANG_ARGS to use the correct
> headers.
>
> Fixes the following do_compile error:
>
> |   /usr/include/linux/types.h:5:10: fatal error: 'asm/types.h' file not
> found
> |   thread 'main' panicked at
> /yocto/sandbox/build/tmp/work/cortexa72-poky-linux/thin-provisioning-tools/1.1.0/sources-unpack/cargo_home/bitbake/devicemapper-sys-0.3.0/build.rs:24
> :10:
> |   Could not generate dm.h bindings:
> ClangDiagnostic("/usr/include/linux/types.h:5:10: fatal error:
> 'asm/types.h' file not found\n")


Good catch I forgot about target vs build here once we point it to target
sysroot we should not need build flags perhaps passing TOOLCHAIN_OPTIONS
would suffice

>
>
> Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
> ---
>  .../thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb    | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git
> a/meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/
> thin-provisioning-tools_1.1.0.bb
> b/meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/
> thin-provisioning-tools_1.1.0.bb
> index bb4b53c28b..72543e60f4 100644
> ---
> a/meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/
> thin-provisioning-tools_1.1.0.bb
> +++
> b/meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/
> thin-provisioning-tools_1.1.0.bb
> @@ -21,7 +21,7 @@ inherit pkgconfig
>  DEPENDS += "udev libdevmapper libdevmapper-native clang-native"
>
>  export LIBCLANG_PATH = "${WORKDIR}/recipe-sysroot-native${libdir}"
> -export BINDGEN_EXTRA_CLANG_ARGS = "${BUILD_CFLAGS}"
> +export BINDGEN_EXTRA_CLANG_ARGS = "${BUILD_CFLAGS}
> --sysroot=${RECIPE_SYSROOT} --target=${TARGET_SYS}"
>
>  require ${BPN}-crates.inc
>  require ${BPN}-git-crates.inc
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#115688):
> https://lists.openembedded.org/g/openembedded-devel/message/115688
> Mute This Topic: https://lists.openembedded.org/mt/111413493/1997914
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [
> raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Gyorgy Sarvari Feb. 27, 2025, 4:56 p.m. UTC | #2
>     Fixes the following do_compile error:
>
>     |   /usr/include/linux/types.h:5:10: fatal error: 'asm/types.h'
>     file not found
>     |   thread 'main' panicked at
>     /yocto/sandbox/build/tmp/work/cortexa72-poky-linux/thin-provisioning-tools/1.1.0/sources-unpack/cargo_home/bitbake/devicemapper-sys-0.3.0/build.rs:24:10:
>     |   Could not generate dm.h bindings:
>     ClangDiagnostic("/usr/include/linux/types.h:5:10: fatal error:
>     'asm/types.h' file not found\n")
>
>
> Good catch I forgot about target vs build here once we point it to
> target sysroot we should not need build flags perhaps passing
> TOOLCHAIN_OPTIONS would suffice 
>
>
Yup, you are right - TOOLCHAIN_OPTIONS seems to do the trick.
diff mbox series

Patch

diff --git a/meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb b/meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb
index bb4b53c28b..72543e60f4 100644
--- a/meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb
+++ b/meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb
@@ -21,7 +21,7 @@  inherit pkgconfig
 DEPENDS += "udev libdevmapper libdevmapper-native clang-native"
 
 export LIBCLANG_PATH = "${WORKDIR}/recipe-sysroot-native${libdir}"
-export BINDGEN_EXTRA_CLANG_ARGS = "${BUILD_CFLAGS}"
+export BINDGEN_EXTRA_CLANG_ARGS = "${BUILD_CFLAGS} --sysroot=${RECIPE_SYSROOT} --target=${TARGET_SYS}"
 
 require ${BPN}-crates.inc
 require ${BPN}-git-crates.inc