# Compile Mender for \`mipsel\` (32bit) architecture

**URL:** <https://hub.mender.io/t/compile-mender-for-mipsel-32bit-architecture/5387>\
**Category:** General Discussions\
**Tags:** mipsel, mips, x2000\
**Created:** [November 11, 2022, 1:47pm UTC](https://hub.mender.io/t/compile-mender-for-mipsel-32bit-architecture/5387 "2022-11-11T13:47:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stwirth](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/stwirth/32/1785_2.png) [@stwirth](https://hub.mender.io/u/stwirth)\
**Post date:** [November 11, 2022, 1:47pm UTC](https://hub.mender.io/t/compile-mender-for-mipsel-32bit-architecture/5387/1 "2022-11-11T13:47:16Z")

</div>

I’m trying to get Mender running on a MIPS-based 32bit SoC.  
Build environment is buildroot 2020.02.1. Here are some relevant configuration variables:

```auto
# BR2_mips is not set
BR2_mipsel=y
# BR2_mips64 is not set
# BR2_mips64el is not set
BR2_ARCH="mipsel"
BR2_ENDIAN="LITTLE"
BR2_GCC_TARGET_ARCH="mips32r2"
BR2_GCC_TARGET_ABI="32"
BR2_GCC_TARGET_NAN="2008"
BR2_GCC_TARGET_FP32_MODE="64"
BR2_BINFMT_SUPPORTS_SHARED=y
BR2_READELF_ARCH_NAME="MIPS R3000"
BR2_BINFMT_ELF=y
BR2_MIPS_CPU_MIPS32R5=y
# BR2_mips_32 is not set
# BR2_mips_32r2 is not set
# BR2_mips_32r3 is not set
# BR2_mips_32r5 is not set
# BR2_mips_32r6 is not set
# BR2_mips_interaptiv is not set
# BR2_mips_m5150 is not set
# BR2_mips_m6250 is not set
# BR2_mips_p5600 is not set
# BR2_mips_xburst is not set
BR2_mips_xburst2=y
# BR2_MIPS_SOFT_FLOAT is not set
# BR2_MIPS_FP32_MODE_32 is not set
# BR2_MIPS_FP32_MODE_XX is not set
BR2_MIPS_FP32_MODE_64=y
BR2_MIPS_NAN_2008=y
BR2_MIPS_OABI32=y

```

First of all, I was not able to select mender in buildroot-menuconfig because of

```auto
# Target go packages should depend on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
config BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
  bool
  default y
  depends on !BR2_TOOLCHAIN_HAS_BINUTILS_BUG_20006
  depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_ARCH_SUPPORTS
  depends on (BR2_arm && BR2_TOOLCHAIN_SUPPORTS_PIE) || BR2_aarch64 \
    || BR2_i386 || BR2_x86_64 || BR2_powerpc64le \
    || BR2_mips64 || BR2_mips64el

```

As 32bit MIPS should be supported by go (see [Go on ARM and Beyond - The Go Programming Language](https://go.dev/blog/ports)), I just added `BR2_mipsel` to the list. With that mender shows up as available package but it does not compile:

```auto
mips-linux-gnu-gcc: error: unrecognized command line option '-m64'

```

I updated the mender version to 3.4.0 with the same effect.

What can I try next?

**EDIT** :  
I got one step further by adding

```auto
else ifeq ($(BR2_mipsel),y)
GO_GOARCH = mipsle

```

to `go/go.mk`.

Now the build fails with

```auto
# runtime/cgo
cc1: error: the 'mips32' architecture does not support '-mnan=2008' [-Werror]
cc1: all warnings being treated as errors

```

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [November 15, 2022, 8:15pm UTC](https://hub.mender.io/t/compile-mender-for-mipsel-32bit-architecture/5387/2 "2022-11-15T20:15:46Z")

</div>

Hi @stwirth,

As I am no buildroot guy, I tried the same in Yocto and can share some findings, but no success (yet)

- the build seems to be progressing normally, no concerning the `-m64` compiler flag. I would guess therefore that this comes from some default `CFLAGS/CXXFLAGS` in buildroot.
- the `lmbd` binding/dependency falls over, in a part that seems to be ABI related go code.

So the takeaway probably is, the Mender client itself and the go toolchain are not the problem. But the whole ecosystem of go modules not being aware of anything else than x86 and ARM. ☹

Sorry I have no better news at the moment.

Greetz,  
Josef

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [November 15, 2022, 9:33pm UTC](https://hub.mender.io/t/compile-mender-for-mipsel-32bit-architecture/5387/3 "2022-11-15T21:33:59Z")

</div>

Howdy @stwirth,

at least some news. Yocto targetting `qemumips64` instead of `qemumips` builds nicely:

> ```auto
> Poky (Yocto Project Reference Distro) 4.0.5 qemumips64 /dev/ttyS0
> 
> qemumips64 login: root
> root@qemumips64:~# mender -v
> 3.4.0 runtime: go1.17.13
> 
> ```

In my understanding this confirms the guess that there are two problems to tackle.

1. the `lmbd` dependency not building for mips32
2. the compiler flag handling in buildroot

Hope this helps,  
Josef

---

<div class="post-metadata">

**Author:** ![stwirth](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/stwirth/32/1785_2.png) [@stwirth](https://hub.mender.io/u/stwirth)\
**Post date:** [November 16, 2022, 12:43pm UTC](https://hub.mender.io/t/compile-mender-for-mipsel-32bit-architecture/5387/4 "2022-11-16T12:43:22Z")

</div>

Thank you @TheYoctoJester for taking the time to try this out! I’ll try to find where these flags come from.
