diff mbox series

clang: Include the libclang python bindings in the build

Message ID 20250515130753.326236-1-luca.fancellu@arm.com
State Under Review
Headers show
Series clang: Include the libclang python bindings in the build | expand

Commit Message

Luca Fancellu May 15, 2025, 1:07 p.m. UTC
Modify the clang recipe to provide also the python module
'clang' when building libclang.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
---
 meta/recipes-devtools/clang/clang_git.bb | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Alexander Kanavin May 15, 2025, 1:10 p.m. UTC | #1
On Thu, 15 May 2025 at 15:08, luca fancellu via lists.openembedded.org
<luca.fancellu=arm.com@lists.openembedded.org> wrote:
> Modify the clang recipe to provide also the python module
> 'clang' when building libclang.

Why? Can that be a PACKAGECONFIG?

Alex
Luca Fancellu May 15, 2025, 1:35 p.m. UTC | #2
Hi Alex,

> On 15 May 2025, at 14:10, Alexander Kanavin <alex.kanavin@gmail.com> wrote:
> 
> On Thu, 15 May 2025 at 15:08, luca fancellu via lists.openembedded.org
> <luca.fancellu=arm.com@lists.openembedded.org> wrote:
>> Modify the clang recipe to provide also the python module
>> 'clang' when building libclang.
> 
> Why? Can that be a PACKAGECONFIG?

I used the same approach as lldb, why do you think we should use a different approach?

Cheers,
Luca
Alexander Kanavin May 15, 2025, 1:38 p.m. UTC | #3
On Thu, 15 May 2025 at 15:36, Luca Fancellu <Luca.Fancellu@arm.com> wrote:
> > Why? Can that be a PACKAGECONFIG?
>
> I used the same approach as lldb, why do you think we should use a different approach?

The request was to explain why this is beneficial, and should be
always enabled. What is the use case specifically in clang?

Alex
Luca Fancellu May 15, 2025, 1:51 p.m. UTC | #4
Hi Alex

> On 15 May 2025, at 14:38, Alexander Kanavin <alex.kanavin@gmail.com> wrote:
> 
> On Thu, 15 May 2025 at 15:36, Luca Fancellu <Luca.Fancellu@arm.com> wrote:
>>> Why? Can that be a PACKAGECONFIG?
>> 
>> I used the same approach as lldb, why do you think we should use a different approach?
> 
> The request was to explain why this is beneficial, and should be
> always enabled. What is the use case specifically in clang?

ok I see what you mean, the module will use some python bindings for libclang, so I guess
some recipe could switch the feature on if using the module, otherwise it should stay off
by default.

Make sense, I’ll try to implement in that way

Cheers,
Luca
Khem Raj May 15, 2025, 3:47 p.m. UTC | #5
On Thu, May 15, 2025 at 6:52 AM luca fancellu via
lists.openembedded.org <luca.fancellu=arm.com@lists.openembedded.org>
wrote:
>
> Hi Alex
>
> > On 15 May 2025, at 14:38, Alexander Kanavin <alex.kanavin@gmail.com> wrote:
> >
> > On Thu, 15 May 2025 at 15:36, Luca Fancellu <Luca.Fancellu@arm.com> wrote:
> >>> Why? Can that be a PACKAGECONFIG?
> >>
> >> I used the same approach as lldb, why do you think we should use a different approach?
> >
> > The request was to explain why this is beneficial, and should be
> > always enabled. What is the use case specifically in clang?
>
> ok I see what you mean, the module will use some python bindings for libclang, so I guess
> some recipe could switch the feature on if using the module, otherwise it should stay off
> by default.
>
> Make sense, I’ll try to implement in that way

Just measure build times before and after this change, my guess is it
is not adding a significant amount, but do measure it.

>
> Cheers,
> Luca
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#216680): https://lists.openembedded.org/g/openembedded-core/message/216680
> Mute This Topic: https://lists.openembedded.org/mt/113126509/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Luca Fancellu May 15, 2025, 6:47 p.m. UTC | #6
Hi Khem,

> On 15 May 2025, at 16:47, Khem Raj via lists.openembedded.org <raj.khem=gmail.com@lists.openembedded.org> wrote:
> 
> On Thu, May 15, 2025 at 6:52 AM luca fancellu via
> lists.openembedded.org <luca.fancellu=arm.com@lists.openembedded.org>
> wrote:
>> 
>> Hi Alex
>> 
>>> On 15 May 2025, at 14:38, Alexander Kanavin <alex.kanavin@gmail.com> wrote:
>>> 
>>> On Thu, 15 May 2025 at 15:36, Luca Fancellu <Luca.Fancellu@arm.com> wrote:
>>>>> Why? Can that be a PACKAGECONFIG?
>>>> 
>>>> I used the same approach as lldb, why do you think we should use a different approach?
>>> 
>>> The request was to explain why this is beneficial, and should be
>>> always enabled. What is the use case specifically in clang?
>> 
>> ok I see what you mean, the module will use some python bindings for libclang, so I guess
>> some recipe could switch the feature on if using the module, otherwise it should stay off
>> by default.
>> 
>> Make sense, I’ll try to implement in that way
> 
> Just measure build times before and after this change, my guess is it
> is not adding a significant amount, but do measure it.

Is there a standard way to do that?

Otherwise I’ll do just: time bitbake -c build <recipe>

Let me know.

Cheers,
Luca
Khem Raj May 15, 2025, 7:38 p.m. UTC | #7
On Thu, May 15, 2025 at 11:48 AM Luca Fancellu <Luca.Fancellu@arm.com> wrote:
>
> Hi Khem,
>
> > On 15 May 2025, at 16:47, Khem Raj via lists.openembedded.org <raj.khem=gmail.com@lists.openembedded.org> wrote:
> >
> > On Thu, May 15, 2025 at 6:52 AM luca fancellu via
> > lists.openembedded.org <luca.fancellu=arm.com@lists.openembedded.org>
> > wrote:
> >>
> >> Hi Alex
> >>
> >>> On 15 May 2025, at 14:38, Alexander Kanavin <alex.kanavin@gmail.com> wrote:
> >>>
> >>> On Thu, 15 May 2025 at 15:36, Luca Fancellu <Luca.Fancellu@arm.com> wrote:
> >>>>> Why? Can that be a PACKAGECONFIG?
> >>>>
> >>>> I used the same approach as lldb, why do you think we should use a different approach?
> >>>
> >>> The request was to explain why this is beneficial, and should be
> >>> always enabled. What is the use case specifically in clang?
> >>
> >> ok I see what you mean, the module will use some python bindings for libclang, so I guess
> >> some recipe could switch the feature on if using the module, otherwise it should stay off
> >> by default.
> >>
> >> Make sense, I’ll try to implement in that way
> >
> > Just measure build times before and after this change, my guess is it
> > is not adding a significant amount, but do measure it.
>
> Is there a standard way to do that?

enable buildstats and do a build before and after
it should capture task times

>
> Otherwise I’ll do just: time bitbake -c build <recipe>
>
> Let me know.
>
> Cheers,
> Luca
>
Luca Fancellu May 15, 2025, 8:56 p.m. UTC | #8
Hi Khem,

> On 15 May 2025, at 20:38, Khem Raj <raj.khem@gmail.com> wrote:
> 
> On Thu, May 15, 2025 at 11:48 AM Luca Fancellu <Luca.Fancellu@arm.com> wrote:
>> 
>> Hi Khem,
>> 
>>> On 15 May 2025, at 16:47, Khem Raj via lists.openembedded.org <raj.khem=gmail.com@lists.openembedded.org> wrote:
>>> 
>>> On Thu, May 15, 2025 at 6:52 AM luca fancellu via
>>> lists.openembedded.org <luca.fancellu=arm.com@lists.openembedded.org>
>>> wrote:
>>>> 
>>>> Hi Alex
>>>> 
>>>>> On 15 May 2025, at 14:38, Alexander Kanavin <alex.kanavin@gmail.com> wrote:
>>>>> 
>>>>> On Thu, 15 May 2025 at 15:36, Luca Fancellu <Luca.Fancellu@arm.com> wrote:
>>>>>>> Why? Can that be a PACKAGECONFIG?
>>>>>> 
>>>>>> I used the same approach as lldb, why do you think we should use a different approach?
>>>>> 
>>>>> The request was to explain why this is beneficial, and should be
>>>>> always enabled. What is the use case specifically in clang?
>>>> 
>>>> ok I see what you mean, the module will use some python bindings for libclang, so I guess
>>>> some recipe could switch the feature on if using the module, otherwise it should stay off
>>>> by default.
>>>> 
>>>> Make sense, I’ll try to implement in that way
>>> 
>>> Just measure build times before and after this change, my guess is it
>>> is not adding a significant amount, but do measure it.
>> 
>> Is there a standard way to do that?
> 
> enable buildstats and do a build before and after
> it should capture task times

Here a summary, let me know if I should paste a particular task/tasks:

with:

NOTE: Build completion summary:
NOTE:   do_populate_sysroot: 0.0% sstate reuse(0 setscene, 1 scratch)
NOTE:   do_deploy_source_date_epoch: 0.0% sstate reuse(0 setscene, 1 scratch)
NOTE:   do_create_spdx: 0.0% sstate reuse(0 setscene, 1 scratch)
NOTE:   do_create_package_spdx: 0.0% sstate reuse(0 setscene, 1 scratch)
NOTE:   do_recipe_qa: 0.0% sstate reuse(0 setscene, 1 scratch)
NOTE:   do_populate_lic: 0.0% sstate reuse(0 setscene, 1 scratch)

Host Info: Linux <hostname> 6.5.0-25-generic #25~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Feb 20 16:09:15 UTC 2 x86_64 x86_64 
Build Started: 1747340234.36 
Elapsed time: 1484.02 seconds 
CPU usage: 71.1% 


without:

NOTE: Build completion summary:
NOTE:   do_populate_sysroot: 0.0% sstate reuse(0 setscene, 1 scratch)
NOTE:   do_deploy_source_date_epoch: 0.0% sstate reuse(0 setscene, 1 scratch)
NOTE:   do_create_spdx: 0.0% sstate reuse(0 setscene, 1 scratch)
NOTE:   do_create_package_spdx: 0.0% sstate reuse(0 setscene, 1 scratch)
NOTE:   do_recipe_qa: 0.0% sstate reuse(0 setscene, 1 scratch)
NOTE:   do_populate_lic: 0.0% sstate reuse(0 setscene, 1 scratch)

Host Info: Linux <hostname> 6.5.0-25-generic #25~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Feb 20 16:09:15 UTC 2 x86_64 x86_64 
Build Started: 1747338659.83 
Elapsed time: 1294.93 seconds 
CPU usage: 81.6% 

Cheers,
Luca
Khem Raj May 15, 2025, 9:13 p.m. UTC | #9
On Thu, May 15, 2025 at 1:57 PM Luca Fancellu <Luca.Fancellu@arm.com> wrote:

> Hi Khem,
>
> > On 15 May 2025, at 20:38, Khem Raj <raj.khem@gmail.com> wrote:
> >
> > On Thu, May 15, 2025 at 11:48 AM Luca Fancellu <Luca.Fancellu@arm.com>
> wrote:
> >>
> >> Hi Khem,
> >>
> >>> On 15 May 2025, at 16:47, Khem Raj via lists.openembedded.org
> <raj.khem=gmail.com@lists.openembedded.org> wrote:
> >>>
> >>> On Thu, May 15, 2025 at 6:52 AM luca fancellu via
> >>> lists.openembedded.org <luca.fancellu=arm.com@lists.openembedded.org>
> >>> wrote:
> >>>>
> >>>> Hi Alex
> >>>>
> >>>>> On 15 May 2025, at 14:38, Alexander Kanavin <alex.kanavin@gmail.com>
> wrote:
> >>>>>
> >>>>> On Thu, 15 May 2025 at 15:36, Luca Fancellu <Luca.Fancellu@arm.com>
> wrote:
> >>>>>>> Why? Can that be a PACKAGECONFIG?
> >>>>>>
> >>>>>> I used the same approach as lldb, why do you think we should use a
> different approach?
> >>>>>
> >>>>> The request was to explain why this is beneficial, and should be
> >>>>> always enabled. What is the use case specifically in clang?
> >>>>
> >>>> ok I see what you mean, the module will use some python bindings for
> libclang, so I guess
> >>>> some recipe could switch the feature on if using the module,
> otherwise it should stay off
> >>>> by default.
> >>>>
> >>>> Make sense, I’ll try to implement in that way
> >>>
> >>> Just measure build times before and after this change, my guess is it
> >>> is not adding a significant amount, but do measure it.
> >>
> >> Is there a standard way to do that?
> >
> > enable buildstats and do a build before and after
> > it should capture task times
>
> Here a summary, let me know if I should paste a particular task/tasks:
>
> with:
>
> NOTE: Build completion summary:
> NOTE:   do_populate_sysroot: 0.0% sstate reuse(0 setscene, 1 scratch)
> NOTE:   do_deploy_source_date_epoch: 0.0% sstate reuse(0 setscene, 1
> scratch)
> NOTE:   do_create_spdx: 0.0% sstate reuse(0 setscene, 1 scratch)
> NOTE:   do_create_package_spdx: 0.0% sstate reuse(0 setscene, 1 scratch)
> NOTE:   do_recipe_qa: 0.0% sstate reuse(0 setscene, 1 scratch)
> NOTE:   do_populate_lic: 0.0% sstate reuse(0 setscene, 1 scratch)
>
> Host Info: Linux <hostname> 6.5.0-25-generic #25~22.04.1-Ubuntu SMP
> PREEMPT_DYNAMIC Tue Feb 20 16:09:15 UTC 2 x86_64 x86_64
> Build Started: 1747340234.36
> Elapsed time: 1484.02 seconds
> CPU usage: 71.1%
>
>
> without:
>
> NOTE: Build completion summary:
> NOTE:   do_populate_sysroot: 0.0% sstate reuse(0 setscene, 1 scratch)
> NOTE:   do_deploy_source_date_epoch: 0.0% sstate reuse(0 setscene, 1
> scratch)
> NOTE:   do_create_spdx: 0.0% sstate reuse(0 setscene, 1 scratch)
> NOTE:   do_create_package_spdx: 0.0% sstate reuse(0 setscene, 1 scratch)
> NOTE:   do_recipe_qa: 0.0% sstate reuse(0 setscene, 1 scratch)
> NOTE:   do_populate_lic: 0.0% sstate reuse(0 setscene, 1 scratch)
>
> Host Info: Linux <hostname> 6.5.0-25-generic #25~22.04.1-Ubuntu SMP
> PREEMPT_DYNAMIC Tue Feb 20 16:09:15 UTC 2 x86_64 x86_64
> Build Started: 1747338659.83
> Elapsed time: 1294.93 seconds
> CPU usage: 81.6%


So it does seem to add 200s to build time perhaps make it a packageconfig

>
>
> Cheers,
> Luca
>
>
Ross Burton May 16, 2025, 9:56 a.m. UTC | #10
On 15 May 2025, at 22:13, Khem Raj via lists.openembedded.org <raj.khem=gmail.com@lists.openembedded.org> wrote:
> So it does seem to add 200s to build time perhaps make it a packageconfig 

Doing buildstats comparisons is less than trivial. I just replicated the test, ensuring that there’s no noise caused by other recipes being built:

  clang-native                  do_compile       9.3s    +1.2%     806.2s -> 815.5s

I’m fine with adding a PACKAGECONFIG but I think it should be on by default.  I know we’re trying to reduce the clang build time but 9s is basically noise in this context.

Ross
Luca Fancellu May 16, 2025, 12:45 p.m. UTC | #11
Hi Khem and Alex

> On 16 May 2025, at 10:56, Ross Burton <Ross.Burton@arm.com> wrote:
> 
> On 15 May 2025, at 22:13, Khem Raj via lists.openembedded.org <raj.khem=gmail.com@lists.openembedded.org> wrote:
>> So it does seem to add 200s to build time perhaps make it a packageconfig
> 
> Doing buildstats comparisons is less than trivial. I just replicated the test, ensuring that there’s no noise caused by other recipes being built:
> 
>  clang-native                  do_compile       9.3s    +1.2%     806.2s -> 815.5s
> 
> I’m fine with adding a PACKAGECONFIG but I think it should be on by default.  I know we’re trying to reduce the clang build time but 9s is basically noise in this context.
> 

please let me know how to proceed, PACKAGECONFIG and config enabled by default or disabled, I’ll send the v2 shortly.

Cheers,
Luca
Khem Raj May 16, 2025, 1:49 p.m. UTC | #12
On Fri, May 16, 2025 at 5:46 AM Luca Fancellu <Luca.Fancellu@arm.com> wrote:

> Hi Khem and Alex
>
> > On 16 May 2025, at 10:56, Ross Burton <Ross.Burton@arm.com> wrote:
> >
> > On 15 May 2025, at 22:13, Khem Raj via lists.openembedded.org <raj.khem=
> gmail.com@lists.openembedded.org> wrote:
> >> So it does seem to add 200s to build time perhaps make it a
> packageconfig
> >
> > Doing buildstats comparisons is less than trivial. I just replicated the
> test, ensuring that there’s no noise caused by other recipes being built:
> >
> >  clang-native                  do_compile       9.3s    +1.2%     806.2s
> -> 815.5s
> >
> > I’m fine with adding a PACKAGECONFIG but I think it should be on by
> default.  I know we’re trying to reduce the clang build time but 9s is
> basically noise in this context.
> >
>

I agree if this is the new number let’s apply it as is

>
> please let me know how to proceed, PACKAGECONFIG and config enabled by
> default or disabled, I’ll send the v2 shortly.
>
> Cheers,
> Luca
>
>
diff mbox series

Patch

diff --git a/meta/recipes-devtools/clang/clang_git.bb b/meta/recipes-devtools/clang/clang_git.bb
index b41b700292c7..6634eb5416b6 100644
--- a/meta/recipes-devtools/clang/clang_git.bb
+++ b/meta/recipes-devtools/clang/clang_git.bb
@@ -163,6 +163,7 @@  EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
                   -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \
                   -DLLVM_TARGETS_TO_BUILD='${LLVM_TARGETS_TO_BUILD}' \
                   -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD='${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}' \
+                  -DCLANG_PYTHON_BINDINGS_VERSIONS='${PYTHON_BASEVERSION}' \
 "
 
 EXTRA_OECMAKE:append:class-native = "\
@@ -312,7 +313,7 @@  PROVIDES:append:class-native = " llvm-native libclc-native"
 PROVIDES:append:class-target = " llvm libclc"
 PROVIDES:append:class-nativesdk = " nativesdk-llvm nativesdk-libclc"
 
-PACKAGES =+ "${PN}-libllvm ${PN}-lldb-python ${PN}-libclang-cpp ${PN}-tidy ${PN}-format ${PN}-tools ${PN}-clc \
+PACKAGES =+ "${PN}-libllvm ${PN}-lldb-python ${PN}-libclang-python ${PN}-libclang-cpp ${PN}-tidy ${PN}-format ${PN}-tools ${PN}-clc \
              libclang lldb lldb-server liblldb llvm-linker-tools"
 
 
@@ -342,6 +343,8 @@  FILES:${PN}-libclang-cpp = "${libdir}/libclang-cpp.so.*"
 
 FILES:${PN}-lldb-python = "${libdir}/python*/site-packages/lldb/*"
 
+FILES:${PN}-libclang-python = "${libdir}/python*/site-packages/clang/*"
+
 FILES:${PN}-tidy = "${bindir}/*clang-tidy*"
 FILES:${PN}-format = "${bindir}/*clang-format*"