Message ID | 20250724074411.2903317-1-bo.sun.cn@windriver.com |
---|---|
State | New |
Headers | show |
Series | [meta-oe,walnascar] thin-provisioning-tools: fix bindgen build error with clang on octeontx2 | expand |
while this fixes it for one recipe, we have to fix it as tune level in oe-core so remove it globally if we are using clang compiler. so perhaps adding it to clang.bbclass might be a good idea On Thu, Jul 24, 2025 at 4:44 AM Bo Sun via lists.openembedded.org <Bo.Sun.CN=windriver.com@lists.openembedded.org> wrote: > > Remove unsupported '-mcpu=octeontx2+crypto' from BINDGEN_EXTRA_CLANG_ARGS > as clang does not recognize 'octeontx2' as a valid target CPU, causing > bindgen to fail when generating Rust bindings. > > Since bindgen only parses headers using Clang, CPU-specific options > like -mcpu are generally unnecessary. > > Fixes build failure: > | error: unsupported argument 'octeontx2+crypto' to option '-mcpu=' > | error: unknown target CPU 'octeontx2' > > Signed-off-by: Bo Sun <bo.sun.cn@windriver.com> > --- > .../thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb | 5 ++++- > 1 file changed, 4 insertions(+), 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 a60ca11244..4ed885f8b3 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 > @@ -23,7 +23,10 @@ inherit pkgconfig > DEPENDS += "udev libdevmapper libdevmapper-native clang-native" > > export LIBCLANG_PATH = "${STAGING_LIBDIR_NATIVE}" > -export BINDGEN_EXTRA_CLANG_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}" > +# Remove octeontx2 specific CPU flags that may cause issues with bindgen > +BINDGEN_EXTRA_CLANG_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}" > +BINDGEN_EXTRA_CLANG_ARGS:remove = "-mcpu=octeontx2+crypto" > +export BINDGEN_EXTRA_CLANG_ARGS > > require ${BPN}-crates.inc > require ${BPN}-git-crates.inc > -- > 2.50.1 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#118723): https://lists.openembedded.org/g/openembedded-devel/message/118723 > Mute This Topic: https://lists.openembedded.org/mt/114317423/1997914 > Group Owner: openembedded-devel+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
On 7/24/25 23:55, Khem Raj wrote: > CAUTION: This email comes from a non Wind River email account! > Do not click links or open attachments unless you recognize the sender and know the content is safe. > > while this fixes it for one recipe, we have to fix it as tune level in > oe-core so remove it globally if we are using clang compiler. so > perhaps adding it to clang.bbclass might be a good idea Yes, this fix does resolve the issue for this specific recipe. However, I think fixing it at the recipe level is still a reasonable solution. Looking at the bindgen code, BINDGEN_EXTRA_CLANG_ARGS is parsed and used directly by bindgen at runtime, not by BitBake: https://github.com/rust-lang/rust-bindgen/blob/de9627ffa4860c6ed56cd40470fc7a96afc09d44/bindgen/lib.rs#L300 fn get_extra_clang_args( parse_callbacks: &[Rc<dyn callbacks::ParseCallbacks>], ) -> Vec<String> { // Add any extra arguments from the environment to the clang command line. let Some(extra_clang_args) = get_target_dependent_env_var( parse_callbacks, "BINDGEN_EXTRA_CLANG_ARGS", ) else { return vec![]; }; https://github.com/rust-lang/rust-bindgen/blob/de9627ffa4860c6ed56cd40470fc7a96afc09d44/bindgen/lib.rs#L337 // Add any extra arguments from the environment to the clang command line. self.options.clang_args.extend( get_extra_clang_args(&self.options.parse_callbacks) .into_iter() .map(String::into_boxed_str), ); Additionally, base on the build.rs for devicemapper-sys, I believe we can safely remove ${HOST_CC_ARCH} from this recipe. https://github.com/stratis-storage/devicemapper-rs/blob/master/devicemapper-rs-sys/build.rs $ git diff 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 a60ca11244..e8173c9b14 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 @@ -23,7 +23,7 @@ inherit pkgconfig DEPENDS += "udev libdevmapper libdevmapper-native clang-native" export LIBCLANG_PATH = "${STAGING_LIBDIR_NATIVE}" -export BINDGEN_EXTRA_CLANG_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}" +export BINDGEN_EXTRA_CLANG_ARGS = "${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}" require ${BPN}-crates.inc require ${BPN}-git-crates.inc I propose submitting this patch to master in v2, from where it will be backported. Let me know if you agree or have an alternative suggestion. Thanks, Bo > > On Thu, Jul 24, 2025 at 4:44 AM Bo Sun via lists.openembedded.org > <Bo.Sun.CN=windriver.com@lists.openembedded.org> wrote: >> >> Remove unsupported '-mcpu=octeontx2+crypto' from BINDGEN_EXTRA_CLANG_ARGS >> as clang does not recognize 'octeontx2' as a valid target CPU, causing >> bindgen to fail when generating Rust bindings. >> >> Since bindgen only parses headers using Clang, CPU-specific options >> like -mcpu are generally unnecessary. >> >> Fixes build failure: >> | error: unsupported argument 'octeontx2+crypto' to option '-mcpu=' >> | error: unknown target CPU 'octeontx2' >> >> Signed-off-by: Bo Sun <bo.sun.cn@windriver.com> >> --- >> .../thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb | 5 ++++- >> 1 file changed, 4 insertions(+), 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 a60ca11244..4ed885f8b3 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 >> @@ -23,7 +23,10 @@ inherit pkgconfig >> DEPENDS += "udev libdevmapper libdevmapper-native clang-native" >> >> export LIBCLANG_PATH = "${STAGING_LIBDIR_NATIVE}" >> -export BINDGEN_EXTRA_CLANG_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}" >> +# Remove octeontx2 specific CPU flags that may cause issues with bindgen >> +BINDGEN_EXTRA_CLANG_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}" >> +BINDGEN_EXTRA_CLANG_ARGS:remove = "-mcpu=octeontx2+crypto" >> +export BINDGEN_EXTRA_CLANG_ARGS >> >> require ${BPN}-crates.inc >> require ${BPN}-git-crates.inc >> -- >> 2.50.1 >> >> >> -=-=-=-=-=-=-=-=-=-=-=- >> Links: You receive all messages sent to this group. >> View/Reply Online (#118723): https://lists.openembedded.org/g/openembedded-devel/message/118723 >> Mute This Topic: https://lists.openembedded.org/mt/114317423/1997914 >> Group Owner: openembedded-devel+owner@lists.openembedded.org >> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com] >> -=-=-=-=-=-=-=-=-=-=-=- >>
sounds good. On Fri, Jul 25, 2025 at 1:52 AM Bo Sun <Bo.Sun.CN@windriver.com> wrote: > > On 7/24/25 23:55, Khem Raj wrote: > > CAUTION: This email comes from a non Wind River email account! > > Do not click links or open attachments unless you recognize the sender and know the content is safe. > > > > while this fixes it for one recipe, we have to fix it as tune level in > > oe-core so remove it globally if we are using clang compiler. so > > perhaps adding it to clang.bbclass might be a good idea > > Yes, this fix does resolve the issue for this specific recipe. However, > I think fixing it at the recipe level is still a reasonable solution. > > Looking at the bindgen code, BINDGEN_EXTRA_CLANG_ARGS is parsed and used > directly by bindgen at runtime, not by BitBake: > > https://github.com/rust-lang/rust-bindgen/blob/de9627ffa4860c6ed56cd40470fc7a96afc09d44/bindgen/lib.rs#L300 > > fn get_extra_clang_args( > parse_callbacks: &[Rc<dyn callbacks::ParseCallbacks>], > ) -> Vec<String> { > // Add any extra arguments from the environment to the clang > command line. > let Some(extra_clang_args) = get_target_dependent_env_var( > parse_callbacks, > "BINDGEN_EXTRA_CLANG_ARGS", > ) else { > return vec![]; > }; > > https://github.com/rust-lang/rust-bindgen/blob/de9627ffa4860c6ed56cd40470fc7a96afc09d44/bindgen/lib.rs#L337 > > // Add any extra arguments from the environment to the clang > command line. > self.options.clang_args.extend( > get_extra_clang_args(&self.options.parse_callbacks) > .into_iter() > .map(String::into_boxed_str), > ); > > Additionally, base on the build.rs for devicemapper-sys, I believe we > can safely remove ${HOST_CC_ARCH} from this recipe. > > https://github.com/stratis-storage/devicemapper-rs/blob/master/devicemapper-rs-sys/build.rs > > $ git diff > 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 a60ca11244..e8173c9b14 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 > @@ -23,7 +23,7 @@ inherit pkgconfig > DEPENDS += "udev libdevmapper libdevmapper-native clang-native" > > export LIBCLANG_PATH = "${STAGING_LIBDIR_NATIVE}" > -export BINDGEN_EXTRA_CLANG_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} > --target=${TARGET_SYS}" > +export BINDGEN_EXTRA_CLANG_ARGS = "${TOOLCHAIN_OPTIONS} > --target=${TARGET_SYS}" > > require ${BPN}-crates.inc > require ${BPN}-git-crates.inc > > I propose submitting this patch to master in v2, from where it will be > backported. Let me know if you agree or have an alternative suggestion. > > > Thanks, > Bo > > > > > On Thu, Jul 24, 2025 at 4:44 AM Bo Sun via lists.openembedded.org > > <Bo.Sun.CN=windriver.com@lists.openembedded.org> wrote: > >> > >> Remove unsupported '-mcpu=octeontx2+crypto' from BINDGEN_EXTRA_CLANG_ARGS > >> as clang does not recognize 'octeontx2' as a valid target CPU, causing > >> bindgen to fail when generating Rust bindings. > >> > >> Since bindgen only parses headers using Clang, CPU-specific options > >> like -mcpu are generally unnecessary. > >> > >> Fixes build failure: > >> | error: unsupported argument 'octeontx2+crypto' to option '-mcpu=' > >> | error: unknown target CPU 'octeontx2' > >> > >> Signed-off-by: Bo Sun <bo.sun.cn@windriver.com> > >> --- > >> .../thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb | 5 ++++- > >> 1 file changed, 4 insertions(+), 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 a60ca11244..4ed885f8b3 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 > >> @@ -23,7 +23,10 @@ inherit pkgconfig > >> DEPENDS += "udev libdevmapper libdevmapper-native clang-native" > >> > >> export LIBCLANG_PATH = "${STAGING_LIBDIR_NATIVE}" > >> -export BINDGEN_EXTRA_CLANG_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}" > >> +# Remove octeontx2 specific CPU flags that may cause issues with bindgen > >> +BINDGEN_EXTRA_CLANG_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}" > >> +BINDGEN_EXTRA_CLANG_ARGS:remove = "-mcpu=octeontx2+crypto" > >> +export BINDGEN_EXTRA_CLANG_ARGS > >> > >> require ${BPN}-crates.inc > >> require ${BPN}-git-crates.inc > >> -- > >> 2.50.1 > >> > >> > >> -=-=-=-=-=-=-=-=-=-=-=- > >> Links: You receive all messages sent to this group. > >> View/Reply Online (#118723): https://lists.openembedded.org/g/openembedded-devel/message/118723 > >> Mute This Topic: https://lists.openembedded.org/mt/114317423/1997914 > >> Group Owner: openembedded-devel+owner@lists.openembedded.org > >> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com] > >> -=-=-=-=-=-=-=-=-=-=-=- > >> >
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 a60ca11244..4ed885f8b3 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 @@ -23,7 +23,10 @@ inherit pkgconfig DEPENDS += "udev libdevmapper libdevmapper-native clang-native" export LIBCLANG_PATH = "${STAGING_LIBDIR_NATIVE}" -export BINDGEN_EXTRA_CLANG_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}" +# Remove octeontx2 specific CPU flags that may cause issues with bindgen +BINDGEN_EXTRA_CLANG_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}" +BINDGEN_EXTRA_CLANG_ARGS:remove = "-mcpu=octeontx2+crypto" +export BINDGEN_EXTRA_CLANG_ARGS require ${BPN}-crates.inc require ${BPN}-git-crates.inc
Remove unsupported '-mcpu=octeontx2+crypto' from BINDGEN_EXTRA_CLANG_ARGS as clang does not recognize 'octeontx2' as a valid target CPU, causing bindgen to fail when generating Rust bindings. Since bindgen only parses headers using Clang, CPU-specific options like -mcpu are generally unnecessary. Fixes build failure: | error: unsupported argument 'octeontx2+crypto' to option '-mcpu=' | error: unknown target CPU 'octeontx2' Signed-off-by: Bo Sun <bo.sun.cn@windriver.com> --- .../thin-provisioning-tools/thin-provisioning-tools_1.1.0.bb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)