Mender client cross compile for ARM - openssl dependency

Hello! I’m having trouble cross compiling mender client for ARM . When I try to compile mender for ARM from an AMD64 machine , I get the following error

mdb.c: In function ‘mdb_cursor_put’:
mdb.c:6535:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
      if (SIZELEFT(fp) < offset) {
         ^
mdb.c:6540:5: note: here
     case MDB_CURRENT:
     ^~~~
# github.com/mendersoftware/openssl
In file included from /usr/include/openssl/bio.h:13:0,
                 from ./shim.h:21,
                 from vendor/github.com/mendersoftware/openssl/bio.go:17:
/usr/include/openssl/e_os2.h:13:11: fatal error: openssl/opensslconf.h: No such file or directory
 # include <openssl/opensslconf.h>
           ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

The README in the mender client repository only talks about the liblzma dependency for cross compilation , is there any reference on how to do the same for openssl since libssl-dev is not multi arch compatible.

@oleorhagen any ideas here?

Hi @prashanthjbabu :slight_smile:

What do you mean libssl-dev is not multi-arch compatible?

We don’t have it in the README, but in essence it should be pretty much the same as regular compilation, you just have to remember to set your C compiler env.

See here

If this does not work for you, can you share the exact steps you are following?

Hi @oleorhagen ,

Here’s a reference for libssl-dev not being multi-arch compatible https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=689093 .

I haven’t yet made an attempt to cross compile openssl . I will try that out and get back to you.

1 Like

Hi @oleorhagen ,

Here are the steps i’ve followed ( taken from the README of mender client repo ) to cross compile for raspberry pi ( as mentioned as an example in the README )

git clone https://github.com/mendersoftware/mender.git
cd mender/
git clone https://github.com/raspberrypi/tools.git
export PATH="$PATH:$(pwd)/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin"
export CC=arm-linux-gnueabihf-gcc
GOARCH=arm make TAGS="nodbus nolzma"

I get the following error :

go build -ldflags "-X github.com/mendersoftware/mender/conf.Version=fbed1ef"  -tags 'nodbus nolzma'
# github.com/mendersoftware/openssl
In file included from /usr/include/openssl/bio.h:13:0,
                 from ./shim.h:21,
                 from vendor/github.com/mendersoftware/openssl/bio.go:17:
/usr/include/openssl/e_os2.h:13:11: fatal error: openssl/opensslconf.h: No such file or directory
 # include <openssl/opensslconf.h>
           ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:78: recipe for target 'build' failed
make: *** [build] Error 2

Are the steps wrong? I feel the README should be updated to include openssl cross compilation steps just like the liblzma steps , since you’ve recently introduced code changes under https://github.com/mendersoftware/mender/tree/master/vendor/github.com/mendersoftware/openssl which require this as a basic need for cross compilation to happen

You’ve probably got a point here, we can probably expand this. Once you get this working a PR would be hugely appreciated :slight_smile:

Ticket looks resolved to me.

This is the changelog:

   * Move <openssl/opensslconf.h> to /usr/include/$(DEB_HOST_MULTIARCH), and
     mark libssl-dev Multi-Arch: same.

And looking here, it looks like armhf is there. Also, the armhf file-list looks like it is architecture.

How did the openssl cross-compilation go?

hello @oleorhagen ,

I was able to successfully cross compile . Here’s a sample script which does everything

git clone https://github.com/mendersoftware/mender.git
cd mender/
git clone https://github.com/raspberrypi/tools.git
export PATH="$PATH:$(pwd)/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin"
export CC=arm-linux-gnueabihf-gcc
export CROSS=arm-linux-gnueabihf
wget -q https://www.openssl.org/source/openssl-1.1.1k.tar.gz
tar -xzf openssl-1.1.1k.tar.gz
cd openssl-1.1.1k
./Configure linux-armv4 --prefix=$(pwd)/install
make
make install
export LIBSSL_INSTALL_PATH=$(pwd)/install
cd ../
make CGO_CFLAGS="-I${LIBSSL_INSTALL_PATH}/include" CGO_LDFLAGS="-L${LIBSSL_INSTALL_PATH}/lib" CGO_ENABLED=1 GOOS=linux GOARCH=arm TAGS="nodbus nolzma"

I’ve also raised a PR to get this into README Add libssl cross compilation steps to README by prashanthjbabu · Pull Request #752 · mendersoftware/mender · GitHub

1 Like

Awesome @prashanthjbabu !

And thanks for the PR, it looks good!

1 Like