diff mbox series

libucontext: use hard/soft float

Message ID 20250630144814.255656-1-jdmason@kudzu.us
State Accepted, archived
Commit 61c54f169db74b818f587b3147c9abb611f64e0d
Headers show
Series libucontext: use hard/soft float | expand

Commit Message

Jon Mason June 30, 2025, 2:48 p.m. UTC
From: Jon Mason <jon.mason@arm.com>

When building for qemuarm-secureboot in meta-arn with musl and clang,
the following compile error is seen:
- | ../sources/libucontext-1.3.2/arch/arm/swapcontext.S:23:11: error: unknown token in expression
- |  ldr r4, =#0x56465001
- |           ^

This is happening because 1.3 added ifdefs for assembly code for both
hard and soft float, and bcause neither is being defined, it is taking
this path with the issue.

Since we can tell if soft or hard float is being used via the TARGET_FPU
variable, use that and set the relevant makefile flag.

Signed-off-by: Jon Mason <jon.mason@arm.com>
---
 meta/recipes-core/musl/libucontext_1.3.2.bb | 3 +++
 1 file changed, 3 insertions(+)

Comments

Mark Hatle June 30, 2025, 4:32 p.m. UTC | #1
On 6/30/25 9:48 AM, Jon Mason wrote:
> From: Jon Mason <jon.mason@arm.com>
> 
> When building for qemuarm-secureboot in meta-arn with musl and clang,
> the following compile error is seen:
> - | ../sources/libucontext-1.3.2/arch/arm/swapcontext.S:23:11: error: unknown token in expression
> - |  ldr r4, =#0x56465001
> - |           ^
> 
> This is happening because 1.3 added ifdefs for assembly code for both
> hard and soft float, and bcause neither is being defined, it is taking
> this path with the issue.
> 
> Since we can tell if soft or hard float is being used via the TARGET_FPU
> variable, use that and set the relevant makefile flag.
> 
> Signed-off-by: Jon Mason <jon.mason@arm.com>
> ---
>   meta/recipes-core/musl/libucontext_1.3.2.bb | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/meta/recipes-core/musl/libucontext_1.3.2.bb b/meta/recipes-core/musl/libucontext_1.3.2.bb
> index 2362cba5c8a2..92001bbe7bb5 100644
> --- a/meta/recipes-core/musl/libucontext_1.3.2.bb
> +++ b/meta/recipes-core/musl/libucontext_1.3.2.bb
> @@ -48,3 +48,6 @@ def map_kernel_arch(a, d):
>   
>   EXTRA_OEMESON = "-Dcpu=${@map_kernel_arch(d.getVar('TARGET_ARCH'), d)}"
>   inherit meson
> +
> +TARGET_CPPFLAGS:arm += "${@bb.utils.contains('TARGET_FPU', 'hard', '-DFORCE_HARD_FLOAT', '', d)}"
> +TARGET_CPPFLAGS:arm += "${@bb.utils.contains('TARGET_FPU', 'soft', '-DFORCE_SOFT_FLOAT', '', d)}"

The above doesn't += to TARGET_CPPFLAGS, it _replaces_ TARGET_CPPFLAGS.

This is probably not what you want.

What I've done in the past is:

ARM_TARGET_CPPFLAGS = ""
ARM_TARGET_CPPFLAGS:append:arm = "${@bb.utils.contains('TARGET_FPU', 'hard', '- 
DFORCE_HARD_FLOAT', '', d)}"
ARM_TARGET_CPPFLAGS:append:arm = "${@bb.utils.contains('TARGET_FPU', 'soft', ' 
-DFORCE_SOFT_FLOAT', '', d)}"

TARGET_CPPFLAGS .= "${ARM_TARGET_CPPFLAGS}"

> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#219524): https://lists.openembedded.org/g/openembedded-core/message/219524
> Mute This Topic: https://lists.openembedded.org/mt/113909237/3616948
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [mark.hatle@kernel.crashing.org]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Jon Mason July 1, 2025, 1:24 p.m. UTC | #2
On Mon, Jun 30, 2025 at 12:32 PM Mark Hatle
<mark.hatle@kernel.crashing.org> wrote:
>
>
>
> On 6/30/25 9:48 AM, Jon Mason wrote:
> > From: Jon Mason <jon.mason@arm.com>
> >
> > When building for qemuarm-secureboot in meta-arn with musl and clang,
> > the following compile error is seen:
> > - | ../sources/libucontext-1.3.2/arch/arm/swapcontext.S:23:11: error: unknown token in expression
> > - |  ldr r4, =#0x56465001
> > - |           ^
> >
> > This is happening because 1.3 added ifdefs for assembly code for both
> > hard and soft float, and bcause neither is being defined, it is taking
> > this path with the issue.
> >
> > Since we can tell if soft or hard float is being used via the TARGET_FPU
> > variable, use that and set the relevant makefile flag.
> >
> > Signed-off-by: Jon Mason <jon.mason@arm.com>
> > ---
> >   meta/recipes-core/musl/libucontext_1.3.2.bb | 3 +++
> >   1 file changed, 3 insertions(+)
> >
> > diff --git a/meta/recipes-core/musl/libucontext_1.3.2.bb b/meta/recipes-core/musl/libucontext_1.3.2.bb
> > index 2362cba5c8a2..92001bbe7bb5 100644
> > --- a/meta/recipes-core/musl/libucontext_1.3.2.bb
> > +++ b/meta/recipes-core/musl/libucontext_1.3.2.bb
> > @@ -48,3 +48,6 @@ def map_kernel_arch(a, d):
> >
> >   EXTRA_OEMESON = "-Dcpu=${@map_kernel_arch(d.getVar('TARGET_ARCH'), d)}"
> >   inherit meson
> > +
> > +TARGET_CPPFLAGS:arm += "${@bb.utils.contains('TARGET_FPU', 'hard', '-DFORCE_HARD_FLOAT', '', d)}"
> > +TARGET_CPPFLAGS:arm += "${@bb.utils.contains('TARGET_FPU', 'soft', '-DFORCE_SOFT_FLOAT', '', d)}"
>
> The above doesn't += to TARGET_CPPFLAGS, it _replaces_ TARGET_CPPFLAGS.
>
> This is probably not what you want.
>
> What I've done in the past is:
>
> ARM_TARGET_CPPFLAGS = ""
> ARM_TARGET_CPPFLAGS:append:arm = "${@bb.utils.contains('TARGET_FPU', 'hard', '-
> DFORCE_HARD_FLOAT', '', d)}"
> ARM_TARGET_CPPFLAGS:append:arm = "${@bb.utils.contains('TARGET_FPU', 'soft', '
> -DFORCE_SOFT_FLOAT', '', d)}"
>
> TARGET_CPPFLAGS .= "${ARM_TARGET_CPPFLAGS}"

Thanks for the insight Mark, I will happily steal your changes and
throw it as a v2 :)

Is there a place I can look (documentation or code) that will help me
understand why this is necessary?

Thanks,
Jon

> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#219524): https://lists.openembedded.org/g/openembedded-core/message/219524
> > Mute This Topic: https://lists.openembedded.org/mt/113909237/3616948
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [mark.hatle@kernel.crashing.org]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
Mark Hatle July 1, 2025, 8:54 p.m. UTC | #3
On 7/1/25 8:24 AM, Jon Mason wrote:
> On Mon, Jun 30, 2025 at 12:32 PM Mark Hatle
> <mark.hatle@kernel.crashing.org> wrote:
>>
>>
>>
>> On 6/30/25 9:48 AM, Jon Mason wrote:
>>> From: Jon Mason <jon.mason@arm.com>
>>>
>>> When building for qemuarm-secureboot in meta-arn with musl and clang,
>>> the following compile error is seen:
>>> - | ../sources/libucontext-1.3.2/arch/arm/swapcontext.S:23:11: error: unknown token in expression
>>> - |  ldr r4, =#0x56465001
>>> - |           ^
>>>
>>> This is happening because 1.3 added ifdefs for assembly code for both
>>> hard and soft float, and bcause neither is being defined, it is taking
>>> this path with the issue.
>>>
>>> Since we can tell if soft or hard float is being used via the TARGET_FPU
>>> variable, use that and set the relevant makefile flag.
>>>
>>> Signed-off-by: Jon Mason <jon.mason@arm.com>
>>> ---
>>>    meta/recipes-core/musl/libucontext_1.3.2.bb | 3 +++
>>>    1 file changed, 3 insertions(+)
>>>
>>> diff --git a/meta/recipes-core/musl/libucontext_1.3.2.bb b/meta/recipes-core/musl/libucontext_1.3.2.bb
>>> index 2362cba5c8a2..92001bbe7bb5 100644
>>> --- a/meta/recipes-core/musl/libucontext_1.3.2.bb
>>> +++ b/meta/recipes-core/musl/libucontext_1.3.2.bb
>>> @@ -48,3 +48,6 @@ def map_kernel_arch(a, d):
>>>
>>>    EXTRA_OEMESON = "-Dcpu=${@map_kernel_arch(d.getVar('TARGET_ARCH'), d)}"
>>>    inherit meson
>>> +
>>> +TARGET_CPPFLAGS:arm += "${@bb.utils.contains('TARGET_FPU', 'hard', '-DFORCE_HARD_FLOAT', '', d)}"
>>> +TARGET_CPPFLAGS:arm += "${@bb.utils.contains('TARGET_FPU', 'soft', '-DFORCE_SOFT_FLOAT', '', d)}"
>>
>> The above doesn't += to TARGET_CPPFLAGS, it _replaces_ TARGET_CPPFLAGS.
>>
>> This is probably not what you want.
>>
>> What I've done in the past is:
>>
>> ARM_TARGET_CPPFLAGS = ""
>> ARM_TARGET_CPPFLAGS:append:arm = "${@bb.utils.contains('TARGET_FPU', 'hard', '-
>> DFORCE_HARD_FLOAT', '', d)}"
>> ARM_TARGET_CPPFLAGS:append:arm = "${@bb.utils.contains('TARGET_FPU', 'soft', '
>> -DFORCE_SOFT_FLOAT', '', d)}"
>>
>> TARGET_CPPFLAGS .= "${ARM_TARGET_CPPFLAGS}"
> 
> Thanks for the insight Mark, I will happily steal your changes and
> throw it as a v2 :)
> 
> Is there a place I can look (documentation or code) that will help me
> understand why this is necessary?

Theoretically the bitbake documentation covers the operator and override rules.. 
but essentially operators all run, and then a second+ pass is made to remove 
overrides.

(:append is an operator, not an override)

So it's not exactly intuitive unless you've worked with it a lot, and even then 
it's easy to make mistakes in these odd cases!

But what happens is:

VARIABLE:override += "foo"
VARIABLE:override += "bar"

Evaluation will attempt to add a space and foo to 'VARIABLE:override', followed 
by a space and bar.  Resulting in ' foo bar'

Then override processing causes 'VARIABLE:override' replaces 'VARIABLE' when the 
override is present resulting in:

VARIABLE = ' foo bar'

I've recently seen CoPilot suggest exactly this to users.  And it USUALLY works, 
but it's chance vs design.

--Mark

> Thanks,
> Jon
> 
>>>
>>>
>>>
>>>
>>>
>>>
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>> Links: You receive all messages sent to this group.
>>> View/Reply Online (#219569): https://lists.openembedded.org/g/openembedded-core/message/219569
>>> Mute This Topic: https://lists.openembedded.org/mt/113909237/3616948
>>> Group Owner: openembedded-core+owner@lists.openembedded.org
>>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [mark.hatle@kernel.crashing.org]
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>
diff mbox series

Patch

diff --git a/meta/recipes-core/musl/libucontext_1.3.2.bb b/meta/recipes-core/musl/libucontext_1.3.2.bb
index 2362cba5c8a2..92001bbe7bb5 100644
--- a/meta/recipes-core/musl/libucontext_1.3.2.bb
+++ b/meta/recipes-core/musl/libucontext_1.3.2.bb
@@ -48,3 +48,6 @@  def map_kernel_arch(a, d):
 
 EXTRA_OEMESON = "-Dcpu=${@map_kernel_arch(d.getVar('TARGET_ARCH'), d)}"
 inherit meson
+
+TARGET_CPPFLAGS:arm += "${@bb.utils.contains('TARGET_FPU', 'hard', '-DFORCE_HARD_FLOAT', '', d)}"
+TARGET_CPPFLAGS:arm += "${@bb.utils.contains('TARGET_FPU', 'soft', '-DFORCE_SOFT_FLOAT', '', d)}"