diff mbox series

toolchain/clang: handle big.LITTLE Arm SoCs

Message ID 20250716145707.2271609-1-skandigraun@gmail.com
State New
Headers show
Series toolchain/clang: handle big.LITTLE Arm SoCs | expand

Commit Message

Gyorgy Sarvari July 16, 2025, 2:57 p.m. UTC
clang doesn't have Arm big.LITTLE specific tune options - when they are used,
the compilation fails with an error like this:

aarch64-poky-linux-clang: error: unsupported argument 'cortex-a72.cortex-a53+crc+crypto' to option '-mcpu='

To avoid this, in case a big.LITTLE SoC is the target, select the tune corresponding
to the LITTLE core.

This has been lifted from meta-clang, extended with cortexa73-cortexa35 which
was missing.

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
 meta/classes/toolchain/clang.bbclass | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Quentin Schulz July 16, 2025, 3:10 p.m. UTC | #1
Hi Gyorgy,

On 7/16/25 4:57 PM, Gyorgy Sarvari via lists.openembedded.org wrote:
> clang doesn't have Arm big.LITTLE specific tune options - when they are used,
> the compilation fails with an error like this:
> 
> aarch64-poky-linux-clang: error: unsupported argument 'cortex-a72.cortex-a53+crc+crypto' to option '-mcpu='
> 
> To avoid this, in case a big.LITTLE SoC is the target, select the tune corresponding
> to the LITTLE core.
> 
> This has been lifted from meta-clang, extended with cortexa73-cortexa35 which
> was missing.
> 
> Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
> ---
>   meta/classes/toolchain/clang.bbclass | 16 ++++++++++++++++
>   1 file changed, 16 insertions(+)
> 
> diff --git a/meta/classes/toolchain/clang.bbclass b/meta/classes/toolchain/clang.bbclass
> index d7b8a3657c..b0e284be84 100644
> --- a/meta/classes/toolchain/clang.bbclass
> +++ b/meta/classes/toolchain/clang.bbclass
> @@ -34,4 +34,20 @@ TUNE_CCARGS += "${@bb.utils.contains("DISTRO_FEATURES", "usrmerge", " --dyld-pre
>   LDFLAGS:append:class-nativesdk:x86-64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-x86-64.so.2"
>   LDFLAGS:append:class-nativesdk:aarch64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-aarch64.so.1"
>   
> +# clang doesn't support big.LITTLE tunes, choose always the tune for the LITTLE cores
> +TUNE_CCARGS:remove = "\
> +    -mcpu=cortex-a57.cortex-a53${TUNE_CCARGS_MARCH_OPTS} \
> +    -mcpu=cortex-a72.cortex-a53${TUNE_CCARGS_MARCH_OPTS} \
> +    -mcpu=cortex-a15.cortex-a7${TUNE_CCARGS_MARCH_OPTS} \
> +    -mcpu=cortex-a17.cortex-a7${TUNE_CCARGS_MARCH_OPTS} \
> +    -mcpu=cortex-a72.cortex-a35${TUNE_CCARGS_MARCH_OPTS} \
> +    -mcpu=cortex-a73.cortex-a35${TUNE_CCARGS_MARCH_OPTS} \
> +    -mcpu=cortex-a73.cortex-a53${TUNE_CCARGS_MARCH_OPTS} \
> +    -mcpu=cortex-a75.cortex-a55${TUNE_CCARGS_MARCH_OPTS} \
> +    -mcpu=cortex-a76.cortex-a55${TUNE_CCARGS_MARCH_OPTS}"
> +TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa72-cortexa53 cortexa57-cortexa53 cortexa73-cortexa53", " -mcpu=cortex-a53${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
> +TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa15-cortexa7 cortexa17-cortexa7", " -mcpu=cortex-a7${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
> +TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa72-cortexa35 cortexa73-cortexa35", " -mcpu=cortex-a35${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
> +TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa75-cortexa55 cortexa76-cortexa55", " -mcpu=cortex-a55${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
> +

Wouldn't it be better to have this in the tune conf file directly? I'm a 
bit worried we'll have more big.LITTLE flavors in the future and because 
this is in a separate file it'll be out of date.

We should be able to do that by simply using the toolchain-clang or 
toolchain-gcc override wherever appropriate?

E.g.

MCPU = "cortexa73-cortexa35"
# clang doesn't have Arm big.LITTLE specific tune options, so select the 
tune corresponding to the LITTLE core.
MCPU:toolchain-clang = "cortexa35"

TUNE_CCARGS .= "${@bb.utils.contains("TUNE_FEATURES", 
"cortexa73-cortexa35", " -mcpu=${MCPU}", "", d)}"

[... and other replacements in 
meta/conf/machine/include/arm/armv8a/tune-cortexa73-cortexa35.inc]

(NOT TESTED) something like that?

What do you think?

Cheers,
Quentin
Gyorgy Sarvari July 16, 2025, 3:20 p.m. UTC | #2
On 7/16/25 17:10, Quentin Schulz wrote:
> Hi Gyorgy,
>
> On 7/16/25 4:57 PM, Gyorgy Sarvari via lists.openembedded.org wrote:
>> clang doesn't have Arm big.LITTLE specific tune options - when they are used,
>> the compilation fails with an error like this:
>>
>> aarch64-poky-linux-clang: error: unsupported argument 'cortex-a72.cortex-a53+crc+crypto' to option '-mcpu='
>>
>> To avoid this, in case a big.LITTLE SoC is the target, select the tune corresponding
>> to the LITTLE core.
>>
>> This has been lifted from meta-clang, extended with cortexa73-cortexa35 which
>> was missing.
>>
>> Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
>> ---
>>   meta/classes/toolchain/clang.bbclass | 16 ++++++++++++++++
>>   1 file changed, 16 insertions(+)
>>
>> diff --git a/meta/classes/toolchain/clang.bbclass b/meta/classes/toolchain/clang.bbclass
>> index d7b8a3657c..b0e284be84 100644
>> --- a/meta/classes/toolchain/clang.bbclass
>> +++ b/meta/classes/toolchain/clang.bbclass
>> @@ -34,4 +34,20 @@ TUNE_CCARGS += "${@bb.utils.contains("DISTRO_FEATURES", "usrmerge", " --dyld-pre
>>   LDFLAGS:append:class-nativesdk:x86-64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-x86-64.so.2"
>>   LDFLAGS:append:class-nativesdk:aarch64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-aarch64.so.1"
>>   
>> +# clang doesn't support big.LITTLE tunes, choose always the tune for the LITTLE cores
>> +TUNE_CCARGS:remove = "\
>> +    -mcpu=cortex-a57.cortex-a53${TUNE_CCARGS_MARCH_OPTS} \
>> +    -mcpu=cortex-a72.cortex-a53${TUNE_CCARGS_MARCH_OPTS} \
>> +    -mcpu=cortex-a15.cortex-a7${TUNE_CCARGS_MARCH_OPTS} \
>> +    -mcpu=cortex-a17.cortex-a7${TUNE_CCARGS_MARCH_OPTS} \
>> +    -mcpu=cortex-a72.cortex-a35${TUNE_CCARGS_MARCH_OPTS} \
>> +    -mcpu=cortex-a73.cortex-a35${TUNE_CCARGS_MARCH_OPTS} \
>> +    -mcpu=cortex-a73.cortex-a53${TUNE_CCARGS_MARCH_OPTS} \
>> +    -mcpu=cortex-a75.cortex-a55${TUNE_CCARGS_MARCH_OPTS} \
>> +    -mcpu=cortex-a76.cortex-a55${TUNE_CCARGS_MARCH_OPTS}"
>> +TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa72-cortexa53 cortexa57-cortexa53 cortexa73-cortexa53", " -mcpu=cortex-a53${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
>> +TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa15-cortexa7 cortexa17-cortexa7", " -mcpu=cortex-a7${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
>> +TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa72-cortexa35 cortexa73-cortexa35", " -mcpu=cortex-a35${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
>> +TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa75-cortexa55 cortexa76-cortexa55", " -mcpu=cortex-a55${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
>> +
> Wouldn't it be better to have this in the tune conf file directly? I'm a 
> bit worried we'll have more big.LITTLE flavors in the future and because 
> this is in a separate file it'll be out of date.
>
> We should be able to do that by simply using the toolchain-clang or 
> toolchain-gcc override wherever appropriate?
>
> E.g.
>
> MCPU = "cortexa73-cortexa35"
> # clang doesn't have Arm big.LITTLE specific tune options, so select the 
> tune corresponding to the LITTLE core.
> MCPU:toolchain-clang = "cortexa35"
>
> TUNE_CCARGS .= "${@bb.utils.contains("TUNE_FEATURES", 
> "cortexa73-cortexa35", " -mcpu=${MCPU}", "", d)}"
>
> [... and other replacements in 
> meta/conf/machine/include/arm/armv8a/tune-cortexa73-cortexa35.inc]
>
> (NOT TESTED) something like that?
>
> What do you think?

I have no strong opinion about this... with that said, the original list
was indeed slightly outdated. Will send a v2 later today with this
implementation.
Khem Raj July 17, 2025, 1:39 a.m. UTC | #3
On Wed, Jul 16, 2025 at 8:10 AM Quentin Schulz via
lists.openembedded.org
<quentin.schulz=cherry.de@lists.openembedded.org> wrote:
>
> Hi Gyorgy,
>
> On 7/16/25 4:57 PM, Gyorgy Sarvari via lists.openembedded.org wrote:
> > clang doesn't have Arm big.LITTLE specific tune options - when they are used,
> > the compilation fails with an error like this:
> >
> > aarch64-poky-linux-clang: error: unsupported argument 'cortex-a72.cortex-a53+crc+crypto' to option '-mcpu='
> >
> > To avoid this, in case a big.LITTLE SoC is the target, select the tune corresponding
> > to the LITTLE core.
> >
> > This has been lifted from meta-clang, extended with cortexa73-cortexa35 which
> > was missing.
> >
> > Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
> > ---
> >   meta/classes/toolchain/clang.bbclass | 16 ++++++++++++++++
> >   1 file changed, 16 insertions(+)
> >
> > diff --git a/meta/classes/toolchain/clang.bbclass b/meta/classes/toolchain/clang.bbclass
> > index d7b8a3657c..b0e284be84 100644
> > --- a/meta/classes/toolchain/clang.bbclass
> > +++ b/meta/classes/toolchain/clang.bbclass
> > @@ -34,4 +34,20 @@ TUNE_CCARGS += "${@bb.utils.contains("DISTRO_FEATURES", "usrmerge", " --dyld-pre
> >   LDFLAGS:append:class-nativesdk:x86-64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-x86-64.so.2"
> >   LDFLAGS:append:class-nativesdk:aarch64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-aarch64.so.1"
> >
> > +# clang doesn't support big.LITTLE tunes, choose always the tune for the LITTLE cores
> > +TUNE_CCARGS:remove = "\
> > +    -mcpu=cortex-a57.cortex-a53${TUNE_CCARGS_MARCH_OPTS} \
> > +    -mcpu=cortex-a72.cortex-a53${TUNE_CCARGS_MARCH_OPTS} \
> > +    -mcpu=cortex-a15.cortex-a7${TUNE_CCARGS_MARCH_OPTS} \
> > +    -mcpu=cortex-a17.cortex-a7${TUNE_CCARGS_MARCH_OPTS} \
> > +    -mcpu=cortex-a72.cortex-a35${TUNE_CCARGS_MARCH_OPTS} \
> > +    -mcpu=cortex-a73.cortex-a35${TUNE_CCARGS_MARCH_OPTS} \
> > +    -mcpu=cortex-a73.cortex-a53${TUNE_CCARGS_MARCH_OPTS} \
> > +    -mcpu=cortex-a75.cortex-a55${TUNE_CCARGS_MARCH_OPTS} \
> > +    -mcpu=cortex-a76.cortex-a55${TUNE_CCARGS_MARCH_OPTS}"
> > +TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa72-cortexa53 cortexa57-cortexa53 cortexa73-cortexa53", " -mcpu=cortex-a53${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
> > +TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa15-cortexa7 cortexa17-cortexa7", " -mcpu=cortex-a7${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
> > +TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa72-cortexa35 cortexa73-cortexa35", " -mcpu=cortex-a35${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
> > +TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa75-cortexa55 cortexa76-cortexa55", " -mcpu=cortex-a55${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
> > +
>
> Wouldn't it be better to have this in the tune conf file directly? I'm a
> bit worried we'll have more big.LITTLE flavors in the future and because
> this is in a separate file it'll be out of date.
>
> We should be able to do that by simply using the toolchain-clang or
> toolchain-gcc override wherever appropriate?
>
> E.g.
>
> MCPU = "cortexa73-cortexa35"
> # clang doesn't have Arm big.LITTLE specific tune options, so select the
> tune corresponding to the LITTLE core.
> MCPU:toolchain-clang = "cortexa35"
>
> TUNE_CCARGS .= "${@bb.utils.contains("TUNE_FEATURES",
> "cortexa73-cortexa35", " -mcpu=${MCPU}", "", d)}"
>
> [... and other replacements in
> meta/conf/machine/include/arm/armv8a/tune-cortexa73-cortexa35.inc]
>
> (NOT TESTED) something like that?
>
> What do you think?

Agreed. Having it in tune files is definitely easier to maintain

>
> Cheers,
> Quentin
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#220469): https://lists.openembedded.org/g/openembedded-core/message/220469
> Mute This Topic: https://lists.openembedded.org/mt/114186273/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/classes/toolchain/clang.bbclass b/meta/classes/toolchain/clang.bbclass
index d7b8a3657c..b0e284be84 100644
--- a/meta/classes/toolchain/clang.bbclass
+++ b/meta/classes/toolchain/clang.bbclass
@@ -34,4 +34,20 @@  TUNE_CCARGS += "${@bb.utils.contains("DISTRO_FEATURES", "usrmerge", " --dyld-pre
 LDFLAGS:append:class-nativesdk:x86-64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-x86-64.so.2"
 LDFLAGS:append:class-nativesdk:aarch64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-aarch64.so.1"
 
+# clang doesn't support big.LITTLE tunes, choose always the tune for the LITTLE cores
+TUNE_CCARGS:remove = "\
+    -mcpu=cortex-a57.cortex-a53${TUNE_CCARGS_MARCH_OPTS} \
+    -mcpu=cortex-a72.cortex-a53${TUNE_CCARGS_MARCH_OPTS} \
+    -mcpu=cortex-a15.cortex-a7${TUNE_CCARGS_MARCH_OPTS} \
+    -mcpu=cortex-a17.cortex-a7${TUNE_CCARGS_MARCH_OPTS} \
+    -mcpu=cortex-a72.cortex-a35${TUNE_CCARGS_MARCH_OPTS} \
+    -mcpu=cortex-a73.cortex-a35${TUNE_CCARGS_MARCH_OPTS} \
+    -mcpu=cortex-a73.cortex-a53${TUNE_CCARGS_MARCH_OPTS} \
+    -mcpu=cortex-a75.cortex-a55${TUNE_CCARGS_MARCH_OPTS} \
+    -mcpu=cortex-a76.cortex-a55${TUNE_CCARGS_MARCH_OPTS}"
+TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa72-cortexa53 cortexa57-cortexa53 cortexa73-cortexa53", " -mcpu=cortex-a53${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
+TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa15-cortexa7 cortexa17-cortexa7", " -mcpu=cortex-a7${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
+TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa72-cortexa35 cortexa73-cortexa35", " -mcpu=cortex-a35${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
+TUNE_CCARGS:append = "${@bb.utils.contains_any("TUNE_FEATURES", "cortexa75-cortexa55 cortexa76-cortexa55", " -mcpu=cortex-a55${TUNE_CCARGS_MARCH_OPTS}", "", d)}"
+
 TCOVERRIDE = "toolchain-clang"