Compile Mender for `mipsel` (32bit) architecture

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:

# 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

# 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), I just added BR2_mipsel to the list. With that mender shows up as available package but it does not compile:

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

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

to go/go.mk.

Now the build fails with

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

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. :frowning:

Sorry I have no better news at the moment.

Greetz,
Josef

Howdy @stwirth,

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

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

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