Skip to contentSkip to conversation

thin-provisioning-tools: add target and sysroot to bindgen flags

PATCH In review Gyorgy Sarvari 2 participants 4 messages Feb 27, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 thin-provisioning-tools: add target and sysroot to bindgen flags

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.

Instead of BUILD_CFLAGS pass HOST_CC_ARCH and TOOLCHAIN_OPTIONS, which contain the sysroot and the requred cross-compiling flags, beside passing the target flag also.

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")
---
 .../thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb +1 -1
index bb4b53c28b..d0241c7016 100644
@@ -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 = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}"
 
 require ${BPN}-crates.inc
 require ${BPN}-git-crates.inc
#1 lore raw
Quoted 24 lines · Gyorgy Sarvari via lists.openembedded.org

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.

Instead of BUILD_CFLAGS pass HOST_CC_ARCH and TOOLCHAIN_OPTIONS, which contain the sysroot and the requred cross-compiling flags, beside passing the target flag also.

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")
---
 .../thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb +0 -0
index bb4b53c28b..d0241c7016 100644

meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb inherit pkgconfig · line 25

Quoted 6 lines
meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb +1 -1
@@ -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 = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}"
 

we do not need -target anymore its part of HOST_CCARCH

Quoted 11 lines
meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb +0 -1
 require ${BPN}-crates.inc
 require ${BPN}-git-crates.inc
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#115699): https://lists.openembedded.org/g/openembedded-devel/message/115699
Mute This Topic: https://lists.openembedded.org/mt/111420486/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw
Quoted 28 lines · Khem Raj
Quoted 25 lines · Gyorgy Sarvari via lists.openembedded.org

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.

Instead of BUILD_CFLAGS pass HOST_CC_ARCH and TOOLCHAIN_OPTIONS, which contain the sysroot and the requred cross-compiling flags, beside passing the target flag also.

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")
---
 .../thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb +0 -0
index bb4b53c28b..d0241c7016 100644
@@ -21,7 +21,7 @@ inherit pkgconfig
 DEPENDS += "udev libdevmapper libdevmapper-native clang-native"
 
Quoted 5 lines

meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb inherit pkgconfig · line 25

Quoted 4 lines
meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb +1 -1
 export LIBCLANG_PATH = "${WORKDIR}/recipe-sysroot-native${libdir}"
-export BINDGEN_EXTRA_CLANG_ARGS = "${BUILD_CFLAGS}"
+export BINDGEN_EXTRA_CLANG_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}"
 

we do not need -target anymore its part of HOST_CCARCH

It is not:

$ bitbake -e thin-provisioning-tools | grep ^HOST_CC_ARCH
HOST_CC_ARCH=" -mcpu=cortex-a72+crc -mbranch-protection=standard
-fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-
security -Werror=format-security"

If I remove it, it gets unhappy:

|   error: unsupported option '-mcpu=' for target 'x86_64-unknown-linux-gnu' |   error: unsupported option '-mbranch-protection=' for target 'x86_64-unknown-linux-gnu'
(etc..)

Quoted 12 lines
Quoted 12 lines
meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb +0 -1
 require ${BPN}-crates.inc
 require ${BPN}-git-crates.inc
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#115699): https://lists.openembedded.org/g/openembedded-devel/message/115699
Mute This Topic: https://lists.openembedded.org/mt/111420486/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw
Quoted 44 lines · Gyorgy Sarvari
Quoted 28 lines · Khem Raj
Quoted 25 lines · Gyorgy Sarvari via lists.openembedded.org

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.

Instead of BUILD_CFLAGS pass HOST_CC_ARCH and TOOLCHAIN_OPTIONS, which contain the sysroot and the requred cross-compiling flags, beside passing the target flag also.

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")
---
 .../thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb +0 -0
index bb4b53c28b..d0241c7016 100644
@@ -21,7 +21,7 @@ inherit pkgconfig
 DEPENDS += "udev libdevmapper libdevmapper-native clang-native"
 
Quoted 5 lines

meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb inherit pkgconfig · line 25

Quoted 4 lines
meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb +1 -1
 export LIBCLANG_PATH = "${WORKDIR}/recipe-sysroot-native${libdir}"
-export BINDGEN_EXTRA_CLANG_ARGS = "${BUILD_CFLAGS}"
+export BINDGEN_EXTRA_CLANG_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}"
 

we do not need -target anymore its part of HOST_CCARCH

It is not:

$ bitbake -e thin-provisioning-tools | grep ^HOST_CC_ARCH
HOST_CC_ARCH=" -mcpu=cortex-a72+crc -mbranch-protection=standard
-fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-
security -Werror=format-security"
Quoted 7 lines

If I remove it, it gets unhappy:

|   error: unsupported option '-mcpu=' for target 'x86_64-unknown-linux-gnu'
|   error: unsupported option '-mbranch-protection=' for target

'x86_64-unknown-linux-gnu'
(etc..)

Yeah, I see when clang is used at default compiler then its added but for gcc defaults it is not. I will take v3

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
meta-oe/dynamic-layers/clang-layer/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb +0 -1
 require ${BPN}-crates.inc
 require ${BPN}-git-crates.inc
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#115699): https://lists.openembedded.org/g/openembedded-devel/message/115699
Mute This Topic: https://lists.openembedded.org/mt/111420486/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-