Cross Compiling of erlang/otp

I am cross compiling erlang/otp 23.1.3 for my embedded device which is configured correctly. but when make it . it gives “recipe for target ‘arm-poky-linux-gnueabi/erl_db_insert_list.ycf.h’ failed”.

make[4]: Leaving directory '/home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/erts/lib_src'
make[3]: Leaving directory '/home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/erts/lib_src'
 GEN	arm-poky-linux-gnueabi/erl_db_insert_list.ycf.h
/bin/sh: 1: /home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/erts/lib_src/yielding_c_fun/bin/arm-poky-linux-gnueabi/yielding_c_fun: Exec format error
arm-poky-linux-gnueabi/Makefile:642: recipe for target 'arm-poky-linux-gnueabi/erl_db_insert_list.ycf.h' failed
make[2]: *** [arm-poky-linux-gnueabi/erl_db_insert_list.ycf.h] Error 2
make[2]: Leaving directory '/home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/erts/emulator'
/home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/make/run_make.mk:42: recipe for target 'generate' failed
make[1]: *** [generate] Error 2
make[1]: Leaving directory '/home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/erts/emulator'
Makefile:533: recipe for target 'depend' failed
make: *** [depend] Error 2

For some reason the arm variant of ycf is invoked.

Could you share what arguments and environment variables you use when invoking configure and make?

You can also have a look here to see a working example of cross compilation.

configured By : ./otp_build configure --host=arm-poky-linux-gnueabi --prefix=/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/ --with-ssl=/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi --enable-dynamic-ssl-lib --without-javac --without-jinterface --without-odbc --without-wx

and
$ echo $CC
arm-poky-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi

$ echo $ARM_SYSROOT
/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi

Do you have a working Erlang/OTP installation in your PATH? i.e. built for the build environment.

yes

$ echo $PATH
/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/qt5:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/usr/bin:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/usr/sbin:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/bin:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/sbin:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/…/x86_64-pokysdk-linux/bin:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-uclibc:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-musl:/home/apaul/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

1 Like

and when Configure with
$ ./otp_build configure --target=arm-poky-linux-gnueabi --host=arm-poky-linux-gnueabi --prefix=/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/ --with-ssl=/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi --without-javac --without-jinterface --without-odbc --without-wx --enable-threads

then build root with
$ ./otp_build boot -a

Get errror as
“make[4]: Entering directory ‘/home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/erts/lib_src’
CC obj/x86_64-unknown-linux-gnu/opt/r/ethread.o
pthread/ethread.c: Assembler messages:
pthread/ethread.c:206: Error: invalid instruction suffix for pop' pthread/ethread.c:209: Error: invalid instruction suffix for push’
pthread/ethread.c:212: Error: invalid instruction suffix for pop' pthread/ethread.c:234: Error: invalid instruction suffix for push’
pthread/ethread.c:237: Error: invalid instruction suffix for `pop’
x86_64-unknown-linux-gnu/Makefile:433: recipe for target ‘obj/x86_64-unknown-linux-gnu/opt/r/ethread.o’ failed
make[4]: *** [obj/x86_64-unknown-linux-gnu/opt/r/ethread.o] Error 1
make[4]: Leaving directory ‘/home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/erts/lib_src’
/home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/make/run_make.mk:35: recipe for target ‘opt’ failed
make[3]: *** [opt] Error 2
make[3]: Leaving directory ‘/home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/erts/lib_src’
x86_64-unknown-linux-gnu/Makefile:465: recipe for target ‘/home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/erts/lib_src/obj/x86_64-unknown-linux-gnu/opt/MADE’ failed
make[2]: *** [/home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/erts/lib_src/obj/x86_64-unknown-linux-gnu/opt/MADE] Error 2
make[2]: Leaving directory ‘/home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/erts/emulator’
/home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/make/run_make.mk:42: recipe for target ‘generate’ failed
make[1]: *** [generate] Error 2
make[1]: Leaving directory ‘/home/apaul/Documents/RabbitMQ/otp-OTP-23.1.3/erts/emulator’
Makefile:533: recipe for target ‘depend’ failed
make: *** [depend] Error 2”

Set environment Details
$ echo $CC
arm-poky-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi

$ echo $PATH
/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/qt5:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/usr/bin:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/usr/sbin:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/bin:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/sbin:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/…/x86_64-pokysdk-linux/bin:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-uclibc:/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-musl:/home/apaul/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

$ echo $ARM_SYSROOT
/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi

Without being able to run the cross-compile myself, it is very hard to guess what is going on. Something is wrong in the setup of the cross-compile environment, what that is I don’t know.

but I am able to cross compile other github projects, in that case my CC settings environment is ok.

I got testing of cross compiled system without error by followed command
$ make release_tests
$ ./otp_build tests

but $ make failed.?
any other Cross Compile documents for erlang_otp?

Have you read this https://github.com/erlang/otp/blob/master/HOWTO/INSTALL-CROSS.md?

yes.
according to this configuration some application are going to disabled…
$ ./configure --target=arm-poky-linux-gnueabi --host=arm-poky-linux-gnueabi --prefix=/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/ --build=erts/autoconf/config.guess --with-ssl

output


********************** APPLICATIONS DISABLED **********************


crypto : Cannot search for ssl; missing cross system root (erl_xcomp_sysroot).
jinterface : No Java compiler found
odbc : ODBC library - header check failed
ssh : Cannot search for ssl; missing cross system root (erl_xcomp_sysroot).
ssl : Cannot search for ssl; missing cross system root (erl_xcomp_sysroot).

and all things to compile is good . but run at device
root@imx6qsabresd:~# erl
Erlang/OTP 23 [erts-11.1.3] [source] [smp:2:1] [ds:2:1:10] [async-threads:1]
Eshell V11.1.3 (abort with ^G)
1> ssl:versions().
** exception error: undefined function ssl:versions/0
2>

if i set as
$ ./configure --target=arm-poky-linux-gnueabi --host=arm-poky-linux-gnueabi --prefix=/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/ --with-ssl=/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi
then (ssh,ssl and crypto) are enabled by not make

Hello Anil,

Did you try this one: https://github.com/meta-erlang/meta-erlang ?

meta-erlang is layer for YP/OE.

Looks like you are using YP/OE as well. You can also check out this documentation: https://meta-erlang.github.io