From eea98c65338d8ebe8c3f50556aa437c07134673b Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Sat, 5 Dec 2020 12:37:01 +0100 Subject: [PATCH 1/2] kamailio-5.x: fix erlang build The Erlang module build checks for libs and includes using the erl tool. This is a hostpkg tool providing paths into the staging/hostpkg. Of course this fails: arc-openwrt-linux-uclibc-gcc -shared -Wl,-O2 -Wl,-E -L/builder/shared-workdir/build/sdk/staging_dir/toolchain-arc_arc700_gcc-8.4.0_uClibc/usr/lib -L/builder/shared-workdir/build/sdk/staging_dir/toolchain-arc_arc700_gcc-8.4.0_uClibc/lib -L/builder/shared-workdir/build/sdk/staging_dir/target-arc_arc700_uClibc/usr/lib/libiconv-stub/lib -Wl,-rpath-link=/builder/shared-workdir/build/sdk/staging_dir/target-arc_arc700_uClibc/usr/lib/libiconv-stub/lib -L/builder/shared-workdir/build/sdk/staging_dir/target-arc_arc700_uClibc/usr/lib/libintl-stub/lib -Wl,-rpath-link=/builder/shared-workdir/build/sdk/staging_dir/target-arc_arc700_uClibc/usr/lib/libintl-stub/lib -znow -zrelro -pthread -rdynamic "-ldl" -Wl,-Bsymbolic-functions handle_emsg.o pv_xbuff.o cnode.o erl_api.o epmd.o erl_helpers.o pv_ref.o pv_pid.o pv_atom.o worker.o handle_rpc.o pv_list.o pv_tuple.o erlang_mod.o -L/builder/shared-workdir/build/sdk/staging_dir/hostpkg/lib/erlang/lib/erl_interface-4.0/lib -lei -lpthread -o erlang.so /builder/shared-workdir/build/sdk/staging_dir/toolchain-arc_arc700_gcc-8.4.0_uClibc/bin/../lib/gcc/arc-openwrt-linux-uclibc/8.4.0/../../../../arc-openwrt-linux-uclibc/bin/ld: /builder/shared-workdir/build/sdk/staging_dir/hostpkg/lib/erlang/lib/erl_interface-4.0/lib/libei.a: error adding symbols: file format not recognized collect2: error: ld returned 1 exit status ../../Makefile.rules:191: recipe for target 'erlang.so' failed make[6]: *** [erlang.so] Error 1 This patch prevents this by relying on the standard paths, where Erlang resides in OpenWrt. Signed-off-by: Sebastian Kemper --- .../patches/150-erlang-fix-flags.patch | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 net/kamailio-5.x/patches/150-erlang-fix-flags.patch diff --git a/net/kamailio-5.x/patches/150-erlang-fix-flags.patch b/net/kamailio-5.x/patches/150-erlang-fix-flags.patch new file mode 100644 index 0000000..60ab4f2 --- /dev/null +++ b/net/kamailio-5.x/patches/150-erlang-fix-flags.patch @@ -0,0 +1,30 @@ +--- a/src/modules/erlang/Makefile ++++ b/src/modules/erlang/Makefile +@@ -5,20 +5,21 @@ include ../../Makefile.defs + auto_gen= + NAME=erlang.so + +-ERLANG=$(shell which erl) ++# In OpenWrt Erlang resides in standard locations, no special flags required ++#ERLANG=$(shell which erl) + + ifneq ($(ERLANG),) + ERLANG_LIBDIR=$(shell $(ERLANG) -noshell -eval 'io:format("~n~s/lib~n", [[code:lib_dir("erl_interface")]]).' -s erlang halt | tail -n 1) + ERLANG_INCDIR=$(shell $(ERLANG) -noshell -eval 'io:format("~n~s/include~n", [[code:lib_dir("erl_interface")]]).' -s erlang halt | tail -n 1) + endif + +-ifeq ($(ERLANG_LIBDIR)$(ERLANG_INCDIR),) +-$(error Not found Erlang) +-endif ++#ifeq ($(ERLANG_LIBDIR)$(ERLANG_INCDIR),) ++#$(error Not found Erlang) ++#endif + +-LIBS=-L$(ERLANG_LIBDIR) -lei -lpthread ++LIBS=-lei -lpthread + +-DEFS+=-I$(ERLANG_INCDIR) ++#DEFS+=-I$(ERLANG_INCDIR) + DEFS+=-D_REENTRANT + + From 060e779993b853a584d91af26c3ce24c7ef84854 Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Sat, 5 Dec 2020 12:42:20 +0100 Subject: [PATCH 2/2] kamailio-5.x: fix build for new MIPS 4kec target Recently support for target rtl838x was added to OpenWrt. It uses 4kec, which is MIPS32. The Kamailio build system doesn't detect this and treats it as MIPS I, adding -march=r3000 to the flags, which clashes with -mips32r2. mips-openwrt-linux-musl-gcc -mfp32 -march=r3000 -ftree-vectorize -fno-strict-overflow -pthread -DKSR_PTHREAD_MUTEX_SHARED -Wall -Os -pipe -mno-branch-likely -mips32r2 -mtune=4kec -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -I/builder/shared-workdir/build/sdk/staging_dir/target-mips_4kec_musl/usr/lib/libiconv-stub/include -I/builder/shared-workdir/build/sdk/staging_dir/target-mips_4kec_musl/usr/lib/libintl-stub/include -ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-mips_4kec_musl/kamailio5-5.4.0=kamailio5-5.4.0 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -DVERSION_NODATE=1 -I/builder/shared-workdir/build/sdk/staging_dir/target-mips_4kec_musl/usr/include -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-mips_4kec_gcc-8.4.0_musl/usr/include -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-mips_4kec_gcc-8.4.0_musl/include/fortify -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-mips_4kec_gcc-8.4.0_musl/include -I/builder/shared-workdir/build/sdk/staging_dir/target-mips_4kec_musl/usr/lib/libiconv-stub/include -I/builder/shared-workdir/build/sdk/staging_dir/target-mips_4kec_musl/usr/lib/libintl-stub/include -DNAME='"kamailio"' -DVERSION='"5.4.0"' -DARCH='"mips"' -DOS='linux_' -DOS_QUOTED='"linux"' -DCOMPILER='"mips-openwrt-linux-musl-gcc 8.4.0"' -D__CPU_mips -D__OS_linux -DVERSIONVAL=5004000 -DCFG_DIR='"/etc/kamailio"' -DSHARE_DIR='"/usr/share/kamailio/"' -DRUN_DIR='"/var/run/kamailio/"' -DPKG_MALLOC -DSHM_MMAP -DDNS_IP_HACK -DUSE_MCAST -DUSE_TCP -DDISABLE_NAGLE -DHAVE_RESOLV_RES -DUSE_DNS_CACHE -DUSE_DNS_FAILOVER -DUSE_DST_BLACKLIST -DUSE_NAPTR -DWITH_XAVP -DMEM_JOIN_FREE -DF_MALLOC -DQ_MALLOC -DTLSF_MALLOC -DDBG_SR_MEMORY -DUSE_TLS -DTLS_HOOKS -DUSE_CORE_STATS -DSTATISTICS -DMALLOC_STATS -DUSE_SCTP -DMIPS_HAS_LLSC -DNOSMP -DCC_GCC_LIKE_ASM -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER -DHAVE_IP_MREQN -DUSE_RAW_SOCKS -DUSE_PTHREAD_MUTEX -DHAVE_EPOLL -DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND -DUSE_FUTEX -DHAVE_SELECT -DMODS_DIR='"/usr/lib/kamailio/modules"' -c main.c -o main.o -MMD -MP cc1: error: '-mips32r2' conflicts with the other architecture options, which specify a mips1 processor Assembler messages: Error: -mips32r2 conflicts with the other architecture options, which imply -mips1 Makefile.rules:100: recipe for target 'main.o' failed make[5]: *** [main.o] Error 1 This commit fixes this by forcing ARCH to mips2 for 4kec CPUs as well (Kamailio only differentiates between mips, mips2 and mips64). Signed-off-by: Sebastian Kemper --- net/kamailio-5.x/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/kamailio-5.x/Makefile b/net/kamailio-5.x/Makefile index 90b0c92..fbc16c2 100644 --- a/net/kamailio-5.x/Makefile +++ b/net/kamailio-5.x/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=kamailio5 PKG_VERSION:=5.4.0 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE_URL:=https://www.kamailio.org/pub/kamailio/$(PKG_VERSION)/src PKG_SOURCE:=kamailio-$(PKG_VERSION)$(PKG_VARIANT)_src.tar.gz @@ -407,7 +407,7 @@ EXTRA_MODULES:= \ # When CONFIG_CPU_TYPE matches one of the identifiers in the list below, set # ARCH to "mips2" to get FAST_LOCK support. ifeq ($(call qstrip,$(CONFIG_ARCH)),mips) -CPU_MIPS2:=mips32 24kc 34kc 74kc +CPU_MIPS2:=mips32 24kc 34kc 4kec 74kc endif MAKE_FLAGS += \