Skip to contentSkip to conversation

clang: Include the libclang python bindings in the build

PATCH Superseded Luca Fancellu 4 participants 13 messages May 15, 2025 – May 16, 2025

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clang: Include the libclang python bindings in the build

Modify the clang recipe to provide also the python module 'clang' when building libclang.

---
 meta/recipes-devtools/clang/clang_git.bb | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
meta/recipes-devtools/clang/clang_git.bb +4 -1
index b41b700292c7..6634eb5416b6 100644
@@ -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*"
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 2 lines · luca fancellu via lists.openembedded.org

Modify the clang recipe to provide also the python module 'clang' when building libclang.

Why? Can that be a PACKAGECONFIG?

Alex

#2 lore raw

Hi Alex,

Quoted 8 lines · Alexander Kanavin
Quoted 2 lines · luca fancellu via lists.openembedded.org

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

#3 lore raw
Quoted 3 lines · Luca Fancellu
Quoted 1 line

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

#4 lore raw

Hi Alex

Quoted 9 lines · Alexander Kanavin
Quoted 3 lines · Luca Fancellu
Quoted 1 line

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

#5 lore raw
Quoted 10 lines · luca fancellu via lists.openembedded.org

Hi Alex

Quoted 7 lines · Alexander Kanavin
Quoted 3 lines · Luca Fancellu
Quoted 1 line

Why? Can that be a PACKAGECONFIG?

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

Quoted 8 lines
Quoted 2 lines

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.

Quoted 11 lines

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: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#6 lore raw

Hi Khem,

Quoted 18 lines · Khem Raj via lists.openembedded.org
Quoted 13 lines · luca fancellu via lists.openembedded.org

Hi Alex

Quoted 9 lines · Alexander Kanavin
Quoted 3 lines · Luca Fancellu
Quoted 1 line

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?

Quoted 8 lines
Quoted 5 lines

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

#7 lore raw
Quoted 25 lines · Luca Fancellu

Hi Khem,

Quoted 22 lines · Khem Raj via lists.openembedded.org
Quoted 17 lines · luca fancellu via lists.openembedded.org

Hi Alex

Quoted 9 lines · Alexander Kanavin
Quoted 3 lines · Luca Fancellu
Quoted 1 line

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.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

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

Quoted 8 lines

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

Let me know.

Cheers,
Luca

#8 lore raw

Hi Khem,

Quoted 30 lines · Khem Raj
Quoted 27 lines · Luca Fancellu

Hi Khem,

Quoted 24 lines · Khem Raj via lists.openembedded.org
Quoted 18 lines · luca fancellu via lists.openembedded.org

Hi Alex

Quoted 9 lines · Alexander Kanavin
Quoted 3 lines · Luca Fancellu
Quoted 1 line

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

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

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

#9 lore raw
Quoted 78 lines · Luca Fancellu

Hi Khem,

Quoted 3 lines · Khem Raj

On Thu, May 15, 2025 at 11:48 AM Luca Fancellu <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines

Hi Khem,

Quoted 1 line

On 15 May 2025, at 16:47, Khem Raj via lists.openembedded.org

Quoted 8 lines · <[email protected]> wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines · luca fancellu via lists.openembedded.org

Hi Alex

Quoted 1 line

On 15 May 2025, at 14:38, Alexander Kanavin <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Thu, 15 May 2025 at 15:36, Luca Fancellu <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Why? Can that be a PACKAGECONFIG?

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

different approach?

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

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

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

some recipe could switch the feature on if using the module,

otherwise it should stay off

Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

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)
Quoted 5 lines

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

Quoted 6 lines

Cheers,
Luca

#10 lore raw
Quoted 1 line · Khem Raj via lists.openembedded.org

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

#11 lore raw

Hi Khem and Alex

Quoted 11 lines · Ross Burton
Quoted 1 line · Khem Raj via lists.openembedded.org

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

#12 lore raw
Quoted 10 lines · Luca Fancellu

Hi Khem and Alex

Quoted 3 lines · Ross Burton

On 15 May 2025, at 22:13, Khem Raj via lists.openembedded.org <raj.khem=

Quoted 1 line · [email protected]> wrote:
Quoted 1 line

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

packageconfig

Quoted 2 lines

Doing buildstats comparisons is less than trivial. I just replicated the

Quoted 10 lines

test, ensuring that there’s no noise caused by other recipes being built:

Quoted 2 lines

clang-native do_compile 9.3s +1.2% 806.2s

-> 815.5s

Quoted 2 lines

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.

Quoted 1 line

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

Quoted 8 lines

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

Cheers,
Luca