diff mbox series

mesa: Fix bindgen includes

Message ID 20250610142413.681911-1-zboszor@gmail.com
State New
Headers show
Series mesa: Fix bindgen includes | expand

Commit Message

Böszörményi Zoltán June 10, 2025, 2:24 p.m. UTC
Add a patch to fix bindgen errors due to not finding headers
in the system, like:

|...
| ../mesa-25.1.2/src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp:1:10: fatal error: 'clang/Basic/Version.h' file not found
| Unable to generate bindings: clang diagnosed error: ../mesa-25.1.2/src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp:1:10: fatal error: 'clang/Basic/Version.h' file not found
|...
| .../work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/include/./GL/glx.h:30:10: fatal error: 'X11/Xlib.h' file not found
| Unable to generate bindings: clang diagnosed error: /data2/dtd-yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/include/./GL/glx.h:30:10: fatal error: 'X11/Xlib.h' file not found

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
---
 ...w-build-option-for-extra-bindgen-inc.patch | 57 +++++++++++++++++++
 meta/recipes-graphics/mesa/mesa.inc           |  3 +-
 2 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-graphics/mesa/files/0001-rusticl-Add-a-new-build-option-for-extra-bindgen-inc.patch

Comments

Dmitry Baryshkov June 10, 2025, 7:49 p.m. UTC | #1
On Tue, 10 Jun 2025 at 17:24, Zoltán Böszörményi <zboszor@gmail.com> wrote:
>
> Add a patch to fix bindgen errors due to not finding headers
> in the system, like:
>
> |...
> | ../mesa-25.1.2/src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp:1:10: fatal error: 'clang/Basic/Version.h' file not found
> | Unable to generate bindings: clang diagnosed error: ../mesa-25.1.2/src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp:1:10: fatal error: 'clang/Basic/Version.h' file not found
> |...
> | .../work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/include/./GL/glx.h:30:10: fatal error: 'X11/Xlib.h' file not found
> | Unable to generate bindings: clang diagnosed error: /data2/dtd-yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/include/./GL/glx.h:30:10: fatal error: 'X11/Xlib.h' file not found

Can we fix this on the meson side by passing additional include path
through the cross file?

>
> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
> ---
>  ...w-build-option-for-extra-bindgen-inc.patch | 57 +++++++++++++++++++
>  meta/recipes-graphics/mesa/mesa.inc           |  3 +-
>  2 files changed, 59 insertions(+), 1 deletion(-)
>  create mode 100644 meta/recipes-graphics/mesa/files/0001-rusticl-Add-a-new-build-option-for-extra-bindgen-inc.patch
>
Böszörményi Zoltán June 11, 2025, 10:46 a.m. UTC | #2
2025. 06. 10. 21:49 keltezéssel, Dmitry Baryshkov via lists.openembedded.org írta:
> On Tue, 10 Jun 2025 at 17:24, Zoltán Böszörményi <zboszor@gmail.com> wrote:
>> Add a patch to fix bindgen errors due to not finding headers
>> in the system, like:
>>
>> |...
>> | ../mesa-25.1.2/src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp:1:10: fatal error: 'clang/Basic/Version.h' file not found
>> | Unable to generate bindings: clang diagnosed error: ../mesa-25.1.2/src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp:1:10: fatal error: 'clang/Basic/Version.h' file not found
>> |...
>> | .../work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/include/./GL/glx.h:30:10: fatal error: 'X11/Xlib.h' file not found
>> | Unable to generate bindings: clang diagnosed error: /data2/dtd-yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/include/./GL/glx.h:30:10: fatal error: 'X11/Xlib.h' file not found
> Can we fix this on the meson side by passing additional include path
> through the cross file?

This seems to work in mesa.inc without patching Mesa:

CFLAGS:append:class-target = " -I${STAGING_INCDIR}"
CXXFLAGS:append:class-target = " -I${STAGING_INCDIR}"

but it also[1] prints this for some of the bindgen runs:

clang diag: 
/home/zozo/yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/mesa/25.1.3/recipe-sysroot/usr/include/stdint.h:95:11: 
warning: '__INT64_C' macro redefined [-Wmacro-redefined]
clang diag: 
/home/zozo/yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/mesa/25.1.3/recipe-sysroot/usr/include/stdint.h:96:11: 
warning: '__UINT64_C' macro redefined [-Wmacro-redefined]

[1] Using the previously posted patch also prints the same.

It seems to be caused by a meson bug because it doesn't
collect the -isystem or --sysroot flags for rust/bindgen.
See the discussion at the MR link in the patch.

CFLAGS and CXXFLAGS changes are both needed because
bindgen is run on both .h and .hpp files for rusticl.

>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>> ---
>>   ...w-build-option-for-extra-bindgen-inc.patch | 57 +++++++++++++++++++
>>   meta/recipes-graphics/mesa/mesa.inc           |  3 +-
>>   2 files changed, 59 insertions(+), 1 deletion(-)
>>   create mode 100644 meta/recipes-graphics/mesa/files/0001-rusticl-Add-a-new-build-option-for-extra-bindgen-inc.patch
>>
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#218438): https://lists.openembedded.org/g/openembedded-core/message/218438
> Mute This Topic: https://lists.openembedded.org/mt/113570520/3617728
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [zboszor@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Dmitry Baryshkov June 11, 2025, 5:34 p.m. UTC | #3
On 11/06/2025 13:46, Böszörményi Zoltán wrote:
> 2025. 06. 10. 21:49 keltezéssel, Dmitry Baryshkov via 
> lists.openembedded.org írta:
>> On Tue, 10 Jun 2025 at 17:24, Zoltán Böszörményi <zboszor@gmail.com> 
>> wrote:
>>> Add a patch to fix bindgen errors due to not finding headers
>>> in the system, like:
>>>
>>> |...
>>> | ../mesa-25.1.2/src/gallium/frontends/rusticl/ 
>>> rusticl_llvm_bindings.hpp:1:10: fatal error: 'clang/Basic/Version.h' 
>>> file not found
>>> | Unable to generate bindings: clang diagnosed error: ../mesa-25.1.2/ 
>>> src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp:1:10: fatal 
>>> error: 'clang/Basic/Version.h' file not found
>>> |...
>>> | .../work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/include/./GL/ 
>>> glx.h:30:10: fatal error: 'X11/Xlib.h' file not found
>>> | Unable to generate bindings: clang diagnosed error: /data2/dtd- 
>>> yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/ 
>>> include/./GL/glx.h:30:10: fatal error: 'X11/Xlib.h' file not found
>> Can we fix this on the meson side by passing additional include path
>> through the cross file?
> 
> This seems to work in mesa.inc without patching Mesa:
> 
> CFLAGS:append:class-target = " -I${STAGING_INCDIR}"
> CXXFLAGS:append:class-target = " -I${STAGING_INCDIR}"

My question was more about meson.bbclass, where we set 
bindgen_clang_args. See the bindgen_args() function.

> 
> but it also[1] prints this for some of the bindgen runs:
> 
> clang diag: /home/zozo/yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/ 
> mesa/25.1.3/recipe-sysroot/usr/include/stdint.h:95:11: warning: 
> '__INT64_C' macro redefined [-Wmacro-redefined]
> clang diag: /home/zozo/yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/ 
> mesa/25.1.3/recipe-sysroot/usr/include/stdint.h:96:11: warning: 
> '__UINT64_C' macro redefined [-Wmacro-redefined]
> 
> [1] Using the previously posted patch also prints the same.
> 
> It seems to be caused by a meson bug because it doesn't
> collect the -isystem or --sysroot flags for rust/bindgen.
> See the discussion at the MR link in the patch.
> 
> CFLAGS and CXXFLAGS changes are both needed because
> bindgen is run on both .h and .hpp files for rusticl.
> 
>>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>>> ---
>>>   ...w-build-option-for-extra-bindgen-inc.patch | 57 +++++++++++++++++++
>>>   meta/recipes-graphics/mesa/mesa.inc           |  3 +-
>>>   2 files changed, 59 insertions(+), 1 deletion(-)
>>>   create mode 100644 meta/recipes-graphics/mesa/files/0001-rusticl- 
>>> Add-a-new-build-option-for-extra-bindgen-inc.patch
>>>
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#218438): https://lists.openembedded.org/g/ 
>> openembedded-core/message/218438
>> Mute This Topic: https://lists.openembedded.org/mt/113570520/3617728
>> Group Owner: openembedded-core+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
>> [zboszor@gmail.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
>
Böszörményi Zoltán June 11, 2025, 6:36 p.m. UTC | #4
2025. 06. 11. 19:34 keltezéssel, Dmitry Baryshkov írta:
> On 11/06/2025 13:46, Böszörményi Zoltán wrote:
>> 2025. 06. 10. 21:49 keltezéssel, Dmitry Baryshkov via lists.openembedded.org írta:
>>> On Tue, 10 Jun 2025 at 17:24, Zoltán Böszörményi <zboszor@gmail.com> wrote:
>>>> Add a patch to fix bindgen errors due to not finding headers
>>>> in the system, like:
>>>>
>>>> |...
>>>> | ../mesa-25.1.2/src/gallium/frontends/rusticl/ rusticl_llvm_bindings.hpp:1:10: fatal 
>>>> error: 'clang/Basic/Version.h' file not found
>>>> | Unable to generate bindings: clang diagnosed error: ../mesa-25.1.2/ 
>>>> src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp:1:10: fatal error: 
>>>> 'clang/Basic/Version.h' file not found
>>>> |...
>>>> | .../work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/include/./GL/ glx.h:30:10: 
>>>> fatal error: 'X11/Xlib.h' file not found
>>>> | Unable to generate bindings: clang diagnosed error: /data2/dtd- 
>>>> yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/ 
>>>> include/./GL/glx.h:30:10: fatal error: 'X11/Xlib.h' file not found
>>> Can we fix this on the meson side by passing additional include path
>>> through the cross file?
>>
>> This seems to work in mesa.inc without patching Mesa:
>>
>> CFLAGS:append:class-target = " -I${STAGING_INCDIR}"
>> CXXFLAGS:append:class-target = " -I${STAGING_INCDIR}"
>
> My question was more about meson.bbclass, where we set bindgen_clang_args. See the 
> bindgen_args() function.

I wouldn't change meson.bbclass because it works for the
most recipes already.

Besides, it seems to be a meson bug, not a meson.bbclass bug
as -isystem and other include path related flags (besides -I) are
ignored in CFLAGS/CXXFLAGS.

The "clang diag" messages are likely coming from mixed up host
vs target header paths.

See
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35435#note_2952621
https://github.com/mesonbuild/meson/blob/master/mesonbuild/modules/rust.py#L392-L397

If we changed meson.bbclass to add -I${STAGING_INCDIR} to
the proper places in meson.cross, it would still print the
clang diag warning. Adding -isystem would still get ignored.

FWIW, --sysroot is also ignored by meson and adding it forcibly
throws a different error. See
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35435#note_2952805

¯\_(ツ)_/¯

>> but it also[1] prints this for some of the bindgen runs:
>>
>> clang diag: /home/zozo/yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/ 
>> mesa/25.1.3/recipe-sysroot/usr/include/stdint.h:95:11: warning: '__INT64_C' macro 
>> redefined [-Wmacro-redefined]
>> clang diag: /home/zozo/yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/ 
>> mesa/25.1.3/recipe-sysroot/usr/include/stdint.h:96:11: warning: '__UINT64_C' macro 
>> redefined [-Wmacro-redefined]
>>
>> [1] Using the previously posted patch also prints the same.
>>
>> It seems to be caused by a meson bug because it doesn't
>> collect the -isystem or --sysroot flags for rust/bindgen.
>> See the discussion at the MR link in the patch.
>>
>> CFLAGS and CXXFLAGS changes are both needed because
>> bindgen is run on both .h and .hpp files for rusticl.
>>
>>>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>>>> ---
>>>>   ...w-build-option-for-extra-bindgen-inc.patch | 57 +++++++++++++++++++
>>>>   meta/recipes-graphics/mesa/mesa.inc           |  3 +-
>>>>   2 files changed, 59 insertions(+), 1 deletion(-)
>>>>   create mode 100644 meta/recipes-graphics/mesa/files/0001-rusticl- 
>>>> Add-a-new-build-option-for-extra-bindgen-inc.patch
>>>>
>>>
>>>
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>> Links: You receive all messages sent to this group.
>>> View/Reply Online (#218438): https://lists.openembedded.org/g/ 
>>> openembedded-core/message/218438
>>> Mute This Topic: https://lists.openembedded.org/mt/113570520/3617728
>>> Group Owner: openembedded-core+owner@lists.openembedded.org
>>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [zboszor@gmail.com]
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>
>>
>
>
Dmitry Baryshkov June 11, 2025, 7:32 p.m. UTC | #5
On Wed, 11 Jun 2025 at 21:36, Böszörményi Zoltán <zboszor@gmail.com> wrote:
>
> 2025. 06. 11. 19:34 keltezéssel, Dmitry Baryshkov írta:
> > On 11/06/2025 13:46, Böszörményi Zoltán wrote:
> >> 2025. 06. 10. 21:49 keltezéssel, Dmitry Baryshkov via lists.openembedded.org írta:
> >>> On Tue, 10 Jun 2025 at 17:24, Zoltán Böszörményi <zboszor@gmail.com> wrote:
> >>>> Add a patch to fix bindgen errors due to not finding headers
> >>>> in the system, like:
> >>>>
> >>>> |...
> >>>> | ../mesa-25.1.2/src/gallium/frontends/rusticl/ rusticl_llvm_bindings.hpp:1:10: fatal
> >>>> error: 'clang/Basic/Version.h' file not found
> >>>> | Unable to generate bindings: clang diagnosed error: ../mesa-25.1.2/
> >>>> src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp:1:10: fatal error:
> >>>> 'clang/Basic/Version.h' file not found
> >>>> |...
> >>>> | .../work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/include/./GL/ glx.h:30:10:
> >>>> fatal error: 'X11/Xlib.h' file not found
> >>>> | Unable to generate bindings: clang diagnosed error: /data2/dtd-
> >>>> yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/
> >>>> include/./GL/glx.h:30:10: fatal error: 'X11/Xlib.h' file not found
> >>> Can we fix this on the meson side by passing additional include path
> >>> through the cross file?
> >>
> >> This seems to work in mesa.inc without patching Mesa:
> >>
> >> CFLAGS:append:class-target = " -I${STAGING_INCDIR}"
> >> CXXFLAGS:append:class-target = " -I${STAGING_INCDIR}"
> >
> > My question was more about meson.bbclass, where we set bindgen_clang_args. See the
> > bindgen_args() function.
>
> I wouldn't change meson.bbclass because it works for the
> most recipes already.

The bindgen_args was implemented for mesa as the first user. It is not
frequent for the packaged software to use rust.bindgen.

>
> Besides, it seems to be a meson bug, not a meson.bbclass bug
> as -isystem and other include path related flags (besides -I) are
> ignored in CFLAGS/CXXFLAGS.
>
> The "clang diag" messages are likely coming from mixed up host
> vs target header paths.
>
> See
> https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35435#note_2952621
> https://github.com/mesonbuild/meson/blob/master/mesonbuild/modules/rust.py#L392-L397
>
> If we changed meson.bbclass to add -I${STAGING_INCDIR} to
> the proper places in meson.cross, it would still print the
> clang diag warning. Adding -isystem would still get ignored.

Are we ta

>
> FWIW, --sysroot is also ignored by meson and adding it forcibly
> throws a different error. See
> https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35435#note_2952805

How were you passing it? Via CFLAGS / CPPFLAGS or via bindgen args?

>
> ¯\_(ツ)_/¯
>
> >> but it also[1] prints this for some of the bindgen runs:
> >>
> >> clang diag: /home/zozo/yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/
> >> mesa/25.1.3/recipe-sysroot/usr/include/stdint.h:95:11: warning: '__INT64_C' macro
> >> redefined [-Wmacro-redefined]
> >> clang diag: /home/zozo/yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/
> >> mesa/25.1.3/recipe-sysroot/usr/include/stdint.h:96:11: warning: '__UINT64_C' macro
> >> redefined [-Wmacro-redefined]
> >>
> >> [1] Using the previously posted patch also prints the same.
> >>
> >> It seems to be caused by a meson bug because it doesn't
> >> collect the -isystem or --sysroot flags for rust/bindgen.
> >> See the discussion at the MR link in the patch.
> >>
> >> CFLAGS and CXXFLAGS changes are both needed because
> >> bindgen is run on both .h and .hpp files for rusticl.
> >>
> >>>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
> >>>> ---
> >>>>   ...w-build-option-for-extra-bindgen-inc.patch | 57 +++++++++++++++++++
> >>>>   meta/recipes-graphics/mesa/mesa.inc           |  3 +-
> >>>>   2 files changed, 59 insertions(+), 1 deletion(-)
> >>>>   create mode 100644 meta/recipes-graphics/mesa/files/0001-rusticl-
> >>>> Add-a-new-build-option-for-extra-bindgen-inc.patch
> >>>>
> >>>
> >>>
> >>> -=-=-=-=-=-=-=-=-=-=-=-
> >>> Links: You receive all messages sent to this group.
> >>> View/Reply Online (#218438): https://lists.openembedded.org/g/
> >>> openembedded-core/message/218438
> >>> Mute This Topic: https://lists.openembedded.org/mt/113570520/3617728
> >>> Group Owner: openembedded-core+owner@lists.openembedded.org
> >>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [zboszor@gmail.com]
> >>> -=-=-=-=-=-=-=-=-=-=-=-
> >>>
> >>
> >
> >
>
Böszörményi Zoltán June 12, 2025, 4:23 a.m. UTC | #6
2025. 06. 11. 21:32 keltezéssel, Dmitry Baryshkov írta:
> On Wed, 11 Jun 2025 at 21:36, Böszörményi Zoltán <zboszor@gmail.com> wrote:
>> 2025. 06. 11. 19:34 keltezéssel, Dmitry Baryshkov írta:
>>> On 11/06/2025 13:46, Böszörményi Zoltán wrote:
>>>> 2025. 06. 10. 21:49 keltezéssel, Dmitry Baryshkov via lists.openembedded.org írta:
>>>>> On Tue, 10 Jun 2025 at 17:24, Zoltán Böszörményi <zboszor@gmail.com> wrote:
>>>>>> Add a patch to fix bindgen errors due to not finding headers
>>>>>> in the system, like:
>>>>>>
>>>>>> |...
>>>>>> | ../mesa-25.1.2/src/gallium/frontends/rusticl/ rusticl_llvm_bindings.hpp:1:10: fatal
>>>>>> error: 'clang/Basic/Version.h' file not found
>>>>>> | Unable to generate bindings: clang diagnosed error: ../mesa-25.1.2/
>>>>>> src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp:1:10: fatal error:
>>>>>> 'clang/Basic/Version.h' file not found
>>>>>> |...
>>>>>> | .../work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/include/./GL/ glx.h:30:10:
>>>>>> fatal error: 'X11/Xlib.h' file not found
>>>>>> | Unable to generate bindings: clang diagnosed error: /data2/dtd-
>>>>>> yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/
>>>>>> include/./GL/glx.h:30:10: fatal error: 'X11/Xlib.h' file not found
>>>>> Can we fix this on the meson side by passing additional include path
>>>>> through the cross file?
>>>> This seems to work in mesa.inc without patching Mesa:
>>>>
>>>> CFLAGS:append:class-target = " -I${STAGING_INCDIR}"
>>>> CXXFLAGS:append:class-target = " -I${STAGING_INCDIR}"
>>> My question was more about meson.bbclass, where we set bindgen_clang_args. See the
>>> bindgen_args() function.
>> I wouldn't change meson.bbclass because it works for the
>> most recipes already.
> The bindgen_args was implemented for mesa as the first user. It is not
> frequent for the packaged software to use rust.bindgen.
>
>> Besides, it seems to be a meson bug, not a meson.bbclass bug
>> as -isystem and other include path related flags (besides -I) are
>> ignored in CFLAGS/CXXFLAGS.
>>
>> The "clang diag" messages are likely coming from mixed up host
>> vs target header paths.
>>
>> See
>> https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35435#note_2952621
>> https://github.com/mesonbuild/meson/blob/master/mesonbuild/modules/rust.py#L392-L397
>>
>> If we changed meson.bbclass to add -I${STAGING_INCDIR} to
>> the proper places in meson.cross, it would still print the
>> clang diag warning. Adding -isystem would still get ignored.
> Are we ta

???

>> FWIW, --sysroot is also ignored by meson and adding it forcibly
>> throws a different error. See
>> https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35435#note_2952805
> How were you passing it? Via CFLAGS / CPPFLAGS or via bindgen args?

Using  this patch and -Dbindgen-sysroot=${STAGING_DIR_TARGET}
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35435/diffs?commit_id=a82381aeaba32775db51080b823893e4b6f647fb

--sysroot is not passing through to bindgen from CFLAGS/CXXFLAGS
due to the filtering of flags in meson by the already qouted code piece at
https://github.com/mesonbuild/meson/blob/master/mesonbuild/modules/rust.py#L392-L397

>> ¯\_(ツ)_/¯
>>
>>>> but it also[1] prints this for some of the bindgen runs:
>>>>
>>>> clang diag: /home/zozo/yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/
>>>> mesa/25.1.3/recipe-sysroot/usr/include/stdint.h:95:11: warning: '__INT64_C' macro
>>>> redefined [-Wmacro-redefined]
>>>> clang diag: /home/zozo/yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/
>>>> mesa/25.1.3/recipe-sysroot/usr/include/stdint.h:96:11: warning: '__UINT64_C' macro
>>>> redefined [-Wmacro-redefined]
>>>>
>>>> [1] Using the previously posted patch also prints the same.
>>>>
>>>> It seems to be caused by a meson bug because it doesn't
>>>> collect the -isystem or --sysroot flags for rust/bindgen.
>>>> See the discussion at the MR link in the patch.
>>>>
>>>> CFLAGS and CXXFLAGS changes are both needed because
>>>> bindgen is run on both .h and .hpp files for rusticl.
>>>>
>>>>>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>>>>>> ---
>>>>>>    ...w-build-option-for-extra-bindgen-inc.patch | 57 +++++++++++++++++++
>>>>>>    meta/recipes-graphics/mesa/mesa.inc           |  3 +-
>>>>>>    2 files changed, 59 insertions(+), 1 deletion(-)
>>>>>>    create mode 100644 meta/recipes-graphics/mesa/files/0001-rusticl-
>>>>>> Add-a-new-build-option-for-extra-bindgen-inc.patch
>>>>>>
>>>>>
>>>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>>> Links: You receive all messages sent to this group.
>>>>> View/Reply Online (#218438): https://lists.openembedded.org/g/
>>>>> openembedded-core/message/218438
>>>>> Mute This Topic: https://lists.openembedded.org/mt/113570520/3617728
>>>>> Group Owner: openembedded-core+owner@lists.openembedded.org
>>>>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [zboszor@gmail.com]
>>>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>>>
>>>
>
Dmitry Baryshkov June 12, 2025, 8:08 a.m. UTC | #7
On 12/06/2025 07:23, Böszörményi Zoltán wrote:
> 2025. 06. 11. 21:32 keltezéssel, Dmitry Baryshkov írta:
>> On Wed, 11 Jun 2025 at 21:36, Böszörményi Zoltán <zboszor@gmail.com> 
>> wrote:
>>> 2025. 06. 11. 19:34 keltezéssel, Dmitry Baryshkov írta:
>>>> On 11/06/2025 13:46, Böszörményi Zoltán wrote:
>>>>> 2025. 06. 10. 21:49 keltezéssel, Dmitry Baryshkov via 
>>>>> lists.openembedded.org írta:
>>>>>> On Tue, 10 Jun 2025 at 17:24, Zoltán Böszörményi 
>>>>>> <zboszor@gmail.com> wrote:
>>>>>>> Add a patch to fix bindgen errors due to not finding headers
>>>>>>> in the system, like:
>>>>>>>
>>>>>>> |...
>>>>>>> | ../mesa-25.1.2/src/gallium/frontends/rusticl/ 
>>>>>>> rusticl_llvm_bindings.hpp:1:10: fatal
>>>>>>> error: 'clang/Basic/Version.h' file not found
>>>>>>> | Unable to generate bindings: clang diagnosed error: ../ 
>>>>>>> mesa-25.1.2/
>>>>>>> src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp:1:10: 
>>>>>>> fatal error:
>>>>>>> 'clang/Basic/Version.h' file not found
>>>>>>> |...
>>>>>>> | .../work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/include/./ 
>>>>>>> GL/ glx.h:30:10:
>>>>>>> fatal error: 'X11/Xlib.h' file not found
>>>>>>> | Unable to generate bindings: clang diagnosed error: /data2/dtd-
>>>>>>> yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/
>>>>>>> include/./GL/glx.h:30:10: fatal error: 'X11/Xlib.h' file not found
>>>>>> Can we fix this on the meson side by passing additional include path
>>>>>> through the cross file?
>>>>> This seems to work in mesa.inc without patching Mesa:
>>>>>
>>>>> CFLAGS:append:class-target = " -I${STAGING_INCDIR}"
>>>>> CXXFLAGS:append:class-target = " -I${STAGING_INCDIR}"
>>>> My question was more about meson.bbclass, where we set 
>>>> bindgen_clang_args. See the
>>>> bindgen_args() function.
>>> I wouldn't change meson.bbclass because it works for the
>>> most recipes already.
>> The bindgen_args was implemented for mesa as the first user. It is not
>> frequent for the packaged software to use rust.bindgen.
>>
>>> Besides, it seems to be a meson bug, not a meson.bbclass bug
>>> as -isystem and other include path related flags (besides -I) are
>>> ignored in CFLAGS/CXXFLAGS.
>>>
>>> The "clang diag" messages are likely coming from mixed up host
>>> vs target header paths.
>>>
>>> See
>>> https://gitlab.freedesktop.org/mesa/mesa/-/ 
>>> merge_requests/35435#note_2952621
>>> https://github.com/mesonbuild/meson/blob/master/mesonbuild/modules/ 
>>> rust.py#L392-L397
>>>
>>> If we changed meson.bbclass to add -I${STAGING_INCDIR} to
>>> the proper places in meson.cross, it would still print the
>>> clang diag warning. Adding -isystem would still get ignored.
>> Are we ta
> 
> ???
> 
>>> FWIW, --sysroot is also ignored by meson and adding it forcibly
>>> throws a different error. See
>>> https://gitlab.freedesktop.org/mesa/mesa/-/ 
>>> merge_requests/35435#note_2952805
>> How were you passing it? Via CFLAGS / CPPFLAGS or via bindgen args?
> 
> Using  this patch and -Dbindgen-sysroot=${STAGING_DIR_TARGET}
> https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35435/diffs? 
> commit_id=a82381aeaba32775db51080b823893e4b6f647fb
> 
> --sysroot is not passing through to bindgen from CFLAGS/CXXFLAGS
> due to the filtering of flags in meson by the already qouted code piece at
> https://github.com/mesonbuild/meson/blob/master/mesonbuild/modules/ 
> rust.py#L392-L397

Can we pass those flags via bindgen_clang_args? If I understand 
correctly, then they will bypass all the filtering.

> 
>>> ¯\_(ツ)_/¯
>>>
>>>>> but it also[1] prints this for some of the bindgen runs:
>>>>>
>>>>> clang diag: /home/zozo/yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/
>>>>> mesa/25.1.3/recipe-sysroot/usr/include/stdint.h:95:11: warning: 
>>>>> '__INT64_C' macro
>>>>> redefined [-Wmacro-redefined]
>>>>> clang diag: /home/zozo/yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/
>>>>> mesa/25.1.3/recipe-sysroot/usr/include/stdint.h:96:11: warning: 
>>>>> '__UINT64_C' macro
>>>>> redefined [-Wmacro-redefined]
>>>>>
>>>>> [1] Using the previously posted patch also prints the same.
>>>>>
>>>>> It seems to be caused by a meson bug because it doesn't
>>>>> collect the -isystem or --sysroot flags for rust/bindgen.
>>>>> See the discussion at the MR link in the patch.
>>>>>
>>>>> CFLAGS and CXXFLAGS changes are both needed because
>>>>> bindgen is run on both .h and .hpp files for rusticl.
>>>>>
>>>>>>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>>>>>>> ---
>>>>>>>    ...w-build-option-for-extra-bindgen-inc.patch | 57 +++++++++++ 
>>>>>>> ++++++++
>>>>>>>    meta/recipes-graphics/mesa/mesa.inc           |  3 +-
>>>>>>>    2 files changed, 59 insertions(+), 1 deletion(-)
>>>>>>>    create mode 100644 meta/recipes-graphics/mesa/files/0001-rusticl-
>>>>>>> Add-a-new-build-option-for-extra-bindgen-inc.patch
>>>>>>>
>>>>>>
>>>>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>>>> Links: You receive all messages sent to this group.
>>>>>> View/Reply Online (#218438): https://lists.openembedded.org/g/
>>>>>> openembedded-core/message/218438
>>>>>> Mute This Topic: https://lists.openembedded.org/mt/113570520/3617728
>>>>>> Group Owner: openembedded-core+owner@lists.openembedded.org
>>>>>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/ 
>>>>>> unsub [zboszor@gmail.com]
>>>>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>>>>
>>>>
>>
>
Böszörményi Zoltán June 12, 2025, 1:48 p.m. UTC | #8
2025. 06. 12. 10:08 keltezéssel, Dmitry Baryshkov írta:
> On 12/06/2025 07:23, Böszörményi Zoltán wrote:
>> 2025. 06. 11. 21:32 keltezéssel, Dmitry Baryshkov írta:
>>> On Wed, 11 Jun 2025 at 21:36, Böszörményi Zoltán <zboszor@gmail.com> wrote:
>>>> 2025. 06. 11. 19:34 keltezéssel, Dmitry Baryshkov írta:
>>>>> On 11/06/2025 13:46, Böszörményi Zoltán wrote:
>>>>>> 2025. 06. 10. 21:49 keltezéssel, Dmitry Baryshkov via lists.openembedded.org írta:
>>>>>>> On Tue, 10 Jun 2025 at 17:24, Zoltán Böszörményi <zboszor@gmail.com> wrote:
>>>>>>>> Add a patch to fix bindgen errors due to not finding headers
>>>>>>>> in the system, like:
>>>>>>>>
>>>>>>>> |...
>>>>>>>> | ../mesa-25.1.2/src/gallium/frontends/rusticl/ rusticl_llvm_bindings.hpp:1:10: 
>>>>>>>> fatal
>>>>>>>> error: 'clang/Basic/Version.h' file not found
>>>>>>>> | Unable to generate bindings: clang diagnosed error: ../ mesa-25.1.2/
>>>>>>>> src/gallium/frontends/rusticl/rusticl_llvm_bindings.hpp:1:10: fatal error:
>>>>>>>> 'clang/Basic/Version.h' file not found
>>>>>>>> |...
>>>>>>>> | .../work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/include/./ GL/ glx.h:30:10:
>>>>>>>> fatal error: 'X11/Xlib.h' file not found
>>>>>>>> | Unable to generate bindings: clang diagnosed error: /data2/dtd-
>>>>>>>> yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/mesa/25.1.2/mesa-25.1.2/
>>>>>>>> include/./GL/glx.h:30:10: fatal error: 'X11/Xlib.h' file not found
>>>>>>> Can we fix this on the meson side by passing additional include path
>>>>>>> through the cross file?
>>>>>> This seems to work in mesa.inc without patching Mesa:
>>>>>>
>>>>>> CFLAGS:append:class-target = " -I${STAGING_INCDIR}"
>>>>>> CXXFLAGS:append:class-target = " -I${STAGING_INCDIR}"
>>>>> My question was more about meson.bbclass, where we set bindgen_clang_args. See the
>>>>> bindgen_args() function.
>>>> I wouldn't change meson.bbclass because it works for the
>>>> most recipes already.
>>> The bindgen_args was implemented for mesa as the first user. It is not
>>> frequent for the packaged software to use rust.bindgen.
>>>
>>>> Besides, it seems to be a meson bug, not a meson.bbclass bug
>>>> as -isystem and other include path related flags (besides -I) are
>>>> ignored in CFLAGS/CXXFLAGS.
>>>>
>>>> The "clang diag" messages are likely coming from mixed up host
>>>> vs target header paths.
>>>>
>>>> See
>>>> https://gitlab.freedesktop.org/mesa/mesa/-/ merge_requests/35435#note_2952621
>>>> https://github.com/mesonbuild/meson/blob/master/mesonbuild/modules/ rust.py#L392-L397
>>>>
>>>> If we changed meson.bbclass to add -I${STAGING_INCDIR} to
>>>> the proper places in meson.cross, it would still print the
>>>> clang diag warning. Adding -isystem would still get ignored.
>>> Are we ta
>>
>> ???
>>
>>>> FWIW, --sysroot is also ignored by meson and adding it forcibly
>>>> throws a different error. See
>>>> https://gitlab.freedesktop.org/mesa/mesa/-/ merge_requests/35435#note_2952805
>>> How were you passing it? Via CFLAGS / CPPFLAGS or via bindgen args?
>>
>> Using  this patch and -Dbindgen-sysroot=${STAGING_DIR_TARGET}
>> https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35435/diffs? 
>> commit_id=a82381aeaba32775db51080b823893e4b6f647fb
>>
>> --sysroot is not passing through to bindgen from CFLAGS/CXXFLAGS
>> due to the filtering of flags in meson by the already qouted code piece at
>> https://github.com/mesonbuild/meson/blob/master/mesonbuild/modules/ rust.py#L392-L397
>
> Can we pass those flags via bindgen_clang_args? If I understand correctly, then they 
> will bypass all the filtering.

You mean these changes from master?

commit 40008d55c01681c60088e5b7defb0b8513a4ed1c
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Date:   Fri Apr 18 03:57:12 2025 +0300

     meson: pass -target and -I to bindgen calls

     In order to properly generate Rust bindings for the target systems, we
     need to pass '-taget foo-linux-gnueabi' flags and a correct include
     target include path (${STAGING_INCDIR}) to the bindgen. Add those
     flags to the generated meson target file.

     Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
     Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

and

commit a647a0ff4c4eb7a7c1f6ec84a574f7d7796b6178
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Date:   Mon May 5 19:22:30 2025 -0700

     meson: correct bindgen_clang_argments

     Follow the changes in Clang search paths and specify sysroot via the
     TOOLCHAIN_OPTIONS, otherwise clang will fail to find system headers when
     executed by bindgen.

     For SDK packages TOOLCHAIN_OPTIONS don't contain full sysroot path, so
     specify the correct directory explicitly.

     Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
     Signed-off-by: Khem Raj <raj.khem@gmail.com>
     Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
     Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

Hurray, they help building the backported mesa recipe on Yocto 5.2.

These two commits should be backported to walnascar. Pretty please.

>
>>
>>>> ¯\_(ツ)_/¯
>>>>
>>>>>> but it also[1] prints this for some of the bindgen runs:
>>>>>>
>>>>>> clang diag: /home/zozo/yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/
>>>>>> mesa/25.1.3/recipe-sysroot/usr/include/stdint.h:95:11: warning: '__INT64_C' macro
>>>>>> redefined [-Wmacro-redefined]
>>>>>> clang diag: /home/zozo/yocto-5.2/tmp-sicom/work/corei7-64-oe-linux/
>>>>>> mesa/25.1.3/recipe-sysroot/usr/include/stdint.h:96:11: warning: '__UINT64_C' macro
>>>>>> redefined [-Wmacro-redefined]
>>>>>>
>>>>>> [1] Using the previously posted patch also prints the same.
>>>>>>
>>>>>> It seems to be caused by a meson bug because it doesn't
>>>>>> collect the -isystem or --sysroot flags for rust/bindgen.
>>>>>> See the discussion at the MR link in the patch.
>>>>>>
>>>>>> CFLAGS and CXXFLAGS changes are both needed because
>>>>>> bindgen is run on both .h and .hpp files for rusticl.
>>>>>>
>>>>>>>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>>>>>>>> ---
>>>>>>>>    ...w-build-option-for-extra-bindgen-inc.patch | 57 +++++++++++ ++++++++
>>>>>>>>    meta/recipes-graphics/mesa/mesa.inc           | 3 +-
>>>>>>>>    2 files changed, 59 insertions(+), 1 deletion(-)
>>>>>>>>    create mode 100644 meta/recipes-graphics/mesa/files/0001-rusticl-
>>>>>>>> Add-a-new-build-option-for-extra-bindgen-inc.patch
>>>>>>>>
>>>>>>>
>>>>>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>>>>> Links: You receive all messages sent to this group.
>>>>>>> View/Reply Online (#218438): https://lists.openembedded.org/g/
>>>>>>> openembedded-core/message/218438
>>>>>>> Mute This Topic: https://lists.openembedded.org/mt/113570520/3617728
>>>>>>> Group Owner: openembedded-core+owner@lists.openembedded.org
>>>>>>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/ unsub 
>>>>>>> [zboszor@gmail.com]
>>>>>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>>>>>
>>>>>
>>>
>>
>
>
diff mbox series

Patch

diff --git a/meta/recipes-graphics/mesa/files/0001-rusticl-Add-a-new-build-option-for-extra-bindgen-inc.patch b/meta/recipes-graphics/mesa/files/0001-rusticl-Add-a-new-build-option-for-extra-bindgen-inc.patch
new file mode 100644
index 0000000000..913357c5dc
--- /dev/null
+++ b/meta/recipes-graphics/mesa/files/0001-rusticl-Add-a-new-build-option-for-extra-bindgen-inc.patch
@@ -0,0 +1,57 @@ 
+From 705309ce727575faac44f6399463616beeafbfa0 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
+ <zboszor@gmail.com>
+Date: Tue, 10 Jun 2025 15:50:08 +0200
+Subject: [PATCH] rusticl: Add a new build option for extra bindgen include
+ dirs
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Bindgen may need extra -I options when headers are not in
+the usual places, like when cross-compiling.
+
+Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
+Upstream-Status: Submitted [https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35435]
+---
+ meson.options                             | 7 +++++++
+ src/gallium/frontends/rusticl/meson.build | 5 +++++
+ 2 files changed, 12 insertions(+)
+
+diff --git a/meson.options b/meson.options
+index 40fe433435a..65d1c236261 100644
+--- a/meson.options
++++ b/meson.options
+@@ -787,6 +787,13 @@ option(
+   ],
+ )
+ 
++option(
++  'bindgen-includes',
++  type : 'array',
++  value : [],
++  description : 'Pass extra -I options to bindgen (if needed for cross builds).'
++)
++
+ option(
+   'mesa-clc',
+   type : 'combo',
+diff --git a/src/gallium/frontends/rusticl/meson.build b/src/gallium/frontends/rusticl/meson.build
+index 426b0a9b993..20e0d7682ea 100644
+--- a/src/gallium/frontends/rusticl/meson.build
++++ b/src/gallium/frontends/rusticl/meson.build
+@@ -106,6 +106,11 @@ rusticl_bindgen_c_args = [
+   '-fno-builtin-malloc',
+ ]
+ 
++_bindgen_includes = get_option('bindgen-includes')
++foreach _bindgen_include : _bindgen_includes
++  rusticl_bindgen_c_args += '-I' + _bindgen_include
++endforeach
++
+ cl_c_args = [
+   '-DCL_USE_DEPRECATED_OPENCL_1_0_APIS',
+   '-DCL_USE_DEPRECATED_OPENCL_1_1_APIS',
+-- 
+2.49.0
+
diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
index b222e72fdd..3179023efb 100644
--- a/meta/recipes-graphics/mesa/mesa.inc
+++ b/meta/recipes-graphics/mesa/mesa.inc
@@ -18,6 +18,7 @@  SRC_URI = "https://archive.mesa3d.org/mesa-${PV}.tar.xz \
            file://0001-meson-misdetects-64bit-atomics-on-mips-clang.patch \
            file://0001-freedreno-don-t-encode-build-path-into-binaries.patch \
            file://0001-dont-build-clover-frontend.patch \
+           file://0001-rusticl-Add-a-new-build-option-for-extra-bindgen-inc.patch \
 "
 
 SRC_URI[sha256sum] = "ffcb6cadb5fd356d56008e6308641dfe4b2929f30139f6585436ca6e3cddba7f"
@@ -151,7 +152,7 @@  PACKAGECONFIG[egl] = "-Degl=enabled, -Degl=disabled"
 
 # "opencl" also requires libclc and gallium-llvm to be present in PKGCONFIG!
 # Be sure to enable them both for the target and for the native build.
-PACKAGECONFIG[opencl] = "-Dgallium-rusticl=true, -Dgallium-rusticl=false, bindgen-cli-native"
+PACKAGECONFIG[opencl] = "-Dgallium-rusticl=true -Dbindgen-includes=${STAGING_INCDIR}, -Dgallium-rusticl=false, bindgen-cli-native"
 
 PACKAGECONFIG[broadcom] = ""
 PACKAGECONFIG[etnaviv] = ",,python3-pycparser-native"