frr icon indicating copy to clipboard operation
frr copied to clipboard

Cross compilation of FRR

Open nic1225 opened this issue 6 years ago • 30 comments

hi, I want to cross compile FRR in ubuntu 18.04 to run in arm64 environment device,are there any compilation instructions? Or how to configure the parameters of a ./configure

thanks Nick.

nic1225 avatar Sep 21 '20 09:09 nic1225

this pretty much worked for me on a RASPI4 - there was some jiggery-pokery getting the right packages installed but give me a shout on the slack channel if you hit issues. http://docs.frrouting.org/projects/dev-guide/en/latest/building-frr-for-ubuntu1804.html

pjdruddy avatar Sep 21 '20 09:09 pjdruddy

While we ostensibly support cjson, I have always used libjson-c, which has ARM packages prebuilt for most distros. It's very possible that compilation with cJSON is either broken, or that your source install did not install a corresponding pkg-config file, which is what automake is looking for when searching for json libraries.

qlyoung avatar Sep 21 '20 18:09 qlyoung

Back to the previous question, I use command ./configure --host=aarch64-linux-gnu, It is mentioned in the echo " builddir separate from srcdir or by building clippy separately",Is there any operation procedure related to it?

checking build system type... x86_64-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
configure: error: cross-compilation is only possible with builddir separate from srcdir or by building clippy separately and using the --with-clippy option.  create a separate directory and run as .../path-to-frr/configure.

And then when compiling in a new directory,as follow

root@nick-virtual-machine:/home/frr# cd build
root@nick-virtual-machine:/home/frr/build# ../configure --host=aarch64-linux-gnu
checking build system type... x86_64-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
configure: ...
configure: ... cross-compilation: creating hosttools directory and self-configuring for build platform tools
configure: ... use HOST_CPPFLAGS / HOST_CFLAGS / HOST_LDFLAGS if neccessary
configure: ...
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
configure: error: source directory already configured; run "make distclean" there first

The compiling platform is Ubuntu 18.04, and the host is armv8 64 bit system

thanks Nick.

nic1225 avatar Sep 22 '20 03:09 nic1225

@lucize The cross-compilation platform is Ubuntu 18.04, and the host is armv8(cortex-a53) 64 bit system, the issue is similar as reported in#2131, my configure like this

../configure \
--host="aarch64-linux-gnu" \
--build="x86_64-pc-linux-gnu" \
CFLAGS="-Os -g -mcpu=cortex-a53 -mfpu=neon -funroll-all-loops --param max-inline-insns-auto=550 -I/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/include -I/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/include/aarch64-linux-gnu" \
CXXFLAGS="-Os -g -mcpu=cortex-a53 -mfpu=neon -funroll-all-loops --param max-inline-insns-auto=550 -I/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/include -I/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/include/aarch64-linux-gnu" \
LDFLAGS="-L/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/local/lib -L$/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/lib/aarch64-linux-gnu -L/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/lib" \
HOST_CFLAGS="" \
HOST_LDFLAGS="" \
BUILD_CPPFLAGS="" \
BUILD_CFLAGS="-Os -g -mcpu=cortex-a53 -mfpu=neon -funroll-all-loops --param max-inline-insns-auto=550 -I/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/include -I/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/include/aarch64-linux-gnu" \
BUILD_LDFLAGS="-L/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/local/lib -L$/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/lib/aarch64-linux-gnu -L/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/lib" \
--prefix=/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main \
--localstatedir=/var/run/frr \
--sysconfdir=/etc/frr/ \
--enable-multipath=1 \
--with-pkg-extra-version=-ctyun \
--enable-sysrepo=yes \
--enable-user=frr \
--enable-group=frr \
--enable-vty-group=frrvty  \
--localstatedir=/var/run/frr \
--sysconfdir=/etc/frr/ 

error as follow

The above user and group must have read/write access to the state file
directory and to the config files in the config file directory.
configure: ...
configure: ... cross-compilation: finished self-configuring for build platform tools
configure: ...
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for aarch64-linux-gnu-strip... aarch64-linux-gnu-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for perl... /usr/bin/perl
checking for aarch64-linux-gnu-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
configure: WARNING: using cross tools not prefixed with host triplet
checking pkg-config is at least version 0.9.0... yes
checking for aarch64-linux-gnu-gcc... aarch64-linux-gnu-gcc
checking whether the C compiler works... no
configure: error: in `/home/nick/nxp/flexbuild/packages/apps/frr/build':
configure: error: C compiler cannot create executables
See `config.log' for more details

thanks Nick.

nic1225 avatar Sep 23 '20 11:09 nic1225

But did you find the exact error from config.log?

lucize avatar Sep 23 '20 15:09 lucize

hi,lucize.

Judging from the error message above, it is probably the compiler's fault

checking for aarch64-linux-gnu-gcc... aarch64-linux-gnu-gcc
checking whether the C compiler works... no
configure: error: in `/home/nick/nxp/flexbuild/packages/apps/frr/build':
configure: error: C compiler cannot create executables

I don't know what the problem is, I posted the log, please help to have a look config.log

In addition, I am not clear about whether the HOST_* parameter is necessary and how to fill it in. the environment variables we use are as follows

export CROSS=aarch64-linux-gnu-
export RTE_SDK=/home/nick/nxp/flexbuild/packages/apps/frr
export RTE_TARGET=arm64-dpaa-linuxapp-gcc
export LDFLAGS="-L/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/lib/aarch64-linux-gnu -L/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/lib -L$(RFSDIR)/usr/lib"
export CROSS_PREFIX=aarch64-linux-gnu
export CROSS_TOOLCHAIN=/usr
export CROSS_SYSROOT=/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main
export ARCH=arm64
export OPENSSL_PATH=/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr
export EXTRA_INC=/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/include/aarch64-linux-gnu
export EXTRA_LIBS=/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/lib/aarch64-linux-gnu
export LD_LIBRARY_PATH=$(DESTDIR)/usr/local/dpdk4vpp/lib:$(RFSDIR)/lib/aarch64-linux-gnu

thanks Nick.

nic1225 avatar Sep 24 '20 01:09 nic1225

this is a working rock64 configuration, maybe you can spot something here:

 zebra -v
zebra version 7.4
Copyright 1996-2005 Kunihiro Ishiguro, et al.
configured with:
 '--target=aarch64-openwrt-linux' '--host=aarch64-openwrt-linux' '--build=x86_64-pc-linux-gnu' '--program-prefix=' '--program-suffix='
 '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--libexecdir=/usr/lib' '--sysconfdir=/etc' '--datadir=/usr/share'
 '--localstatedir=/var' '--mandir=/usr/man' '--infodir=/usr/info' '--disable-nls' '--with-clippy=/home/build/staging/staging_dir/hostpkg/bin/clippy'
 '--prefix=/usr' '--enable-shared' '--disable-static' '--enable-user=network' '--enable-group=network' '--disable-ospfclient'
 '--disable-doc' '--disable-backtrace' '--localstatedir=/var/run/frr' '--sysconfdir=/etc/frr/' '--with-crypto=openssl' '--disable-babeld'
 '--disable-bfdd' '--enable-bgpd' '--enable-eigrpd' '--disable-fabricd' '--disable-isisd' '--disable-ldpd' '--enable-nhrpd' '--enable-ospfd'
 '--disable-ospf6d' '--disable-pbrd' '--disable-pimd' '--enable-ripd' '--disable-ripngd' '--enable-staticd' '--disable-vrrpd' '--enable-vtysh' '--enable-zebra'
 'build_alias=x86_64-pc-linux-gnu' 'host_alias=aarch64-openwrt-linux' 'target_alias=aarch64-openwrt-linux'
 'PKG_CONFIG=/home/build/staging/staging_dir/host/bin/pkg-config'
 'PKG_CONFIG_PATH=/home/build/staging/staging_dir/target-aarch64_generic_musl/usr/lib/pkgconfig:/home/build/staging/staging_dir/target-aarch64_generic_musl/usr/share/pkgconfig'
 'PKG_CONFIG_LIBDIR=/home/build/staging/staging_dir/target-aarch64_generic_musl/usr/lib/pkgconfig:/home/build/staging/staging_dir/target-aarch64_generic_musl/usr/share/pkgconfig'
 'CC=aarch64-openwrt-linux-musl-gcc'
 'CXX=aarch64-openwrt-linux-musl-g++'

but from your config file it seems that you are missing at least the --target option or build only clippy first, not in the cross compile stage and specify it like I did in the second stage

config for clippy only (for running on build system):

./configure --target=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --program-prefix= --program-suffix= --prefix=/home/build/staging/staging_dir/hostpkg --exec-prefix=/home/build/staging/staging_dir/hostpkg --sysconfdir=/home/build/staging/staging_dir/hostpkg/etc --localstatedir=/home/build/staging/staging_dir/hostpkg/var --sbindir=/home/build/staging/staging_dir/hostpkg/bin --enable-clippy-only

don't know exactly what variables are exported because I use Openwrt SDK in cross building it

lucize avatar Sep 24 '20 06:09 lucize

hi,lucize I don't quite understand what a means for cross compilation. I think the cross compilation process is as follows

./bootstrap.sh 
mkdir build; cd build/
../configure xxx
cd hosttools
make
make install

is that all?

thanks Nick

nic1225 avatar Sep 24 '20 07:09 nic1225

it can be like your example, but that is the mixed config setup you can split the build, I found it more clear like that first natively build with --enable-clippy-only then second if you specify --with-clippy= it seems you don't have to make a sub folder, again look at my configure argument for the cross compile stage

lucize avatar Sep 24 '20 07:09 lucize

Hi,

I also have a cross-compilation issue. I don't know if it's the same described here, but I'll try to describe the problem. My environment is adding a prefix to all main tools:

MACHINE = tilegx ARCH = tilegx CROSS_COMPILE = tile- CROSS = $(CROSS_COMPILE) CC = $(CROSS_COMPILE)gcc $(CPUCFLAGS) AS = $(CROSS_COMPILE)as $(CPUCFLAGS) CXX = $(CROSS_COMPILE)g++ $(CPUCFLAGS) AR = $(CROSS_COMPILE)ar LD = $(CROSS_COMPILE)ld $(CPULDFLAGS) OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump RANLIB = $(CROSS_COMPILE)ranlib STRIPTOOL = $(CROSS_COMPILE)strip STRIP = $(STRIPTOOL) READELF = $(CROSS_COMPILE)readelf

when I cross compile FRR, I face a mixed configuration when it's time to compile hosttools, because CC, LD, etc. are referring to the host machine instead of native one. So, my solution is to add following patch to configure.ac:

--- a/configure.ac +++ b/configure.ac @@ -25,6 +25,13 @@ AC_CANONICAL_BUILD() AC_CANONICAL_HOST()

+AC_ARG_VAR([AR],[archiver command]) +AC_ARG_VAR([LD],[linker command]) +AC_ARG_VAR([OBJCOPY],[objcopy command]) +AC_ARG_VAR([OBJDUMP],[objdump command]) +AC_ARG_VAR([RANLIB],[ranlib command]) +AC_ARG_VAR([STRIP],[strip command]) + hosttools_clippy="false" build_clippy="true"

and then add following variables to configure command line:

HOST_CC=gcc HOST_LD=ld HOST_AR=ar HOST_CXX=g++ HOST_OBJCOPY=objcopy HOST_OBJDUMP=objdump HOST_RANLIB=ranlib HOST_STRIP=strip

In this way hosttools configure correctly copies HOST_LD to LD, HOST_AR to AR, etc.. Before this change only HOST_CC was copied to CC, because it was the only one present in ac_precious_vars:

ac_precious_vars='build_alias host_alias target_alias PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP CXX CXXFLAGS CCC LUA LUA_INCLUDE LUA_LIB CXXCPP PYTHON_CFLAGS PYTHON_LIBS PYTHON PROTOBUF_C_CFLAGS PROTOBUF_C_LIBS CARES_CFLAGS CARES_LIBS LIBYANG_CFLAGS LIBYANG_LIBS SQLITE3_CFLAGS SQLITE3_LIBS SYSREPO_CFLAGS SYSREPO_LIBS GRPC_CFLAGS GRPC_LIBS ZEROMQ_CFLAGS ZEROMQ_LIBS RTRLIB_CFLAGS RTRLIB_LIBS YACC YFLAGS UNWIND_CFLAGS UNWIND_LIBS'

I hope that this can help and to have a feedback on my change. If it's the case I can push a patch. Thanks Ema

emabo avatar Sep 24 '20 08:09 emabo

hi @emabo

How do you set the configure parameter?

thanks Nick

nic1225 avatar Sep 24 '20 08:09 nic1225

in the configure command line:

configure --sysconfdir=/var/tmp/shells --localstatedir=/tmp --sbindir=/usr/local/6bin --bindir=/usr/local/6bin --libdir=/lib --host=tilegx-redhat-linux --build=x86_64-linux-gnu --srcdir=/home/emanu/ports/frr/src --enable-user=root --enable-group=root --enable-vtysh --enable-multipath=4 --enable-capabilities --disable-irdp --disable-rtadv --disable-doc --disable-ripd --disable-ripngd --disable-isisd --disable-pimd --disable-babeld --disable-ospfclient --disable-eigrpd --disable-nhrpd --disable-rr-semantics CFLAGS="-O2 -fomit-frame-pointer -Dlinux -Dlinux -Dunix -DEMBED LIBS="-l6whas -lxml2 -lxt -lm" HOST_CC=gcc HOST_LD=ld HOST_AR=ar HOST_CXX=g++ HOST_OBJCOPY=objcopy HOST_OBJDUMP=objdump HOST_RANLIB=ranlib HOST_STRIP=strip

Ema

emabo avatar Sep 24 '20 08:09 emabo

hi @emabo

I've added the following to line 28 of the configure.ac file

AC_ARG_VAR([AR],[archiver command])
AC_ARG_VAR([LD],[linker command])
AC_ARG_VAR([OBJCOPY],[objcopy command])
AC_ARG_VAR([OBJDUMP],[objdump command])
AC_ARG_VAR([RANLIB],[ranlib command])
AC_ARG_VAR([STRIP],[strip command])

Use the following configure parameter

../configure --host=aarch64-linux-gnu 	--build=x86_64-linux-gnu 	HOST_CC=aarch64-linux-gnu-gcc 	HOST_CXX=aarch64-linux-gnu-g++ 	HOST_AR=aarch64-linux-gnu-ar 	HOST_LD=aarch64-linux-gnu-ld     CFLAGS="-Os -g -mcpu=cortex-a53 -mfpu=neon -funroll-all-loops --param max-inline-insns-auto=550 -I/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/include -I/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/include/aarch64-linux-gnu"     LDFLAGS="-L/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/local/lib -L$/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/lib/aarch64-linux-gnu -L/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/lib"     --prefix=/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main     --localstatedir=/var/run/frr     --sysconfdir=/etc/frr/     --enable-multipath=1     --with-pkg-extra-version=-ctyun     --enable-sysrepo=yes 

Also try changing the a parameter to HOST_* to be the same as yours

HOST_CC=gcc 
HOST_LD=ld 
HOST_AR=ar 
HOST_CXX=g++ 
HOST_OBJCOPY=objcopy 
HOST_OBJDUMP=objdump 
HOST_RANLIB=ranlib 
HOST_STRIP=strip

Encountered the following log

The above user and group must have read/write access to the state file
directory and to the config files in the config file directory.
configure: ...
configure: ... cross-compilation: finished self-configuring for build platform tools
configure: ...
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for aarch64-linux-gnu-strip... aarch64-linux-gnu-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for perl... /usr/bin/perl
checking for aarch64-linux-gnu-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
configure: WARNING: using cross tools not prefixed with host triplet
checking pkg-config is at least version 0.9.0... yes
checking for aarch64-linux-gnu-gcc... aarch64-linux-gnu-gcc
checking whether the C compiler works... no
configure: error: in `/home/nick/nxp/flexbuild/packages/apps/frr/build':
configure: error: C compiler cannot create executables
See `config.log' for more details

In addition,Why is your cross-compiler gcc, not something like aarch64-linux-gnu-gcc, powerpc-fsl-linux-gcc and so on.

thanks Nick

nic1225 avatar Sep 24 '20 09:09 nic1225

I think it's a bit confusing, but from what I understood from configure.ac, HOST_xx contains the local tools and flags needed for building hosttools:

configure:2996: checking build system type configure:3010: result: x86_64-pc-linux-gnu configure:3030: checking host system type configure:3043: result: tilegx-redhat-linux-gnu configure:3085: ... configure:3087: ... cross-compilation: creating hosttools directory and self-configuring for build platform tools configure:3089: ... use HOST_CPPFLAGS / HOST_CFLAGS / HOST_LDFLAGS if neccessary configure:3091: ... configure:3111: host unset build_alias configure:3111: host unset host_alias configure:3111: host unset target_alias configure:3111: host unset PKG_CONFIG configure:3111: host unset PKG_CONFIG_PATH configure:3111: host unset PKG_CONFIG_LIBDIR configure:3106: host CC='gcc' configure:3111: host unset CFLAGS configure:3111: host unset LDFLAGS configure:3111: host unset LIBS configure:3111: host unset CPPFLAGS configure:3111: host unset CPP configure:3111: host unset CXX

so, in my case CC=tile-gcc while HOST_CC=gcc. If you already tried this option, I think you have a different problem in your configuration. Probably, in my case I should have to open a new issue.

emabo avatar Sep 24 '20 10:09 emabo

I again ask, did you tried with adding also --target?

and some output variables:

It was created by frr configure 7.4, which was generated by GNU Autoconf 2.69. Invocation command line was

$ ./configure --target=aarch64-openwrt-linux --host=aarch64-openwrt-linux --build=x86_64-pc-linux-gnu --program-prefix= --program-suffix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls --with-clippy=/home/build/staging/staging_dir/hostpkg/bin/clippy --prefix=/usr --enable-shared --disable-static --enable-user=network --enable-group=network --disable-ospfclient --disable-doc --disable-backtrace --localstatedir=/var/run/frr --sysconfdir=/etc/frr/ --with-crypto=openssl --disable-babeld --disable-bfdd --enable-bgpd --enable-eigrpd --disable-fabricd --disable-isisd --disable-ldpd --enable-nhrpd --enable-ospfd --disable-ospf6d --disable-pbrd --disable-pimd --enable-ripd --disable-ripngd --enable-staticd --disable-vrrpd --enable-vtysh --enable-zebra

Output variables.

AR='aarch64-openwrt-linux-musl-gcc-ar'
CC='aarch64-openwrt-linux-musl-gcc -std=gnu11'
CFLAGS='-Os -pipe -mcpu=generic -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/build/staging/build_dir/target-aarch64_generic_musl/frr-frr-7.4=frr-frr-7.4 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -flto  -fno-omit-frame-pointer -funwind-tables -Wall -Wextra -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wundef -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers '
CLIPPY='/home/build/staging/staging_dir/hostpkg/bin/clippy'
CONFIG_ARGS=''\''--target=aarch64-openwrt-linux'\'' '\''--host=aarch64-openwrt-linux'\'' '\''--build=x86_64-pc-linux-gnu'\'' '\''--program-prefix='\'' '\''--program-suffix='\'' '\''--exec-prefix=/usr'\'' '\''--bindir=/usr/bin'\'' '\''--sbindir=/usr/sbin'\'' '\''--libexecdir=/usr/lib'\'' '\''--sysconfdir=/etc'\'' '\''--datadir=/usr/share'\'' '\''--localstatedir=/var'\'' '\''--mandir=/usr/man'\'' '\''--infodir=/usr/info'\'' '\''--disable-nls'\'' '\''--with-clippy=/home/build/staging/staging_dir/hostpkg/bin/clippy'\'' '\''--prefix=/usr'\'' '\''--enable-shared'\'' '\''--disable-static'\'' '\''--enable-user=network'\'' '\''--enable-group=network'\'' '\''--disable-ospfclient'\'' '\''--disable-doc'\'' '\''--disable-backtrace'\'' '\''--localstatedir=/var/run/frr'\'' '\''--sysconfdir=/etc/frr/'\'' '\''--with-crypto=openssl'\'' '\''--disable-babeld'\'' '\''--disable-bfdd'\'' '\''--enable-bgpd'\'' '\''--enable-eigrpd'\'' '\''--disable-fabricd'\'' '\''--disable-isisd'\'' '\''--disable-ldpd'\'' '\''--enable-nhrpd'\'' '\''--enable-ospfd'\'' '\''--disable-ospf6d'\'' '\''--disable-pbrd'\'' '\''--disable-pimd'\'' '\''--enable-ripd'\'' '\''--disable-ripngd'\'' '\''--enable-staticd'\'' '\''--disable-vrrpd'\'' '\''--enable-vtysh'\'' '\''--enable-zebra'\'' '\''build_alias=x86_64-pc-linux-gnu'\'' '\''host_alias=aarch64-openwrt-linux'\'' '\''target_alias=aarch64-openwrt-linux'\'' '\''PKG_CONFIG=/home/build/staging/staging_dir/host/bin/pkg-config'\'' '\''PKG_CONFIG_PATH=/home/build/staging/staging_dir/target-aarch64_generic_musl/usr/lib/pkgconfig:/home/build/staging/staging_dir/target-aarch64_generic_musl/usr/share/pkgconfig'\'' '\''PKG_CONFIG_LIBDIR=/home/build/staging/staging_dir/target-aarch64_generic_musl/usr/lib/pkgconfig:/home/build/staging/staging_dir/target-aarch64_generic_musl/usr/share/pkgconfig'\'' '\''CC=aarch64-openwrt-linux-musl-gcc'\'' '\''CXX=aarch64-openwrt-linux-musl-g++'\'''
CPP='aarch64-openwrt-linux-musl-gcc -E'
CPPFLAGS='-I/home/build/staging/staging_dir/target-aarch64_generic_musl/usr/include -I/home/build/staging/staging_dir/toolchain-aarch64_generic_gcc-8.4.0_musl/usr/include -I/home/build/staging/staging_dir/toolchain-aarch64_generic_gcc-8.4.0_musl/include/fortify -I/home/build/staging/staging_dir/toolchain-aarch64_generic_gcc-8.4.0_musl/include '
CXX='aarch64-openwrt-linux-musl-g++'
CXXCPP='aarch64-openwrt-linux-musl-g++ -E'
CXXFLAGS='-Os -pipe -mcpu=generic -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/build/staging/build_dir/target-aarch64_generic_musl/frr-frr-7.4=frr-frr-7.4 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -flto '

LD='aarch64-openwrt-linux-musl-ld'
LDFLAGS='-L/home/build/staging/staging_dir/target-aarch64_generic_musl/usr/lib -L/home/build/staging/staging_dir/target-aarch64_generic_musl/lib -L/home/build/staging/staging_dir/toolchain-aarch64_generic_gcc-8.4.0_musl/usr/lib -L/home/build/staging/staging_dir/toolchain-aarch64_generic_gcc-8.4.0_musl/lib -znow -zrelro -Wl,--gc-sections,--as-needed -latomic '
LIBS='-lresolv -lcrypt   -lcrypto -ljson-c -lrt'
NM='aarch64-openwrt-linux-musl-gcc-nm'
OBJCOPY='aarch64-openwrt-linux-musl-objcopy'
OBJDUMP='aarch64-openwrt-linux-musl-objdump'
PTHREAD_CC='aarch64-openwrt-linux-musl-gcc -std=gnu11'
RANLIB='aarch64-openwrt-linux-musl-gcc-ranlib -D'
STRIP='aarch64-openwrt-linux-musl-strip'
target_alias='aarch64-openwrt-linux'

lucize avatar Sep 24 '20 11:09 lucize

hi,lucize

Sorry for the late recovery, I just tried it, the problem remains the same

../configure --host=aarch64-linux-gnu --build=x86_64-linux-gnu --target=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ AR=aarch64-linux-gnu-ar LD=aarch64-linux-gnu-ld HOST_CC=gcc HOST_LD=ld HOST_AR=ar HOST_CXX=g++ HOST_OBJCOPY=objcopy HOST_OBJDUMP=objdump HOST_RANLIB=ranlib HOST_STRIP=strip CFLAGS="-Os -g -mcpu=cortex-a53 -mfpu=neon -funroll-all-loops --param max-inline-insns-auto=550 -I/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/include -I/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/include/aarch64-linux-gnu" LDFLAGS="-L/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/local/lib -L$/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/lib/aarch64-linux-gnu -L/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/lib" HOST_CFLAGS="" HOST_LDFLAGS="" BUILD_CPPFLAGS="" --prefix=/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main --localstatedir=/var/run/frr --sysconfdir=/etc/frr/ --enable-multipath=1 --with-pkg-extra-version=-ctyun --enable-sysrepo=yes --enable-user=frr --enable-group=frr --enable-vty-group=frrvty --localstatedir=/var/run/frr --sysconfdir=/etc/frr/

FRRouting configuration
------------------------------
FRR version             : 7.3
host operating system   : linux-gnu
source code location    : /home/nick/nxp/flexbuild/packages/apps/frr
compiler                : gcc -std=gnu11
compiler flags          :  -g -O2 -fno-omit-frame-pointer -funwind-tables -Wall -Wextra -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -pthread 
make                    : make
linker flags            :     -lrt -lcap  
state file directory    : /var/run
config file directory   : /usr/local/etc
example directory       : /usr/local/etc
module directory        : /usr/local/lib/frr/modules
user to run as          : frr
group to run as         : frr
group for vty sockets   : 
config file mask        : 0600
log file mask           : 0600
zebra protobuf enabled  : no

The above user and group must have read/write access to the state file
directory and to the config files in the config file directory.
configure: ...
configure: ... cross-compilation: finished self-configuring for build platform tools
configure: ...
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for aarch64-linux-gnu-strip... aarch64-linux-gnu-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for perl... /usr/bin/perl
checking for aarch64-linux-gnu-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
configure: WARNING: using cross tools not prefixed with host triplet
checking pkg-config is at least version 0.9.0... yes
checking for aarch64-linux-gnu-gcc... aarch64-linux-gnu-gcc
checking whether the C compiler works... no
configure: error: in `/home/nick/nxp/flexbuild/packages/apps/frr/build':
configure: error: C compiler cannot create executables

thanks Nick

nic1225 avatar Sep 24 '20 11:09 nic1225

@nic1225 please try first native build of clippy only and then specify the clippy path and let's see

lucize avatar Sep 24 '20 11:09 lucize

also look at specific variables aarch64-* that you didn't defined in the config

lucize avatar Sep 24 '20 11:09 lucize

I understand the steps are as follows first, build clippy only ./configure --target=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --enable-clippy-only

FRRouting configuration
------------------------------
FRR version             : 7.3
host operating system   : linux-gnu
source code location    : .
compiler                : gcc -std=gnu11
compiler flags          :  -g -O2 -fno-omit-frame-pointer -funwind-tables -Wall -Wextra -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -pthread 
make                    : make
linker flags            :     -lrt -lcap  
state file directory    : /var/run
config file directory   : /usr/local/etc
example directory       : /usr/local/etc
module directory        : /usr/local/lib/frr/modules
user to run as          : frr
group to run as         : frr
group for vty sockets   : 
config file mask        : 0600
log file mask           : 0600
zebra protobuf enabled  : no

The above user and group must have read/write access to the state file
directory and to the config files in the config file directory.

and then, cross-compilation with clippy path

./configure --target=aarch64-linux-gnu --host=aarch64-linux-gnu --build=x86_64-linux-gnu CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ AR=aarch64-linux-gnu-ar LD=aarch64-linux-gnu-ld CFLAGS="-Os -g -mcpu=cortex-a53 -mfpu=neon -funroll-all-loops --param max-inline-insns-auto=550 -I/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/include -I/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/include/aarch64-linux-gnu" LDFLAGS="-L/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/local/lib -L$/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/lib/aarch64-linux-gnu -L/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main/usr/lib" --prefix=/home/nick/nxp/flexbuild/build/rfs/rootfs_lsdk1909_LS_arm64_main --localstatedir=/var/run/frr --sysconfdir=/etc/frr/ --enable-multipath=1 --with-pkg-extra-version=-ctyun --enable-sysrepo=yes --enable-user=frr --enable-group=frr --enable-vty-group=frrvty --localstatedir=/var/run/frr --sysconfdir=/etc/frr/ --with-clippy=./build

log as follow:

checking build system type... x86_64-pc-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for aarch64-linux-gnu-strip... aarch64-linux-gnu-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for perl... /usr/bin/perl
checking for aarch64-linux-gnu-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
configure: WARNING: using cross tools not prefixed with host triplet
checking pkg-config is at least version 0.9.0... yes
checking for aarch64-linux-gnu-gcc... aarch64-linux-gnu-gcc
checking whether the C compiler works... no
configure: error: in `/home/nick/nxp/flexbuild/packages/apps/frr':
configure: error: C compiler cannot create executables
See `config.log' for more details

thanks Nick

nic1225 avatar Sep 24 '20 11:09 nic1225

./configure --enable-clippy-only make (build), it will take a while because configure.ac builds everything even if clippy-only is selected .. then cross compile, your cflags are not ok, if you look at my output variables the includes are added to cppflags and clippy path is the full path to the bin object here is a paste with all variables added before ./configure


 AR="aarch64-openwrt-linux-musl-gcc-ar" AS="aarch64-openwrt-linux-musl-gcc -c -Os -pipe -mcpu=generic -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/build/staging/build_dir/target-aarch64_generic_musl/frr-frr-7.4=frr-frr-7.4 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -flto" LD=aarch64-openwrt-linux-musl-ld NM="aarch64-openwrt-linux-musl-gcc-nm" CC="aarch64-openwrt-linux-musl-gcc" GCC="aarch64-openwrt-linux-musl-gcc" CXX="aarch64-openwrt-linux-musl-g++" RANLIB="aarch64-openwrt-linux-musl-gcc-ranlib" STRIP=aarch64-openwrt-linux-musl-strip OBJCOPY=aarch64-openwrt-linux-musl-objcopy OBJDUMP=aarch64-openwrt-linux-musl-objdump SIZE=aarch64-openwrt-linux-musl-size CFLAGS="-Os -pipe -mcpu=generic -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/build/staging/build_dir/target-aarch64_generic_musl/frr-frr-7.4=frr-frr-7.4 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -flto " CXXFLAGS="-Os -pipe -mcpu=generic -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/build/staging/build_dir/target-aarch64_generic_musl/frr-frr-7.4=frr-frr-7.4 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -flto " CPPFLAGS="-I/home/build/staging/staging_dir/target-aarch64_generic_musl/usr/include -I/home/build/staging/staging_dir/toolchain-aarch64_generic_gcc-8.4.0_musl/usr/include -I/home/build/staging/staging_dir/toolchain-aarch64_generic_gcc-8.4.0_musl/include/fortify -I/home/build/staging/staging_dir/toolchain-aarch64_generic_gcc-8.4.0_musl/include " LDFLAGS="-L/home/build/staging/staging_dir/target-aarch64_generic_musl/usr/lib -L/home/build/staging/staging_dir/target-aarch64_generic_musl/lib -L/home/build/staging/staging_dir/toolchain-aarch64_generic_gcc-8.4.0_musl/usr/lib -L/home/build/staging/staging_dir/toolchain-aarch64_generic_gcc-8.4.0_musl/lib -znow -zrelro -Wl,--gc-sections,--as-needed -latomic "   ./configure --target=aarch64-openwrt-linux --host=aarch64-openwrt-linux --build=x86_64-pc-linux-gnu (and the rest options)


checking build system type... x86_64-pc-linux-gnu
checking host system type... aarch64-openwrt-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for aarch64-openwrt-linux-strip... aarch64-openwrt-linux-musl-strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for perl... /home/build/staging/staging_dir/host/bin/perl
checking pkg-config is at least version 0.9.0... yes
checking for aarch64-openwrt-linux-gcc... aarch64-openwrt-linux-musl-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
...

FRRouting configuration
------------------------------
FRR version             : 7.4
host operating system   : linux-gnu
source code location    : .
compiler                : aarch64-openwrt-linux-musl-gcc -std=gnu11
compiler flags          : -Os -pipe -mcpu=generic -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/build/staging/build_dir/target-aarch64_generic_musl/frr-frr-7.4=frr-frr-7.4 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -flto  -fno-omit-frame-pointer -funwind-tables -Wall -Wextra -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wundef -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers
make                    : make
linker flags            : -L/home/build/staging/staging_dir/target-aarch64_generic_musl/usr/lib -L/home/build/staging/staging_dir/target-aarch64_generic_musl/lib -L/home/build/staging/staging_dir/toolchain-aarch64_generic_gcc-8.4.0_musl/usr/lib -L/home/build/staging/staging_dir/toolchain-aarch64_generic_gcc-8.4.0_musl/lib -znow -zrelro -Wl,--gc-sections,--as-needed -latomic   -lresolv -lcrypt   -lcrypto -ljson-c -lrt -lcap -lreadline
state file directory    : /var/run/frr
config file directory   : /etc/frr
example directory       : /etc/frr
module directory        : /usr/lib/frr/modules
user to run as          : network
group to run as         : network
group for vty sockets   :
config file mask        : 0600
log file mask           : 0600

lucize avatar Sep 24 '20 12:09 lucize