Bug 15024

Summary: Meson compiler build failures for mips/octeon2.
Product: [Build System, Metadata & Runtime] Meta-yocto Reporter: mabnhdev
Component: meta-yoctoAssignee: Unassigned <unassigned>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: mabnhdev, pavel, poky.bs.watcher, poky.watcher, raj.khem, randy.macleod
Version: 4.0.7   
Target Milestone: 4.2 M3   
Hardware: Other   
OS: mips   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
Bash shell used to reproduce the failure. 'meson-repro.sh mips'
none
Full build failure log.
none
Bash script to reproduce the problem. Run with no arguments.
none
meson.cross as requested none

Description mabnhdev 2023-02-01 14:36:10 UTC
Created attachment 4920 [details]
Bash shell used to reproduce the failure. 'meson-repro.sh mips'

When cross-compiling for octeon2 (mips), the meson compiler fails to compile components with the error 'Executables created by c compiler ... are not runnable'.

I've included a bash script that can be used to reproduce the errors and the full log of the build failure.

Run the script using the command 'meson-repro.sh mips'.

Build Configuration:

BB_VERSION           = "2.0.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "ubuntu-22.04"
TARGET_SYS           = "mips-poky-linux"
MACHINE              = "my-meson-repro-mips"
DISTRO               = "poky"
DISTRO_VERSION       = "4.0.7"
TUNE_FEATURES        = "o32 bigendian fpu-hard octeon2"
TARGET_FPU           = ""

| The Meson build system
| Version: 0.61.3
| Source dir: /home/mabnhdev/meson-repro-mips/build/tmp/work/octeon2-o32-poky-linux/xorgproto/2021.5-r0/xorgproto-2021.5
| Build dir: /home/mabnhdev/meson-repro-mips/build/tmp/work/octeon2-o32-poky-linux/xorgproto/2021.5-r0/build
| Build type: cross build
| Project name: xorgproto
| Project version: 2021.5
| 
| ../xorgproto-2021.5/meson.build:22:0: ERROR: Executables created by c compiler mips-poky-linux-gcc -meb -mabi=32 -mhard-float -march=octeon2 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/mabnhdev/meson-repro-mips/build/tmp/work/octeon2-o32-poky-linux/xorgproto/2021.5-r0/recipe-sysroot are not runnable.
Comment 1 mabnhdev 2023-02-01 14:36:58 UTC
Created attachment 4921 [details]
Full build failure log.
Comment 2 mabnhdev 2023-02-01 17:16:29 UTC
Created attachment 4922 [details]
Bash script to reproduce the problem.  Run with no arguments.
Comment 3 Randy MacLeod 2023-02-02 15:41:37 UTC
Not many members of the Yocto community are using octeon so this is unassigned.

What branch is this happening on?
Comment 4 Randy MacLeod 2023-02-02 15:42:48 UTC
See question in previous comment.
Comment 5 mabnhdev 2023-02-02 17:11:38 UTC
This is happening in 4.0.7 - branch Kirkstone.
Comment 6 mabnhdev 2023-02-02 17:18:31 UTC
The attached script will reproduce the problem in Kirkstone.

I understand octeon is not a heavily used architecture.  I'm hoping that it is an easy fix for mips in general.
Comment 7 Randy MacLeod 2023-02-03 01:25:54 UTC
I'm not sure but I think Khem still has need of mips so I've CCed him.
Comment 8 Khem Raj 2023-02-03 01:55:31 UTC
Can you post meson.cross which is being used ?
secondly, are you seeing this issue with qemumips ?
thirdly. does it happen with trunk too ?
Comment 9 mabnhdev 2023-02-03 03:55:00 UTC
No, this does not happen with qemumips.

To try yourself, just change Line #28 in the repro script to 'MACHINE = "qemumips"'.
Comment 10 Khem Raj 2023-02-03 04:15:54 UTC
(In reply to comment #9)
> No, this does not happen with qemumips.
> 
> To try yourself, just change Line #28 in the repro script to 'MACHINE =
> "qemumips"'.

I know, I can do it. Since you have this reproduced and perhaps files are handy it is faster to get to it. Thats why I asked for uploading meson.cross file from builddir of failing component.
Comment 11 mabnhdev 2023-02-03 05:19:59 UTC
Same failure with the octeon-o32 in HEAD also.

BB_VERSION           = "2.2.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "ubuntu-22.04"
TARGET_SYS           = "mips-poky-linux"
MACHINE              = "my-meson-repro"
DISTRO               = "poky"
DISTRO_VERSION       = "4.1+snapshot-61c35514cfd27dda045735695f8960126e0704b5"
TUNE_FEATURES        = "o32 bigendian fpu-hard octeon2"
TARGET_FPU           = ""
meta                 
meta-poky            
meta-yocto-bsp       = "master:61c35514cfd27dda045735695f8960126e0704b5"
meta-meson-repro     = "<unknown>:<unknown>"

| ../xorgproto-2022.2/meson.build:22:0: ERROR: Executables created by c compiler mips-poky-linux-gcc -meb -mabi=32 -mhard-float -march=octeon2 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/mabnhdev/meson-repro/build/tmp/work/octeon2-o32-poky-linux/xorgproto/2022.2-r0/recipe-sysroot are not runnable.
Comment 12 mabnhdev 2023-02-03 05:24:11 UTC
Created attachment 4928 [details]
meson.cross as requested

This is from the HEAD rather than Kirkstone, but they both fail the same way, so I assume this is sufficient.
Comment 13 Khem Raj 2023-02-03 06:23:58 UTC
(In reply to comment #12)
> Created attachment 4928 [details]
> meson.cross as requested
> 
> This is from the HEAD rather than Kirkstone, but they both fail the same
> way, so I assume this is sufficient.

Thanks meson.cross is fine, so I think the generated binaries are being run in qemu-user and its not able to run it because they contain some octeon specific instruction which is it not emulating.

Can you also upload followinf two files.

/home/mabnhdev/meson-repro-mips/build/tmp/work/octeon2-o32-poky-linux/xorgproto/2021.5-r0/meson-qemuwrapper

/home/mabnhdev/meson-repro-mips/build/tmp/work/octeon2-o32-poky-linux/xorgproto/2021.5-r0/build/meson-private/sanitycheckc_cross.exe
Comment 14 Khem Raj 2023-02-03 06:44:52 UTC
qemumips o32 does not support any octeon emulation instructions and most probably thats whats going on here becasue I see -march=octeon2 is in the compile cmdline. So any qemu usermode invocation is likely to fail. So one of two things can be done.

1. Add something like below to the octeon2 tune file.
MACHINE_FEATURES_BACKFILL_CONSIDERED:append = "${@bb.utils.contains('TUNE_FEATURES', 'octeon2', ' qemu-usermode', '', d)}"

2. Remove -march=octeon2 from tune file.

For 64bit octeon builds try adding

QEMU_EXTRAOPTIONS_octeon2 = " -cpu Octeon68XX"

to ./meta/classes-recipe/qemu.bbclass
Comment 15 mabnhdev 2023-02-04 15:45:32 UTC
> 1. Add something like below to the octeon2 tune file.
MACHINE_FEATURES_BACKFILL_CONSIDERED:append = "${@bb.utils.contains('TUNE_FEATURES', 'octeon2', ' qemu-usermode', '', d)}"

Your first suggestion works for me - I can now complete the build of my mips/octeon2 platform with no errors.  Thanks!

I'm not really knowledgeable about QEMU - would you mind giving me a brief explanation as to why this worked?
Comment 16 mabnhdev 2023-02-04 15:50:23 UTC
As far as I'm concerned, I consider this issue resolved.  I'll leave it to the PTB as to whether, from a project point of view, there is any further action needed.
Comment 17 Randy MacLeod 2023-02-04 19:43:06 UTC
Thanks to Khem, the reporter has a work-around and unless someone funds more complete emulation of octeon2 in qemu, there's nothing else to be done so marking as resolved.