Skip to content

Commit 3a30f21

Browse files
committed
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.
1 parent d83f4f5 commit 3a30f21

File tree

4 files changed

+40
-58
lines changed

4 files changed

+40
-58
lines changed

meson.build

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,8 @@ exe = executable('systemd-udevd',
20182018
libudev_internal,
20192019
libsystemd_network,
20202020
libshared],
2021-
dependencies : [libkmod,
2021+
dependencies : [threads,
2022+
libkmod,
20222023
libidn,
20232024
libacl,
20242025
libblkid],
@@ -2034,7 +2035,8 @@ exe = executable('udevadm',
20342035
libudev_internal,
20352036
libsystemd_network,
20362037
libshared],
2037-
dependencies : [libkmod,
2038+
dependencies : [threads,
2039+
libkmod,
20382040
libidn,
20392041
libacl,
20402042
libblkid],

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ option('rootlibdir', type : 'string',
66
description : '''[/usr]/lib/x86_64-linux-gnu or such''')
77
option('rootprefix', type : 'string',
88
description : '''override the root prefix''')
9+
option('link-udev-shared', type : 'boolean',
10+
description : 'link systemd-udev and its helpers to libsystemd-shared.so')
911

1012
option('sysvinit-path', type : 'string', value : '/etc/init.d',
1113
description : 'the directory where the SysV init scripts are located')

src/test/meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,8 @@ tests += [
575575
libudev_internal,
576576
libsystemd_network,
577577
libshared],
578-
[librt,
578+
[threads,
579+
librt,
579580
libblkid,
580581
libkmod,
581582
libacl],

src/udev/meson.build

Lines changed: 32 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,20 @@ link_config_gperf_c = custom_target(
9292

9393
############################################################
9494

95+
if get_option('link-udev-shared')
96+
libudev_link_with = [libshared]
97+
rpath = rootlibexecdir
98+
else
99+
libudev_link_with = [libshared_static,
100+
libsystemd_internal]
101+
rpath = ''
102+
endif
103+
95104
libudev_internal = static_library(
96105
'udev',
97106
libudev_sources,
98107
include_directories : includes,
99-
link_with : [libshared])
108+
link_with : libudev_link_with)
100109

101110
libudev_core_includes = [includes, include_directories('net')]
102111
libudev_core = static_library(
@@ -105,60 +114,28 @@ libudev_core = static_library(
105114
link_config_gperf_c,
106115
keyboard_keys_from_name_h,
107116
include_directories : libudev_core_includes,
108-
link_with : [libshared])
109-
110-
executable('ata_id',
111-
'ata_id/ata_id.c',
112-
include_directories : includes,
113-
link_with : [libudev_internal,
114-
libshared],
115-
install : true,
116-
install_dir : udevlibexecdir)
117-
118-
executable('cdrom_id',
119-
'cdrom_id/cdrom_id.c',
120-
include_directories : includes,
121-
link_with : [libudev_internal,
122-
libshared],
123-
install : true,
124-
install_dir : udevlibexecdir)
125-
126-
executable('collect',
127-
'collect/collect.c',
128-
include_directories : includes,
129-
link_with : [libudev_internal,
130-
libshared],
131-
install : true,
132-
install_dir : udevlibexecdir)
133-
134-
executable('scsi_id',
135-
'scsi_id/scsi_id.c',
136-
'scsi_id/scsi_id.h',
137-
'scsi_id/scsi_serial.c',
138-
'scsi_id/scsi.h',
139-
include_directories : includes,
140-
link_with : [libudev_internal,
141-
libshared],
142-
install : true,
143-
install_dir : udevlibexecdir)
144-
145-
executable('v4l_id',
146-
'v4l_id/v4l_id.c',
147-
include_directories : includes,
148-
link_with : [libudev_internal,
149-
libshared],
150-
install : true,
151-
install_dir : udevlibexecdir)
152-
153-
executable('mtd_probe',
154-
'mtd_probe/mtd_probe.c',
155-
'mtd_probe/mtd_probe.h',
156-
'mtd_probe/probe_smartmedia.c',
157-
include_directories : includes,
158-
link_with : [libudev_internal,
159-
libshared],
160-
install : true,
161-
install_dir : udevlibexecdir)
117+
link_with : libudev_link_with)
118+
119+
foreach prog : [['ata_id/ata_id.c'],
120+
['cdrom_id/cdrom_id.c'],
121+
['collect/collect.c'],
122+
['scsi_id/scsi_id.c',
123+
'scsi_id/scsi_id.h',
124+
'scsi_id/scsi_serial.c',
125+
'scsi_id/scsi.h'],
126+
['v4l_id/v4l_id.c'],
127+
['mtd_probe/mtd_probe.c',
128+
'mtd_probe/mtd_probe.h',
129+
'mtd_probe/probe_smartmedia.c']]
130+
131+
executable(prog[0].split('/')[0],
132+
prog,
133+
include_directories : includes,
134+
link_with : [libudev_internal],
135+
install_rpath : rpath,
136+
install : true,
137+
install_dir : udevlibexecdir)
138+
endforeach
162139

163140
install_data('udev.conf',
164141
install_dir : join_paths(sysconfdir, 'udev'))

0 commit comments

Comments
 (0)