Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/42308?usp=email )
Change subject: sane embedded builds without host talloc ......................................................................
sane embedded builds without host talloc
So far host talloc was always required. This fixes this up to only build a subset of stuff that actually works for embedded targets while using the pseudotalloc header file, and the actual firmware can supply its own talloc, without involving some random build system supplied talloc headers.
Unfortunately static symbols can't really be weak, so just going for always-on weak pseudotalloc does not work.
Change-Id: Ibb309a01ac6cad827b33ac18be408be1ac2cf7e0 --- M configure.ac M libosmocore.pc.in M src/Makefile.am M src/core/Makefile.am M src/core/backtrace.c M src/core/panic.c 6 files changed, 55 insertions(+), 25 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/08/42308/1
diff --git a/configure.ac b/configure.ac index b5f858f..3eaf0ad 100644 --- a/configure.ac +++ b/configure.ac @@ -217,8 +217,6 @@ dnl Don't require a newer version than 3.4, we build poky 201705 on debian 8 AM_PATH_PYTHON([3.4])
-PKG_CHECK_MODULES(TALLOC, [talloc >= 2.1.0]) - ENABLE_URING_DEFAULT="yes" ENABLE_PCSC_DEFAULT="yes" ENABLE_LIBUSB_DEFAULT="yes" @@ -503,6 +501,19 @@ AC_DEFINE([ENABLE_PSEUDOTALLOC], [1], [Enable building pseudotalloc library]) ])
+dnl In embedded mode, talloc is provided externally (e.g. by the firmware project) +dnl or via pseudotalloc. Only check for system talloc in non-embedded, non-pseudotalloc builds. +AS_IF([test "x$enable_pseudotalloc" != "xyes" && test "x$embedded" != "xyes"], [ + PKG_CHECK_MODULES(TALLOC, [talloc >= 2.1.0]) + AC_SUBST(TALLOC_PC, [talloc]) +], [ + TALLOC_CFLAGS="" + TALLOC_LIBS="" + AC_SUBST(TALLOC_PC, []) +]) +AC_SUBST(TALLOC_CFLAGS) +AC_SUBST(TALLOC_LIBS) + AC_ARG_ENABLE(log_macros, [AS_HELP_STRING( [--disable-log-macros], diff --git a/libosmocore.pc.in b/libosmocore.pc.in index 6479221..d2928fd 100644 --- a/libosmocore.pc.in +++ b/libosmocore.pc.in @@ -6,7 +6,7 @@ Name: Osmocom Core Library Description: C Utility Library Version: @VERSION@ -Requires: talloc @LIBMNL_PC@ +Requires: @TALLOC_PC@ @LIBMNL_PC@ Requires.private: @LIBSCTP_PC@ Libs: -L${libdir} -losmocore Libs.private: @PTHREAD_LIBS@ @LIBSCTP_LIBS@ diff --git a/src/Makefile.am b/src/Makefile.am index 8606646..57e897f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,10 @@ SUBDIRS = \ core \ + pseudotalloc \ + $(NULL) + +if !EMBEDDED +SUBDIRS += \ vty \ isdn \ codec \ @@ -7,7 +12,7 @@ coding \ gb \ ctrl \ - pseudotalloc \ sim \ usb \ - $(NULL) \ No newline at end of file + $(NULL) +endif \ No newline at end of file diff --git a/src/core/Makefile.am b/src/core/Makefile.am index b89cb70..bfe3050 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -8,6 +8,10 @@
if ENABLE_PSEUDOTALLOC AM_CPPFLAGS += -I$(top_srcdir)/src/pseudotalloc +else +if EMBEDDED +AM_CPPFLAGS += -I$(top_srcdir)/src/pseudotalloc +endif endif
lib_LTLIBRARIES = libosmocore.la @@ -22,44 +26,54 @@ $(NULL)
libosmocore_la_SOURCES = \ - application.c \ backtrace.c \ base64.c \ bits.c \ - bitvec.c \ bitcomp.c \ - context.c \ conv.c \ conv_acc.c \ conv_acc_generic.c \ - counter.c \ crc16.c \ crc8gen.c \ crc16gen.c \ crc32gen.c \ crc64gen.c \ - exec.c \ fsm.c \ - gsmtap_util.c \ isdnhdlc.c \ - it_q.c \ logging.c \ + loggingrb.c \ + msgb.c \ + panic.c \ + prbs.c \ + rbtree.c \ + sercomm.c \ + tdef.c \ + timer.c \ + timer_gettimeofday.c \ + timer_clockgettime.c \ + utils.c \ + probes.d \ + $(NULL) + +if !EMBEDDED +libosmocore_la_SOURCES += \ + application.c \ + bitvec.c \ + context.c \ + counter.c \ + exec.c \ + gsmtap_util.c \ + it_q.c \ logging_file.c \ logging_gsmtap.c \ - loggingrb.c \ macaddr.c \ - msgb.c \ netdev.c \ netns.c \ osmo_io.c \ osmo_io_poll.c \ - panic.c \ - prbs.c \ prim.c \ rate_ctr.c \ - rbtree.c \ select.c \ - sercomm.c \ signal.c \ sockaddr_str.c \ socket.c \ @@ -69,18 +83,13 @@ stats_statsd.c \ stats_tcp.c \ strrb.c \ - tdef.c \ thread.c \ time_cc.c \ - timer.c \ - timer_gettimeofday.c \ - timer_clockgettime.c \ tun.c \ use_count.c \ - utils.c \ write_queue.c \ - probes.d \ $(NULL) +endif
if HAVE_EMSCRIPTEN libosmocore_la_SOURCES += logging_emscripten.c diff --git a/src/core/backtrace.c b/src/core/backtrace.c index 60bd238..5930cb7 100644 --- a/src/core/backtrace.c +++ b/src/core/backtrace.c @@ -22,9 +22,9 @@
#include <stdio.h> #include <stdlib.h> +#include "config.h" #include <osmocom/core/utils.h> #include <osmocom/core/logging.h> -#include "config.h"
#ifdef HAVE_EXECINFO_H #include <execinfo.h> diff --git a/src/core/panic.c b/src/core/panic.c index bbf6d08..f8efd00 100644 --- a/src/core/panic.c +++ b/src/core/panic.c @@ -100,4 +100,9 @@ osmo_panic_handler = h; }
+#ifdef EMBEDDED +/* thread.c is excluded from the embedded build (requires POSIX pid_t/getpid) */ +int osmo_gettid(void) { return 0; } +#endif + /*! @} */