[lxc-devel] [lxc/master] autotools: enable static liblxc

brauner on Github lxc-bot at linuxcontainers.org
Mon Jul 2 17:41:02 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180702/3cf87763/attachment.bin>
-------------- next part --------------
From 482f87876439827c8ba526aa1e3072ae06c485ea Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sun, 1 Jul 2018 22:16:08 +0200
Subject: [PATCH 1/2] tree-wide: remove unneded log prefixes

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/af_unix.c         | 2 +-
 src/lxc/attach.c          | 2 +-
 src/lxc/caps.c            | 2 +-
 src/lxc/cgroups/cgfsng.c  | 2 +-
 src/lxc/cgroups/cgroup.c  | 2 +-
 src/lxc/commands.c        | 2 +-
 src/lxc/commands_utils.c  | 2 +-
 src/lxc/conf.c            | 2 +-
 src/lxc/confile.c         | 2 +-
 src/lxc/confile_utils.c   | 2 +-
 src/lxc/criu.c            | 2 +-
 src/lxc/error.c           | 2 +-
 src/lxc/execute.c         | 2 +-
 src/lxc/freezer.c         | 2 +-
 src/lxc/initutils.c       | 2 +-
 src/lxc/log.c             | 2 +-
 src/lxc/lxccontainer.c    | 2 +-
 src/lxc/lxclock.c         | 2 +-
 src/lxc/monitor.c         | 2 +-
 src/lxc/namespace.c       | 2 +-
 src/lxc/network.c         | 2 +-
 src/lxc/parse.c           | 2 +-
 src/lxc/seccomp.c         | 2 +-
 src/lxc/start.c           | 2 +-
 src/lxc/state.c           | 2 +-
 src/lxc/sync.c            | 2 +-
 src/lxc/tools/arguments.c | 8 +-------
 src/lxc/utils.c           | 2 +-
 28 files changed, 28 insertions(+), 34 deletions(-)

diff --git a/src/lxc/af_unix.c b/src/lxc/af_unix.c
index 002f944ce..86f1fe9fd 100644
--- a/src/lxc/af_unix.c
+++ b/src/lxc/af_unix.c
@@ -40,7 +40,7 @@
 #include "include/strlcpy.h"
 #endif
 
-lxc_log_define(lxc_af_unix, lxc);
+lxc_log_define(af_unix, lxc);
 
 int lxc_abstract_unix_open(const char *path, int type, int flags)
 {
diff --git a/src/lxc/attach.c b/src/lxc/attach.c
index bc98f67c5..afb4e0bc0 100644
--- a/src/lxc/attach.c
+++ b/src/lxc/attach.c
@@ -87,7 +87,7 @@
 #define MS_SLAVE (1 << 19)
 #endif
 
-lxc_log_define(lxc_attach, lxc);
+lxc_log_define(attach, lxc);
 
 /* /proc/pid-to-str/status\0 = (5 + 21 + 7 + 1) */
 #define __PROC_STATUS_LEN (5 + (LXC_NUMSTRLEN64) + 7 + 1)
diff --git a/src/lxc/caps.c b/src/lxc/caps.c
index 7b1848f63..ae5d7ef16 100644
--- a/src/lxc/caps.c
+++ b/src/lxc/caps.c
@@ -34,7 +34,7 @@
 #include "caps.h"
 #include "log.h"
 
-lxc_log_define(lxc_caps, lxc);
+lxc_log_define(caps, lxc);
 
 #if HAVE_LIBCAP
 
diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index b514a7bb6..465a9c243 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -66,7 +66,7 @@
 #include "include/strlcat.h"
 #endif
 
-lxc_log_define(lxc_cgfsng, lxc);
+lxc_log_define(cgfsng, cgroup);
 
 static void free_string_list(char **clist)
 {
diff --git a/src/lxc/cgroups/cgroup.c b/src/lxc/cgroups/cgroup.c
index cd67c3c5d..754fdcae3 100644
--- a/src/lxc/cgroups/cgroup.c
+++ b/src/lxc/cgroups/cgroup.c
@@ -30,7 +30,7 @@
 #include "log.h"
 #include "start.h"
 
-lxc_log_define(lxc_cgroup, lxc);
+lxc_log_define(cgroup, lxc);
 
 extern struct cgroup_ops *cgfsng_ops_init(void);
 
diff --git a/src/lxc/commands.c b/src/lxc/commands.c
index 22275277b..618b3089d 100644
--- a/src/lxc/commands.c
+++ b/src/lxc/commands.c
@@ -76,7 +76,7 @@
  * container.
  */
 
-lxc_log_define(lxc_commands, lxc);
+lxc_log_define(commands, lxc);
 
 static const char *lxc_cmd_str(lxc_cmd_t cmd)
 {
diff --git a/src/lxc/commands_utils.c b/src/lxc/commands_utils.c
index 03e481f09..f27880032 100644
--- a/src/lxc/commands_utils.c
+++ b/src/lxc/commands_utils.c
@@ -38,7 +38,7 @@
 #include "state.h"
 #include "utils.h"
 
-lxc_log_define(lxc_commands_utils, lxc);
+lxc_log_define(commands_utils, lxc);
 
 int lxc_cmd_sock_rcv_state(int state_client_fd, int timeout)
 {
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index bb483522d..5f060fe18 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -118,7 +118,7 @@
 #define MS_LAZYTIME (1<<25)
 #endif
 
-lxc_log_define(lxc_conf, lxc);
+lxc_log_define(conf, lxc);
 
 /* The lxc_conf of the container currently being worked on in an API call.
  * This is used in the error calls.
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 7cb1fbb16..4365264e9 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -73,7 +73,7 @@
 #include "include/strlcat.h"
 #endif
 
-lxc_log_define(lxc_confile, lxc);
+lxc_log_define(confile, lxc);
 
 #define lxc_config_define(name)                                                \
 	static int set_config_##name(const char *, const char *,               \
diff --git a/src/lxc/confile_utils.c b/src/lxc/confile_utils.c
index a68c6ffd0..8100cf741 100644
--- a/src/lxc/confile_utils.c
+++ b/src/lxc/confile_utils.c
@@ -40,7 +40,7 @@
 #include "include/strlcpy.h"
 #endif
 
-lxc_log_define(lxc_confile_utils, lxc);
+lxc_log_define(confile_utils, lxc);
 
 int parse_idmaps(const char *idmap, char *type, unsigned long *nsid,
 		 unsigned long *hostid, unsigned long *range)
diff --git a/src/lxc/criu.c b/src/lxc/criu.c
index 41b0c027f..c36421627 100644
--- a/src/lxc/criu.c
+++ b/src/lxc/criu.c
@@ -63,7 +63,7 @@
 #define CRIU_IN_FLIGHT_SUPPORT	"2.4"
 #define CRIU_EXTERNAL_NOT_VETH	"2.8"
 
-lxc_log_define(lxc_criu, lxc);
+lxc_log_define(criu, lxc);
 
 struct criu_opts {
 	/* the thing to hook to stdout and stderr for logging */
diff --git a/src/lxc/error.c b/src/lxc/error.c
index 9147a6afb..769dedc40 100644
--- a/src/lxc/error.c
+++ b/src/lxc/error.c
@@ -28,7 +28,7 @@
 #include "error.h"
 #include "log.h"
 
-lxc_log_define(lxc_error, lxc);
+lxc_log_define(error, lxc);
 
 /*---------------------------------------------------------------------------*/
 /* lxc_error_set_and_log
diff --git a/src/lxc/execute.c b/src/lxc/execute.c
index 1a87b2321..d01df6b2e 100644
--- a/src/lxc/execute.c
+++ b/src/lxc/execute.c
@@ -34,7 +34,7 @@
 #include "start.h"
 #include "utils.h"
 
-lxc_log_define(lxc_execute, lxc_start);
+lxc_log_define(execute, start);
 
 static int execute_start(struct lxc_handler *handler, void* data)
 {
diff --git a/src/lxc/freezer.c b/src/lxc/freezer.c
index 5665aee8e..2103b50b9 100644
--- a/src/lxc/freezer.c
+++ b/src/lxc/freezer.c
@@ -40,7 +40,7 @@
 #include "parse.h"
 #include "state.h"
 
-lxc_log_define(lxc_freezer, lxc);
+lxc_log_define(freezer, lxc);
 
 static int do_freeze_thaw(bool freeze, const char *name, const char *lxcpath)
 {
diff --git a/src/lxc/initutils.c b/src/lxc/initutils.c
index 4ca2ce197..6ab39a7da 100644
--- a/src/lxc/initutils.c
+++ b/src/lxc/initutils.c
@@ -31,7 +31,7 @@
 #include "include/strlcpy.h"
 #endif
 
-lxc_log_define(lxc_initutils, lxc);
+lxc_log_define(initutils, lxc);
 
 static char *copy_global_config_value(char *p)
 {
diff --git a/src/lxc/log.c b/src/lxc/log.c
index a3ce9f367..8e7de7c8d 100644
--- a/src/lxc/log.c
+++ b/src/lxc/log.c
@@ -66,7 +66,7 @@ static char log_prefix[LXC_LOG_PREFIX_SIZE] = "lxc";
 static char *log_fname = NULL;
 static char *log_vmname = NULL;
 
-lxc_log_define(lxc_log, lxc);
+lxc_log_define(log, lxc);
 
 static int lxc_log_priority_to_syslog(int priority)
 {
diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index c5ea78770..ce01f13e9 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -104,7 +104,7 @@ static int faccessat(int __fd, const char *__file, int __type, int __flag)
 }
 #endif
 
-lxc_log_define(lxc_container, lxc);
+lxc_log_define(lxccontainer, lxc);
 
 static bool do_lxcapi_destroy(struct lxc_container *c);
 static const char *lxcapi_get_config_path(struct lxc_container *c);
diff --git a/src/lxc/lxclock.c b/src/lxc/lxclock.c
index 08c96e0b1..29675fb59 100644
--- a/src/lxc/lxclock.c
+++ b/src/lxc/lxclock.c
@@ -40,7 +40,7 @@
 
 #define MAX_STACKDEPTH 25
 
-lxc_log_define(lxc_lock, lxc);
+lxc_log_define(lxclock, lxc);
 
 #ifdef MUTEX_DEBUGGING
 static pthread_mutex_t thread_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
diff --git a/src/lxc/monitor.c b/src/lxc/monitor.c
index 4bbf679db..d9f10c40b 100644
--- a/src/lxc/monitor.c
+++ b/src/lxc/monitor.c
@@ -54,7 +54,7 @@
 #include "include/strlcpy.h"
 #endif
 
-lxc_log_define(lxc_monitor, lxc);
+lxc_log_define(monitor, lxc);
 
 /* routines used by monitor publishers (containers) */
 int lxc_monitor_fifo_name(const char *lxcpath, char *fifo_path, size_t fifo_path_sz,
diff --git a/src/lxc/namespace.c b/src/lxc/namespace.c
index a169f83de..2459c9d2e 100644
--- a/src/lxc/namespace.c
+++ b/src/lxc/namespace.c
@@ -37,7 +37,7 @@
 #include "namespace.h"
 #include "utils.h"
 
-lxc_log_define(lxc_namespace, lxc);
+lxc_log_define(namespace, lxc);
 
 struct clone_arg {
 	int (*fn)(void *);
diff --git a/src/lxc/network.c b/src/lxc/network.c
index e59b85d62..c9497afa4 100644
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -95,7 +95,7 @@
 #define IFLA_MACVLAN_MODE 1
 #endif
 
-lxc_log_define(lxc_network, lxc);
+lxc_log_define(network, lxc);
 
 typedef int (*instantiate_cb)(struct lxc_handler *, struct lxc_netdev *);
 
diff --git a/src/lxc/parse.c b/src/lxc/parse.c
index a1025c5af..bc209347c 100644
--- a/src/lxc/parse.c
+++ b/src/lxc/parse.c
@@ -35,7 +35,7 @@
 #include "utils.h"
 #include "log.h"
 
-lxc_log_define(lxc_parse, lxc);
+lxc_log_define(parse, lxc);
 
 void *lxc_strmmap(void *addr, size_t length, int prot, int flags, int fd,
 		  off_t offset)
diff --git a/src/lxc/seccomp.c b/src/lxc/seccomp.c
index 81abf62ee..c8f2b3f3b 100644
--- a/src/lxc/seccomp.c
+++ b/src/lxc/seccomp.c
@@ -42,7 +42,7 @@
 #define MIPS_ARCH_N64 lxc_seccomp_arch_mips64
 #endif
 
-lxc_log_define(lxc_seccomp, lxc);
+lxc_log_define(seccomp, lxc);
 
 static int parse_config_v1(FILE *f, char *line, size_t *line_bufsz, struct lxc_conf *conf)
 {
diff --git a/src/lxc/start.c b/src/lxc/start.c
index a0bcd80bb..953722261 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -94,7 +94,7 @@
 #include "include/strlcpy.h"
 #endif
 
-lxc_log_define(lxc_start, lxc);
+lxc_log_define(start, lxc);
 
 extern void mod_all_rdeps(struct lxc_container *c, bool inc);
 static bool do_destroy_container(struct lxc_handler *handler);
diff --git a/src/lxc/state.c b/src/lxc/state.c
index 12fd65386..3ccbe583a 100644
--- a/src/lxc/state.c
+++ b/src/lxc/state.c
@@ -44,7 +44,7 @@
 #include "monitor.h"
 #include "start.h"
 
-lxc_log_define(lxc_state, lxc);
+lxc_log_define(state, lxc);
 
 static const char *const strstate[] = {
     "STOPPED",  "STARTING", "RUNNING", "STOPPING",
diff --git a/src/lxc/sync.c b/src/lxc/sync.c
index f38a56961..43f4c142d 100644
--- a/src/lxc/sync.c
+++ b/src/lxc/sync.c
@@ -32,7 +32,7 @@
 #include "log.h"
 #include "start.h"
 
-lxc_log_define(lxc_sync, lxc);
+lxc_log_define(sync, lxc);
 
 static int __sync_wait(int fd, int sequence)
 {
diff --git a/src/lxc/tools/arguments.c b/src/lxc/tools/arguments.c
index 5e2387a9e..daff4d816 100644
--- a/src/lxc/tools/arguments.c
+++ b/src/lxc/tools/arguments.c
@@ -38,6 +38,7 @@
 
 #include "arguments.h"
 #include "namespace.h"
+#include "initutils.h"
 
 static int build_shortopts(const struct option *a_options, char *a_shortopts,
 			   size_t a_size)
@@ -186,13 +187,6 @@ static int lxc_arguments_lxcpath_add(struct lxc_arguments *args,
 	return 0;
 }
 
-void remove_trailing_slashes(char *p)
-{
-	int l = strlen(p);
-	while (--l >= 0 && (p[l] == '/' || p[l] == '\n'))
-		p[l] = '\0';
-}
-
 extern int lxc_arguments_parse(struct lxc_arguments *args, int argc,
 			       char *const argv[])
 {
diff --git a/src/lxc/utils.c b/src/lxc/utils.c
index fb7ae2023..c134a167c 100644
--- a/src/lxc/utils.c
+++ b/src/lxc/utils.c
@@ -67,7 +67,7 @@
 #define O_NOFOLLOW  00400000
 #endif
 
-lxc_log_define(lxc_utils, lxc);
+lxc_log_define(utils, lxc);
 
 /*
  * if path is btrfs, tries to remove it and any subvolumes beneath it

From 04eac47c8a5334cf2d61b40865a5a8bc92a262b7 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sun, 1 Jul 2018 22:16:22 +0200
Subject: [PATCH 2/2] configure: add --enable-static

This adds --enable-static which compiles a static version of liblxc.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 configure.ac        |  9 +++++++++
 src/lxc/Makefile.am | 10 +++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index c24f8f3ee..e119cc740 100644
--- a/configure.ac
+++ b/configure.ac
@@ -489,6 +489,12 @@ AC_ARG_WITH([log-path],
 		[per container log path]
 	)], [], [with_log_path=['${default_log_path}']])
 
+# Compile static liblxc
+AC_ARG_ENABLE([static],
+	[AC_HELP_STRING([--enable-static], [build a static version of liblxc [default=no]])],
+	[], [enable_static=no])
+AM_CONDITIONAL([ENABLE_STATIC], [test "x$enable_static" = "xyes"])
+
 # Expand some useful variables
 AS_AC_EXPAND(PREFIX, "$prefix")
 AS_AC_EXPAND(LIBDIR, "$libdir")
@@ -898,4 +904,7 @@ Debugging:
 
 Paths:
  - Logs in configpath: $enable_configpath_log
+
+liblxc:
+ - static: $enable_static
 EOF
diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
index da647740b..0922cc8f9 100644
--- a/src/lxc/Makefile.am
+++ b/src/lxc/Makefile.am
@@ -207,11 +207,15 @@ endif
 
 liblxc_la_CFLAGS = -fPIC -DPIC $(AM_CFLAGS) -pthread
 
-liblxc_la_LDFLAGS = \
-	-pthread \
-	-shared \
+liblxc_la_LDFLAGS = -pthread
+
+if ENABLE_STATIC
+liblxc_la_LDFLAGS += -all-static
+else
+liblxc_la_LDFLAGS += -shared \
 	-Wl,-soname,liblxc.so.$(firstword $(subst ., , at LXC_ABI@)) \
 	-version-info @LXC_ABI_MAJOR@
+endif
 
 liblxc_la_LIBADD = $(CAP_LIBS) $(GNUTLS_LIBS) $(SELINUX_LIBS) $(SECCOMP_LIBS)
 


More information about the lxc-devel mailing list