diff mbox series

clang: multilib-header fix for llvm/Config/llvm-config.h and clang/Config/config.h

Message ID 20250521031413.1566-1-liuyd.fnst@fujitsu.com
State New
Headers show
Series clang: multilib-header fix for llvm/Config/llvm-config.h and clang/Config/config.h | expand

Commit Message

Yiding Liu (Fujitsu) May 21, 2025, 3:14 a.m. UTC
Error: Transaction test error:
  file /usr/include/clang/Config/config.h conflicts between attempted installs of
lib32-clang-dev-20.1.4-r0.core2_32 and clang-dev-20.1.4-r0.core2_64
  file /usr/include/llvm/Config/llvm-config.h conflicts between attempted
installs of lib32-clang-dev-20.1.4-r0.core2_32 and clang-dev-20.1.4-r0.core2_64

reproduce steps:
1. Add in local.conf the following lines:

  MACHINE ?= "qemux86-64"

  require conf/multilib.conf

  MULTILIBS ?= "multilib:lib32"

  DEFAULTTUNE:virtclass-multilib-lib32 ?= "core2-32"

2. add lib32-llvm-dev llvm-dev to core-image-minimal.bb

  IMAGE_INSTALL = "packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL} lib32-clang-dev clang-dev"

3. $ bitbake core-image-minimal

Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com>
---
 meta/recipes-devtools/clang/clang_git.bb | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Alexander Kanavin May 22, 2025, 10:21 a.m. UTC | #1
On Wed, 21 May 2025 at 05:14, Yiding Liu (Fujitsu) via
lists.openembedded.org <liuyd.fnst=fujitsu.com@lists.openembedded.org>
wrote:
>
> Error: Transaction test error:
>   file /usr/include/clang/Config/config.h conflicts between attempted installs of
> lib32-clang-dev-20.1.4-r0.core2_32 and clang-dev-20.1.4-r0.core2_64
>   file /usr/include/llvm/Config/llvm-config.h conflicts between attempted
> installs of lib32-clang-dev-20.1.4-r0.core2_32 and clang-dev-20.1.4-r0.core2_64

What is the actual difference between the headers and where does it
originate? Before any multilib fixes are applied, this does need to be
investigated. This is repeatedly being asked in response to similar
patches, and it would be good if such investigations happen up front.

Alex
Yiding Liu (Fujitsu) May 23, 2025, 1:22 a.m. UTC | #2
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org
> <openembedded-core@lists.openembedded.org> On Behalf Of Alexander
> Kanavin via lists.openembedded.org
> Sent: 2025年5月22日 18:22
> To: Liu, Yiding/刘 乙丁 <liuyd.fnst@fujitsu.com>
> Cc: Khem Raj <raj.khem@gmail.com>;
> openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCH] clang: multilib-header fix for
> llvm/Config/llvm-config.h and clang/Config/config.h
> 
> On Wed, 21 May 2025 at 05:14, Yiding Liu (Fujitsu) via lists.openembedded.org
> <liuyd.fnst=fujitsu.com@lists.openembedded.org>
> wrote:
> >
> > Error: Transaction test error:
> >   file /usr/include/clang/Config/config.h conflicts between attempted
> > installs of
> > lib32-clang-dev-20.1.4-r0.core2_32 and clang-dev-20.1.4-r0.core2_64
> >   file /usr/include/llvm/Config/llvm-config.h conflicts between
> > attempted installs of lib32-clang-dev-20.1.4-r0.core2_32 and
> > clang-dev-20.1.4-r0.core2_64
> 
> What is the actual difference between the headers and where does it originate?
> Before any multilib fixes are applied, this does need to be investigated. This is
> repeatedly being asked in response to similar patches, and it would be good if
> such investigations happen up front.

Let me explain it more clearly 
1. This fix started from my original patch in April
https://lists.openembedded.org/g/openembedded-core/message/215193

2. Then Khem Raj raj.khem@gmail.com merged a patch set, claiming it would resolve the conflict issues. But in reality, it didn’t.

For the difference, I have pasted it here:
https://lists.openembedded.org/g/openembedded-core/message/216811?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Cllvm-config.h%2C20%2C2%2C0%2C112624219 


I know multi-script or multi-header is the last step we should consider.
But regarding this issue, if you or Khem Raj have any good suggestions, please let me know.


Liu Yiding
> 
> Alex
Khem Raj May 23, 2025, 1:45 a.m. UTC | #3
On 5/22/25 6:22 PM, Yiding Liu (Fujitsu) wrote:
> 
> 
>> -----Original Message-----
>> From: openembedded-core@lists.openembedded.org
>> <openembedded-core@lists.openembedded.org> On Behalf Of Alexander
>> Kanavin via lists.openembedded.org
>> Sent: 2025年5月22日 18:22
>> To: Liu, Yiding/刘 乙丁 <liuyd.fnst@fujitsu.com>
>> Cc: Khem Raj <raj.khem@gmail.com>;
>> openembedded-core@lists.openembedded.org
>> Subject: Re: [OE-core] [PATCH] clang: multilib-header fix for
>> llvm/Config/llvm-config.h and clang/Config/config.h
>>
>> On Wed, 21 May 2025 at 05:14, Yiding Liu (Fujitsu) via lists.openembedded.org
>> <liuyd.fnst=fujitsu.com@lists.openembedded.org>
>> wrote:
>>>
>>> Error: Transaction test error:
>>>    file /usr/include/clang/Config/config.h conflicts between attempted
>>> installs of
>>> lib32-clang-dev-20.1.4-r0.core2_32 and clang-dev-20.1.4-r0.core2_64
>>>    file /usr/include/llvm/Config/llvm-config.h conflicts between
>>> attempted installs of lib32-clang-dev-20.1.4-r0.core2_32 and
>>> clang-dev-20.1.4-r0.core2_64
>>
>> What is the actual difference between the headers and where does it originate?
>> Before any multilib fixes are applied, this does need to be investigated. This is
>> repeatedly being asked in response to similar patches, and it would be good if
>> such investigations happen up front.
> 
> Let me explain it more clearly
> 1. This fix started from my original patch in April
> https://lists.openembedded.org/g/openembedded-core/message/215193
> 
> 2. Then Khem Raj raj.khem@gmail.com merged a patch set, claiming it would resolve the conflict issues. But in reality, it didn’t.
> 
> For the difference, I have pasted it here:
> https://lists.openembedded.org/g/openembedded-core/message/216811?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Cllvm-config.h%2C20%2C2%2C0%2C112624219
> 
> 
> I know multi-script or multi-header is the last step we should consider.
> But regarding this issue, if you or Khem Raj have any good suggestions, please let me know.

These are configuration headers and will depend upon how clang/llvm is 
built, I hoped that we maybe able to generate identical file by enabling 
all backends but it has more entries that vary according to multilibs. 
At this point this is best we can do, install multilibbed versions of 
these headers. This patch is fine to go in.

> 
> 
> Liu Yiding
>>
>> Alex
Yiding Liu (Fujitsu) May 30, 2025, 2:58 a.m. UTC | #4
> -----Original Message-----
> From: Khem Raj <raj.khem@gmail.com>
> Sent: 2025年5月23日 9:45
> To: Liu, Yiding/刘 乙丁 <liuyd.fnst@fujitsu.com>; alex.kanavin@gmail.com
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCH] clang: multilib-header fix for
> llvm/Config/llvm-config.h and clang/Config/config.h
> 
> 
> 
> On 5/22/25 6:22 PM, Yiding Liu (Fujitsu) wrote:
> >
> >
> >> -----Original Message-----
> >> From: openembedded-core@lists.openembedded.org
> >> <openembedded-core@lists.openembedded.org> On Behalf Of Alexander
> >> Kanavin via lists.openembedded.org
> >> Sent: 2025年5月22日 18:22
> >> To: Liu, Yiding/刘 乙丁 <liuyd.fnst@fujitsu.com>
> >> Cc: Khem Raj <raj.khem@gmail.com>;
> >> openembedded-core@lists.openembedded.org
> >> Subject: Re: [OE-core] [PATCH] clang: multilib-header fix for
> >> llvm/Config/llvm-config.h and clang/Config/config.h
> >>
> >> On Wed, 21 May 2025 at 05:14, Yiding Liu (Fujitsu) via
> >> lists.openembedded.org
> >> <liuyd.fnst=fujitsu.com@lists.openembedded.org>
> >> wrote:
> >>>
> >>> Error: Transaction test error:
> >>>    file /usr/include/clang/Config/config.h conflicts between
> >>> attempted installs of
> >>> lib32-clang-dev-20.1.4-r0.core2_32 and clang-dev-20.1.4-r0.core2_64
> >>>    file /usr/include/llvm/Config/llvm-config.h conflicts between
> >>> attempted installs of lib32-clang-dev-20.1.4-r0.core2_32 and
> >>> clang-dev-20.1.4-r0.core2_64
> >>
> >> What is the actual difference between the headers and where does it
> originate?
> >> Before any multilib fixes are applied, this does need to be
> >> investigated. This is repeatedly being asked in response to similar
> >> patches, and it would be good if such investigations happen up front.
> >
> > Let me explain it more clearly
> > 1. This fix started from my original patch in April
> > https://lists.openembedded.org/g/openembedded-core/message/215193
> >
> > 2. Then Khem Raj raj.khem@gmail.com merged a patch set, claiming it would
> resolve the conflict issues. But in reality, it didn’t.
> >
> > For the difference, I have pasted it here:
> >
> https://lists.openembedded.org/g/openembedded-core/message/216811?p=%2
> >
> C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Cllvm-co
> nfig.h%
> > 2C20%2C2%2C0%2C112624219
> >
> >
> > I know multi-script or multi-header is the last step we should consider.
> > But regarding this issue, if you or Khem Raj have any good suggestions, please
> let me know.
> 
> These are configuration headers and will depend upon how clang/llvm is built, I
> hoped that we maybe able to generate identical file by enabling all backends but
> it has more entries that vary according to multilibs.
> At this point this is best we can do, install multilibbed versions of these headers.
> This patch is fine to go in.


Hi Raj

I noticed this patch still hasn't been tested by the master-next branch. Should we consider testing it now?
Or is there anything else I can do?


Yiding



> 
> >
> >
> > Liu Yiding
> >>
> >> Alex
Khem Raj May 30, 2025, 3:15 a.m. UTC | #5
Yes please ping Richard or Mathieu to stage it

On Thu, May 29, 2025 at 7:58 PM Yiding Liu (Fujitsu) <liuyd.fnst@fujitsu.com>
wrote:

>
>
> > -----Original Message-----
> > From: Khem Raj <raj.khem@gmail.com>
> > Sent: 2025年5月23日 9:45
> > To: Liu, Yiding/刘 乙丁 <liuyd.fnst@fujitsu.com>; alex.kanavin@gmail.com
> > Cc: openembedded-core@lists.openembedded.org
> > Subject: Re: [OE-core] [PATCH] clang: multilib-header fix for
> > llvm/Config/llvm-config.h and clang/Config/config.h
> >
> >
> >
> > On 5/22/25 6:22 PM, Yiding Liu (Fujitsu) wrote:
> > >
> > >
> > >> -----Original Message-----
> > >> From: openembedded-core@lists.openembedded.org
> > >> <openembedded-core@lists.openembedded.org> On Behalf Of Alexander
> > >> Kanavin via lists.openembedded.org
> > >> Sent: 2025年5月22日 18:22
> > >> To: Liu, Yiding/刘 乙丁 <liuyd.fnst@fujitsu.com>
> > >> Cc: Khem Raj <raj.khem@gmail.com>;
> > >> openembedded-core@lists.openembedded.org
> > >> Subject: Re: [OE-core] [PATCH] clang: multilib-header fix for
> > >> llvm/Config/llvm-config.h and clang/Config/config.h
> > >>
> > >> On Wed, 21 May 2025 at 05:14, Yiding Liu (Fujitsu) via
> > >> lists.openembedded.org
> > >> <liuyd.fnst=fujitsu.com@lists.openembedded.org>
> > >> wrote:
> > >>>
> > >>> Error: Transaction test error:
> > >>>    file /usr/include/clang/Config/config.h conflicts between
> > >>> attempted installs of
> > >>> lib32-clang-dev-20.1.4-r0.core2_32 and clang-dev-20.1.4-r0.core2_64
> > >>>    file /usr/include/llvm/Config/llvm-config.h conflicts between
> > >>> attempted installs of lib32-clang-dev-20.1.4-r0.core2_32 and
> > >>> clang-dev-20.1.4-r0.core2_64
> > >>
> > >> What is the actual difference between the headers and where does it
> > originate?
> > >> Before any multilib fixes are applied, this does need to be
> > >> investigated. This is repeatedly being asked in response to similar
> > >> patches, and it would be good if such investigations happen up front.
> > >
> > > Let me explain it more clearly
> > > 1. This fix started from my original patch in April
> > > https://lists.openembedded.org/g/openembedded-core/message/215193
> > >
> > > 2. Then Khem Raj raj.khem@gmail.com merged a patch set, claiming it
> would
> > resolve the conflict issues. But in reality, it didn’t.
> > >
> > > For the difference, I have pasted it here:
> > >
> > https://lists.openembedded.org/g/openembedded-core/message/216811?p=%2
> > >
> > C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Cllvm-co
> > nfig.h%
> > > 2C20%2C2%2C0%2C112624219
> > >
> > >
> > > I know multi-script or multi-header is the last step we should
> consider.
> > > But regarding this issue, if you or Khem Raj have any good
> suggestions, please
> > let me know.
> >
> > These are configuration headers and will depend upon how clang/llvm is
> built, I
> > hoped that we maybe able to generate identical file by enabling all
> backends but
> > it has more entries that vary according to multilibs.
> > At this point this is best we can do, install multilibbed versions of
> these headers.
> > This patch is fine to go in.
>
>
> Hi Raj
>
> I noticed this patch still hasn't been tested by the master-next branch.
> Should we consider testing it now?
> Or is there anything else I can do?
>
>
> Yiding
>
>
>
> >
> > >
> > >
> > > Liu Yiding
> > >>
> > >> Alex
>
>
Mathieu Dubois-Briand May 30, 2025, 7:33 a.m. UTC | #6
On Fri May 30, 2025 at 4:58 AM CEST, Yiding Liu (Fujitsu) via lists.openembedded.org wrote:
>
> Hi Raj
>
> I noticed this patch still hasn't been tested by the master-next branch. Should we consider testing it now?
> Or is there anything else I can do?
>
>
> Yiding
>

Sorry, I ignored it at first as Alexander had some questions, and then
missed the end of the discussion.

I'm adding it to the queue.
Randy MacLeod June 22, 2025, 9:22 p.m. UTC | #7
On 2025-05-20 11:14 p.m., Yiding Liu (Fujitsu) via 
lists.openembedded.org wrote:
> Error: Transaction test error:
>    file /usr/include/clang/Config/config.h conflicts between attempted installs of
> lib32-clang-dev-20.1.4-r0.core2_32 and clang-dev-20.1.4-r0.core2_64
>    file /usr/include/llvm/Config/llvm-config.h conflicts between attempted
> installs of lib32-clang-dev-20.1.4-r0.core2_32 and clang-dev-20.1.4-r0.core2_64
>
> reproduce steps:
> 1. Add in local.conf the following lines:
>
>    MACHINE ?= "qemux86-64"
>
>    require conf/multilib.conf
>
>    MULTILIBS ?= "multilib:lib32"
>
>    DEFAULTTUNE:virtclass-multilib-lib32 ?= "core2-32"
>
> 2. add lib32-llvm-dev llvm-dev to core-image-minimal.bb
>
>    IMAGE_INSTALL = "packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL} lib32-clang-dev clang-dev"
>
> 3. $ bitbake core-image-minimal
>
> Signed-off-by: Liu Yiding<liuyd.fnst@fujitsu.com>
> ---
>   meta/recipes-devtools/clang/clang_git.bb | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/meta/recipes-devtools/clang/clang_git.bb b/meta/recipes-devtools/clang/clang_git.bb
> index b41b700292..d083dae28b 100644
> --- a/meta/recipes-devtools/clang/clang_git.bb
> +++ b/meta/recipes-devtools/clang/clang_git.bb
> @@ -22,7 +22,7 @@ INHIBIT_DEFAULT_DEPS:class-native = "1"
>   LDFLAGS:append:class-target:riscv32 = " -Wl,--no-as-needed -latomic -Wl,--as-needed"
>   LDFLAGS:append:class-target:mips = " -Wl,--no-as-needed -latomic -Wl,--as-needed"
>   
> -inherit cmake pkgconfig python3native python3targetconfig
> +inherit cmake pkgconfig python3native python3targetconfig multilib_header
>   
>   OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "BOTH"
>   
> @@ -236,6 +236,9 @@ do_install:append() {
>               install -Dm 0755 ${B}${BINPATHPREFIX}/bin/$t ${D}${bindir}/$t
>           fi
>       done
> +
> +    oe_multilib_header llvm/Config/llvm-config.h
> +    oe_multilib_header clang/Config/config.h
>   }
>   
>   do_install:append:class-target () {

Hi Yiding, Khem, and everyone,

This is mostly a note to myself but if anyone else has tried the 
following or wants to, please let me know.
I haven't worked out exactly what the test is yet either so stay tuned.

I think I need to test if this patch enables on-target compilation 
(packagegroup-self-hosted should be able to pull in either gcc or clang, 
IMO)
and if I install both clang and lib32-clang  what options to select to 
get the desired multilib.

Also if we add that selection mechanism, do we still need this patch.

../Randy


>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#216962):https://lists.openembedded.org/g/openembedded-core/message/216962
> Mute This Topic:https://lists.openembedded.org/mt/113223787/3616765
> Group Owner:openembedded-core+owner@lists.openembedded.org
> Unsubscribe:https://lists.openembedded.org/g/openembedded-core/unsub [randy.macleod@windriver.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Xinjian Ma (Fujitsu) June 23, 2025, 3:03 a.m. UTC | #8
Hi Randy



  *   if I install both clang and lib32-clang  what options to select to get the desired multilib.

  *   ​​Runtime​​: Users must explicitly specify architecture.
For example, $clang -m32 hello.c  # Should find 32-bit headers automatically
$clang -m64 hello.c  # Should find 64-bit headers automatically


  *   If we add that selection mechanism, is this patch still needed?
​​​​Yes, absolutely​​. This patch is only to ensure clang-dev and lib32-clang-dev packages physically coexist in the sysroot during builds.

If your system only needs 64-bit support, you don't need multilib at all.
Multilib is only required when you need both 32-bit and 64-bit compatibility.
To enable multilib, you must explicitly add these lines in conf/local.conf:
---------
MULTILIBS ?= "multilib:lib32"
DEFAULTTUNE:virtclass-multilib-lib32 ?= "core2-32"
---------
Otherwise, by default,Yocto will build a pure 64-bit system without any 32-bit components.
The oe_multilib_header patch is only necessary when multilib is enabled.

Yiding

发件人: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> 代表 Randy MacLeod via lists.openembedded.org
发送时间: 2025年6月23日 5:22
收件人: Liu, Yiding/刘 乙丁 <liuyd.fnst@fujitsu.com>; Khem Raj <raj.khem@gmail.com>
抄送: openembedded-core@lists.openembedded.org; Kokkonda, Sundeep <Sundeep.Kokkonda@windriver.com>; Dora, Sunil Kumar <SunilKumar.Dora@windriver.com>
主题: Re: [OE-core] [PATCH] clang: multilib-header fix for llvm/Config/llvm-config.h and clang/Config/config.h


On 2025-05-20 11:14 p.m., Yiding Liu (Fujitsu) via lists.openembedded.org wrote:

Error: Transaction test error:

  file /usr/include/clang/Config/config.h conflicts between attempted installs of

lib32-clang-dev-20.1.4-r0.core2_32 and clang-dev-20.1.4-r0.core2_64

  file /usr/include/llvm/Config/llvm-config.h conflicts between attempted

installs of lib32-clang-dev-20.1.4-r0.core2_32 and clang-dev-20.1.4-r0.core2_64



reproduce steps:

1. Add in local.conf the following lines:



  MACHINE ?= "qemux86-64"



  require conf/multilib.conf



  MULTILIBS ?= "multilib:lib32"



  DEFAULTTUNE:virtclass-multilib-lib32 ?= "core2-32"



2. add lib32-llvm-dev llvm-dev to core-image-minimal.bb



  IMAGE_INSTALL = "packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL} lib32-clang-dev clang-dev"



3. $ bitbake core-image-minimal



Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com><mailto:liuyd.fnst@fujitsu.com>

---

 meta/recipes-devtools/clang/clang_git.bb | 5 ++++-

 1 file changed, 4 insertions(+), 1 deletion(-)



diff --git a/meta/recipes-devtools/clang/clang_git.bb b/meta/recipes-devtools/clang/clang_git.bb

index b41b700292..d083dae28b 100644

--- a/meta/recipes-devtools/clang/clang_git.bb

+++ b/meta/recipes-devtools/clang/clang_git.bb

@@ -22,7 +22,7 @@ INHIBIT_DEFAULT_DEPS:class-native = "1"

 LDFLAGS:append:class-target:riscv32 = " -Wl,--no-as-needed -latomic -Wl,--as-needed"

 LDFLAGS:append:class-target:mips = " -Wl,--no-as-needed -latomic -Wl,--as-needed"



-inherit cmake pkgconfig python3native python3targetconfig

+inherit cmake pkgconfig python3native python3targetconfig multilib_header



 OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "BOTH"



@@ -236,6 +236,9 @@ do_install:append() {

             install -Dm 0755 ${B}${BINPATHPREFIX}/bin/$t ${D}${bindir}/$t

         fi

     done

+

+    oe_multilib_header llvm/Config/llvm-config.h

+    oe_multilib_header clang/Config/config.h

 }



 do_install:append:class-target () {

Hi Yiding, Khem, and everyone,
This is mostly a note to myself but if anyone else has tried the following or wants to, please let me know.
I haven't worked out exactly what the test is yet either so stay tuned.

I think I need to test if this patch enables on-target compilation (packagegroup-self-hosted should be able to pull in either gcc or clang, IMO)
and if I install both clang and lib32-clang  what options to select to get the desired multilib.

Also if we add that selection mechanism, do we still need this patch.

../Randy












--

# Randy MacLeod

# Wind River Linux
Richard Purdie June 23, 2025, 9:03 p.m. UTC | #9
On Mon, 2025-06-23 at 03:03 +0000, Xinjian Ma (Fujitsu) via lists.openembedded.org wrote:
>  * 
>    if I install both clang and lib32-clang  what options to select to
> get the desired multilib.
>  * ​​Runtime​​: Users must explicitly specify architecture. 
> For example, $clang -m32 hello.c # Should find 32-bit headers
> automatically
> $clang -m64 hello.c # Should find 64-bit headers automatically

Did you test this works correctly on target?

The commit message only mentions build time testing and doesn't mention
any runtime testing.

I appreciate the patch fixes build issues but there isn't much point in
doing that if things are still broken at runtime.

Cheers,

Richard
Xinjian Ma (Fujitsu) June 25, 2025, 2:11 a.m. UTC | #10
> -----邮件原件-----
> 发件人: Richard Purdie <richard.purdie@linuxfoundation.org>
> 发送时间: 2025年6月24日 5:04
> 收件人: Ma, Xinjian/马 新建 <maxj.fnst@fujitsu.com>;
> randy.macleod@windriver.com; Liu, Yiding/刘 乙丁 <liuyd.fnst@fujitsu.com>;
> Khem Raj <raj.khem@gmail.com>
> 抄送: openembedded-core@lists.openembedded.org; Kokkonda, Sundeep
> <Sundeep.Kokkonda@windriver.com>; Dora, Sunil Kumar
> <SunilKumar.Dora@windriver.com>
> 主题: Re: 回复: [OE-core] [PATCH] clang: multilib-header fix for
> llvm/Config/llvm-config.h and clang/Config/config.h
> 
> On Mon, 2025-06-23 at 03:03 +0000, Xinjian Ma (Fujitsu) via
> lists.openembedded.org wrote:
> >  *
> >    if I install both clang and lib32-clang  what options to select to
> > get the desired multilib.
> >  * ​​Runtime​​: Users must explicitly specify architecture.
> > For example, $clang -m32 hello.c # Should find 32-bit headers
> > automatically $clang -m64 hello.c # Should find 64-bit headers
> > automatically
> 
> Did you test this works correctly on target?
Yes, I have tested as follows:

After doing reproduce steps in the comment

$ runqemu nographic
$ cat multilib_test.c
#include <stdio.h>
#include <stdint.h>
#include <llvm/Config/llvm-config.h>

int main() {
    printf("=== Multilib Header Test ===\n");

    printf("Pointer size: %zu bits\n", sizeof(void*)*8);

    printf("LLVM_VERSION_MAJOR: %d\n", LLVM_VERSION_MAJOR);
    printf("LLVM_VERSION_MINOR: %d\n", LLVM_VERSION_MINOR);

    #ifdef __i386__
    printf("Header path: 32-bit (__i386__ defined)\n");
    #else
    printf("Header path: 64-bit\n");
    #endif

    printf("===========================\n");
    return 0;
}

$ clang -m32 multilib_test.c -o test32
$ clang -m64 multilib_test.c -o test64


Then here are the outputs:
root@qemux86-64:~/multilib# ./test32
=== Multilib Header Test ===
Pointer size: 32 bits
LLVM_VERSION_MAJOR: 20
LLVM_VERSION_MINOR: 1
Header path: 32-bit (__i386__ defined)
===========================
root@qemux86-64:~/multilib# ./test64
=== Multilib Header Test ===
Pointer size: 64 bits
LLVM_VERSION_MAJOR: 20
LLVM_VERSION_MINOR: 1
Header path: 64-bit
===========================


And I also checked content of header file /usr/include/clang/Config/config.h


root@qemux86-64:~/multilib# cat /usr/include/clang/Config/config.h
/*
 * Copyright (C) 2005-2011 by Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: MIT
 *
 */

#include <bits/wordsize.h>

#if __WORDSIZE == 32

#ifdef _MIPS_SIM

#if _MIPS_SIM == _ABIO32
#include <clang/Config/config-32.h>
#elif _MIPS_SIM == _ABIN32
#include <clang/Config/config-n32.h>
#else
#error "Unknown _MIPS_SIM"
#endif

#else /* _MIPS_SIM is not defined */
#include <clang/Config/config-32.h>
#endif

#elif __WORDSIZE == 64
#include <clang/Config/config-64.h>
#else
#error "Unknown __WORDSIZE detected"
#endif /* matches #if __WORDSIZE == 32 */


root@qemux86-64:~/multilib# ls -l -t /usr/include/clang/Config/config*
-rw-r--r-- 1 root root 2379 Apr  5  2011 /usr/include/clang/Config/config-32.h
-rw-r--r-- 1 root root 2381 Apr  5  2011 /usr/include/clang/Config/config-64.h
-rw-r--r-- 1 root root  564 Apr  5  2011 /usr/include/clang/Config/config.h



> 
> The commit message only mentions build time testing and doesn't mention any
> runtime testing.
> 
> I appreciate the patch fixes build issues but there isn't much point in doing that if
> things are still broken at runtime.
> 
> Cheers,
> 
> Richard
diff mbox series

Patch

diff --git a/meta/recipes-devtools/clang/clang_git.bb b/meta/recipes-devtools/clang/clang_git.bb
index b41b700292..d083dae28b 100644
--- a/meta/recipes-devtools/clang/clang_git.bb
+++ b/meta/recipes-devtools/clang/clang_git.bb
@@ -22,7 +22,7 @@  INHIBIT_DEFAULT_DEPS:class-native = "1"
 LDFLAGS:append:class-target:riscv32 = " -Wl,--no-as-needed -latomic -Wl,--as-needed"
 LDFLAGS:append:class-target:mips = " -Wl,--no-as-needed -latomic -Wl,--as-needed"
 
-inherit cmake pkgconfig python3native python3targetconfig
+inherit cmake pkgconfig python3native python3targetconfig multilib_header
 
 OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "BOTH"
 
@@ -236,6 +236,9 @@  do_install:append() {
             install -Dm 0755 ${B}${BINPATHPREFIX}/bin/$t ${D}${bindir}/$t
         fi
     done
+
+    oe_multilib_header llvm/Config/llvm-config.h
+    oe_multilib_header clang/Config/config.h
 }
 
 do_install:append:class-target () {