From 3a30f21ff8ddbef5eae61d6e4305ec1cd2e4e041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 17 Apr 2017 12:07:12 -0400 Subject: meson: allow optional static linking of shared code in udev helpers This makes the helper binaries significantly bigger (in some cases, the final size depends on link options and optimization level), and is only useful for distributions which want to provide the option to install udev without systemd. As the linking is improved, the difference between the columns might shrink, but it's unlikely that linking libshared statically could ever be more efficient. E.g. with -O0, no -flto: (static) (shared) src/udev/ata_id 999176 85696 src/udev/cdrom_id 1024344 111656 src/udev/collect 990344 81280 src/udev/scsi_id 1023592 115656 src/udev/v4l_id 811736 17744 When linked dynamically, install_rpath must be specified, so add that. --- meson.build | 6 ++-- meson_options.txt | 2 ++ src/test/meson.build | 3 +- src/udev/meson.build | 87 +++++++++++++++++++--------------------------------- 4 files changed, 40 insertions(+), 58 deletions(-) diff --git a/meson.build b/meson.build index 6fca0b0932..9504e984ec 100644 --- a/meson.build +++ b/meson.build @@ -2018,7 +2018,8 @@ exe = executable('systemd-udevd', libudev_internal, libsystemd_network, libshared], - dependencies : [libkmod, + dependencies : [threads, + libkmod, libidn, libacl, libblkid], @@ -2034,7 +2035,8 @@ exe = executable('udevadm', libudev_internal, libsystemd_network, libshared], - dependencies : [libkmod, + dependencies : [threads, + libkmod, libidn, libacl, libblkid], diff --git a/meson_options.txt b/meson_options.txt index 9caf9a329f..132c05ab56 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -6,6 +6,8 @@ option('rootlibdir', type : 'string', description : '''[/usr]/lib/x86_64-linux-gnu or such''') option('rootprefix', type : 'string', description : '''override the root prefix''') +option('link-udev-shared', type : 'boolean', + description : 'link systemd-udev and its helpers to libsystemd-shared.so') option('sysvinit-path', type : 'string', value : '/etc/init.d', description : 'the directory where the SysV init scripts are located') diff --git a/src/test/meson.build b/src/test/meson.build index 59a51d857e..0014fed79b 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -575,7 +575,8 @@ tests += [ libudev_internal, libsystemd_network, libshared], - [librt, + [threads, + librt, libblkid, libkmod, libacl], diff --git a/src/udev/meson.build b/src/udev/meson.build index e7feaedb4f..1eac8754eb 100644 --- a/src/udev/meson.build +++ b/src/udev/meson.build @@ -92,11 +92,20 @@ link_config_gperf_c = custom_target( ############################################################ +if get_option('link-udev-shared') + libudev_link_with = [libshared] + rpath = rootlibexecdir +else + libudev_link_with = [libshared_static, + libsystemd_internal] + rpath = '' +endif + libudev_internal = static_library( 'udev', libudev_sources, include_directories : includes, - link_with : [libshared]) + link_with : libudev_link_with) libudev_core_includes = [includes, include_directories('net')] libudev_core = static_library( @@ -105,60 +114,28 @@ libudev_core = static_library( link_config_gperf_c, keyboard_keys_from_name_h, include_directories : libudev_core_includes, - link_with : [libshared]) - -executable('ata_id', - 'ata_id/ata_id.c', - include_directories : includes, - link_with : [libudev_internal, - libshared], - install : true, - install_dir : udevlibexecdir) - -executable('cdrom_id', - 'cdrom_id/cdrom_id.c', - include_directories : includes, - link_with : [libudev_internal, - libshared], - install : true, - install_dir : udevlibexecdir) - -executable('collect', - 'collect/collect.c', - include_directories : includes, - link_with : [libudev_internal, - libshared], - install : true, - install_dir : udevlibexecdir) - -executable('scsi_id', - 'scsi_id/scsi_id.c', - 'scsi_id/scsi_id.h', - 'scsi_id/scsi_serial.c', - 'scsi_id/scsi.h', - include_directories : includes, - link_with : [libudev_internal, - libshared], - install : true, - install_dir : udevlibexecdir) - -executable('v4l_id', - 'v4l_id/v4l_id.c', - include_directories : includes, - link_with : [libudev_internal, - libshared], - install : true, - install_dir : udevlibexecdir) - -executable('mtd_probe', - 'mtd_probe/mtd_probe.c', - 'mtd_probe/mtd_probe.h', - 'mtd_probe/probe_smartmedia.c', - include_directories : includes, - link_with : [libudev_internal, - libshared], - install : true, - install_dir : udevlibexecdir) + link_with : libudev_link_with) + +foreach prog : [['ata_id/ata_id.c'], + ['cdrom_id/cdrom_id.c'], + ['collect/collect.c'], + ['scsi_id/scsi_id.c', + 'scsi_id/scsi_id.h', + 'scsi_id/scsi_serial.c', + 'scsi_id/scsi.h'], + ['v4l_id/v4l_id.c'], + ['mtd_probe/mtd_probe.c', + 'mtd_probe/mtd_probe.h', + 'mtd_probe/probe_smartmedia.c']] + + executable(prog[0].split('/')[0], + prog, + include_directories : includes, + link_with : [libudev_internal], + install_rpath : rpath, + install : true, + install_dir : udevlibexecdir) +endforeach install_data('udev.conf', install_dir : join_paths(sysconfdir, 'udev')) -- cgit v1.2.1