mirror of
https://github.com/openwrt/packages.git
synced 2025-12-22 19:04:32 +04:00
LXC after the switch to the Meson build system increased the binary sizes significantly as each binary is basically static so shipping complete liblxc which should be linked dynamically. Upstream later fixed it with series of 10 commits and this fixes are available in LXC release v6.0.0. Since we can't upstep to that release, lets fix it by backporting those fixes only, basically making libxlc a shared library again. Package sizes before: 384K lxc-user-nic_5.0.3-1_aarch64_cortex-a53.ipk 383K lxc-ls_5.0.3-1_aarch64_cortex-a53.ipk 382K lxc-top_5.0.3-1_aarch64_cortex-a53.ipk 382K lxc-copy_5.0.3-1_aarch64_cortex-a53.ipk 381K lxc-unshare_5.0.3-1_aarch64_cortex-a53.ipk 380K lxc-start_5.0.3-1_aarch64_cortex-a53.ipk 380K lxc-monitor_5.0.3-1_aarch64_cortex-a53.ipk 380K lxc-info_5.0.3-1_aarch64_cortex-a53.ipk 380K lxc-create_5.0.3-1_aarch64_cortex-a53.ipk 380K lxc-autostart_5.0.3-1_aarch64_cortex-a53.ipk 380K lxc-attach_5.0.3-1_aarch64_cortex-a53.ipk 379K lxc-execute_5.0.3-1_aarch64_cortex-a53.ipk 378K lxc-wait_5.0.3-1_aarch64_cortex-a53.ipk 378K lxc-usernsexec_5.0.3-1_aarch64_cortex-a53.ipk 378K lxc-unfreeze_5.0.3-1_aarch64_cortex-a53.ipk 378K lxc-stop_5.0.3-1_aarch64_cortex-a53.ipk 378K lxc-freeze_5.0.3-1_aarch64_cortex-a53.ipk 378K lxc-device_5.0.3-1_aarch64_cortex-a53.ipk 378K lxc-destroy_5.0.3-1_aarch64_cortex-a53.ipk 378K lxc-console_5.0.3-1_aarch64_cortex-a53.ipk 378K lxc-cgroup_5.0.3-1_aarch64_cortex-a53.ipk 376K liblxc_5.0.3-1_aarch64_cortex-a53.ipk 375K lxc-config_5.0.3-1_aarch64_cortex-a53.ipk 12K lxc-hooks_5.0.3-1_aarch64_cortex-a53.ipk 11K lxc-templates_5.0.3-1_aarch64_cortex-a53.ipk 3.7K lxc-checkconfig_5.0.3-1_aarch64_cortex-a53.ipk 2.4K lxc-configs_5.0.3-1_aarch64_cortex-a53.ipk 1.9K lxc-auto_5.0.3-1_aarch64_cortex-a53.ipk 1.6K lxc-common_5.0.3-1_aarch64_cortex-a53.ipk 1.2K lxc-unprivileged_5.0.3-1_aarch64_cortex-a53.ipk 978 lxc_5.0.3-1_aarch64_cortex-a53.ipk Sizes after: 378K liblxc_5.0.3-2_aarch64_cortex-a53.ipk 27K lxc-user-nic_5.0.3-2_aarch64_cortex-a53.ipk 24K lxc-ls_5.0.3-2_aarch64_cortex-a53.ipk 21K lxc-usernsexec_5.0.3-2_aarch64_cortex-a53.ipk 21K lxc-top_5.0.3-2_aarch64_cortex-a53.ipk 20K lxc-unshare_5.0.3-2_aarch64_cortex-a53.ipk 20K lxc-copy_5.0.3-2_aarch64_cortex-a53.ipk 20K lxc-attach_5.0.3-2_aarch64_cortex-a53.ipk 18K lxc-start_5.0.3-2_aarch64_cortex-a53.ipk 18K lxc-info_5.0.3-2_aarch64_cortex-a53.ipk 18K lxc-execute_5.0.3-2_aarch64_cortex-a53.ipk 18K lxc-device_5.0.3-2_aarch64_cortex-a53.ipk 18K lxc-create_5.0.3-2_aarch64_cortex-a53.ipk 18K lxc-autostart_5.0.3-2_aarch64_cortex-a53.ipk 17K lxc-destroy_5.0.3-2_aarch64_cortex-a53.ipk 16K lxc-wait_5.0.3-2_aarch64_cortex-a53.ipk 16K lxc-unfreeze_5.0.3-2_aarch64_cortex-a53.ipk 16K lxc-stop_5.0.3-2_aarch64_cortex-a53.ipk 16K lxc-freeze_5.0.3-2_aarch64_cortex-a53.ipk 16K lxc-console_5.0.3-2_aarch64_cortex-a53.ipk 16K lxc-cgroup_5.0.3-2_aarch64_cortex-a53.ipk 15K lxc-monitor_5.0.3-2_aarch64_cortex-a53.ipk 13K lxc-config_5.0.3-2_aarch64_cortex-a53.ipk 12K lxc-hooks_5.0.3-2_aarch64_cortex-a53.ipk 11K lxc-templates_5.0.3-2_aarch64_cortex-a53.ipk 3.7K lxc-checkconfig_5.0.3-2_aarch64_cortex-a53.ipk 2.4K lxc-configs_5.0.3-2_aarch64_cortex-a53.ipk 1.9K lxc-auto_5.0.3-2_aarch64_cortex-a53.ipk 1.6K lxc-common_5.0.3-2_aarch64_cortex-a53.ipk 1.1K lxc-unprivileged_5.0.3-2_aarch64_cortex-a53.ipk 944 lxc_5.0.3-2_aarch64_cortex-a53.ipk Sum of Package Sizes: Before: 8758.78K After: 814.64K The total package size has decreased by approximately 90% after the fix. References: https://github.com/lxc/lxc/pull/4401 Signed-off-by: Petr Štetiar <ynezz@true.cz>
79 lines
2.5 KiB
Diff
79 lines
2.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
|
|
Date: Sat, 17 Feb 2024 16:47:41 +0100
|
|
Subject: [PATCH] meson: introduce IN_LIBLXC preprocessor macro
|
|
|
|
The purpose of it is to tell us if we are compiling
|
|
liblxc or lxc test/tool/command.
|
|
|
|
This thing is needed to exclude unnecessary functions
|
|
from being compiled-in in the resulting executables
|
|
like lxc-start, lxc-attach, etc.
|
|
|
|
The problem is that lxc tools (lxc-start, lxc-stop, etc)
|
|
depend not only on the liblxc as a shared library, but also
|
|
require some non-exported symbols or helpers from liblxc
|
|
internals. So, we have to link these executables with some liblxc
|
|
object files directly which results in the dependency hell,
|
|
because linking one .c file from liblxc may end up having to
|
|
link with another one (what contains some dependency) and so on.
|
|
By using IN_LIBLXC in the liblxc internals we can selectively
|
|
omit some functions from being compiled in such cases.
|
|
|
|
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
|
|
(cherry picked from commit f14656ebf62ab0dbb836431e2781cfd363f4e4aa)
|
|
---
|
|
src/lxc/meson.build | 2 +-
|
|
src/lxc/state.c | 4 ++++
|
|
src/lxc/utils.c | 4 ++++
|
|
3 files changed, 9 insertions(+), 1 deletion(-)
|
|
|
|
--- a/src/lxc/meson.build
|
|
+++ b/src/lxc/meson.build
|
|
@@ -157,7 +157,7 @@ liblxc_static = static_library(
|
|
install: true,
|
|
include_directories: liblxc_includes,
|
|
dependencies: [threads] + liblxc_dependency_headers,
|
|
- c_args: '-fvisibility=default')
|
|
+ c_args: ['-fvisibility=default', '-DIN_LIBLXC'])
|
|
|
|
lxc_functions = configure_file(
|
|
configuration: conf,
|
|
--- a/src/lxc/state.c
|
|
+++ b/src/lxc/state.c
|
|
@@ -52,6 +52,8 @@ lxc_state_t lxc_str2state(const char *st
|
|
return -1;
|
|
}
|
|
|
|
+#ifdef IN_LIBLXC
|
|
+
|
|
lxc_state_t lxc_getstate(const char *name, const char *lxcpath)
|
|
{
|
|
return lxc_cmd_get_state(name, lxcpath);
|
|
@@ -117,3 +119,5 @@ int lxc_wait(const char *lxcname, const
|
|
|
|
return 0;
|
|
}
|
|
+
|
|
+#endif /* IN_LIBLXC */
|
|
--- a/src/lxc/utils.c
|
|
+++ b/src/lxc/utils.c
|
|
@@ -61,6 +61,8 @@ lxc_log_define(utils, lxc);
|
|
*/
|
|
extern bool btrfs_try_remove_subvol(const char *path);
|
|
|
|
+#ifdef IN_LIBLXC
|
|
+
|
|
static int _recursive_rmdir(const char *dirname, dev_t pdev,
|
|
const char *exclude, int level, bool onedev)
|
|
{
|
|
@@ -193,6 +195,8 @@ extern int lxc_rmdir_onedev(const char *
|
|
return _recursive_rmdir(path, mystat.st_dev, exclude, 0, onedev);
|
|
}
|
|
|
|
+#endif /* IN_LIBLXC */
|
|
+
|
|
/* borrowed from iproute2 */
|
|
extern int get_u16(unsigned short *val, const char *arg, int base)
|
|
{
|