chiark / gitweb /
meson: recompile all sources for install_libudev_static and install_libsystemd_static
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 25 Apr 2018 13:29:48 +0000 (15:29 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
This means that when those targets are built, all the sources are built again,
instead of reusing the work done to create libbasic.a and other convenience static
libraries. It would be nice to not do this, but there seems to be no support in
our toolchain for joining multiple static libraries into one. When linking
a static library, any -l arguments are simply ignored by ar/gcc-ar, and .a
libraries given as positional arguments are copied verbatim into the archive
so they objects in them cannot be accessed.

https://stackoverflow.com/questions/2157629/linking-static-libraries-to-other-static-libraries
suggests either unzipping all the archives and putting them back togather,
or using a linker script. Unzipping and zipping back together seems ugly.
The other option is not very nice. The linker script language does not
allow "+" to appear in the filenames, and filenames that meson generates
use that, so files would have to be renamed before a linker script was used.
And we would have to generate the linker script on the fly. Either way, this
doesn't seem attractive. Since those static libraries are a niche use case,
it seems reasonable to just go with the easiest and safest solution and
recompile all the source files. Thanks to ccache, this is probably almost as
cheap as actually reusing the convenience .a libraries.

test-libsystemd-sym.c and test-libudev-sym.c compile fine with the generated
static libs, so it seems that they indeed provide all the symbols they should.

meson.build
src/basic/meson.build
src/shared/meson.build

index cd79723684580602577be771d00cc406a58ea8ee..0193f95f2e163e3dbbfb3b36b362d5ed2384457c 100644 (file)
@@ -1548,9 +1548,9 @@ install_libelogind_static = static_library(
         'elogind',
         libelogind_sources,
         journal_client_sources,
+        basic_sources,
+        basic_gcrypt_sources,
         include_directories : includes,
-        link_with : [libbasic,
-                     libbasic_gcrypt],
         build_by_default : static_libelogind != 'false',
         install : static_libelogind != 'false',
         install_dir : rootlibdir,
@@ -1559,6 +1559,10 @@ install_libelogind_static = static_library(
                         librt,
                         libxz,
                         liblz4,
+                        libcap,
+                        libblkid,
+                        libmount,
+                        libselinux,
                         libgcrypt],
         c_args : libelogind_c_args + (static_libelogind_pic ? [] : ['-fno-PIC']))
 
index bc7e7865584d2b6cec24e4d2bde97b11377398b6..5eef906d43ff0645b83bc5151462631cc003781b 100644 (file)
 #         securebits.h
 #         selinux-util.c
 #         selinux-util.h
+#         set.c
 #         set.h
 #         sigbus.c
 #         sigbus.h
@@ -459,6 +460,9 @@ foreach item : [['cap',    cap_list_txt,    'capability', ''],
 endforeach
 
 basic_sources += [missing_h] + generated_gperf_headers
+basic_gcrypt_sources = files(
+        'gcrypt-util.c',
+        'gcrypt-util.h')
 
 libbasic = static_library(
         'basic',
@@ -479,8 +483,7 @@ libbasic = static_library(
 # # unnecessary linking to libgcrypt.
 # libbasic_gcrypt = static_library(
 #         'basic-gcrypt',
-#         'gcrypt-util.c',
-#         'gcrypt-util.h',
+#         basic_gcrypt_sources,
 #         include_directories : includes,
 #         dependencies : [libgcrypt],
 #         c_args : ['-fvisibility=default'])
index 139ecb0efc30aae51166d81f0fc3ccb9a599dff2..a42059c83bc78626cd3f3916f1aa570ff832c813 100644 (file)
@@ -3,7 +3,7 @@
 # Copyright 2017 Zbigniew Jędrzejewski-Szmek
 
 #if 0 /// elogind has a much shorter list
-# shared_sources = '''
+# shared_sources = files('''
 #         acl-util.h
 #         acpi-fpdt.c
 #         acpi-fpdt.h
 #         watchdog.c
 #         watchdog.h
 #         wireguard-netlink.h
-# '''.split()
+# '''.split())
 #else
 shared_sources = '''
         bus-util.c
@@ -135,20 +135,20 @@ test_tables_h = files('test-tables.h')
 shared_sources += [test_tables_h]
 
 if conf.get('HAVE_ACL') == 1
-        shared_sources += ['acl-util.c']
+        shared_sources += files('acl-util.c')
 endif
 
 if conf.get('ENABLE_UTMP') == 1
-        shared_sources += ['utmp-wtmp.c']
+        shared_sources += files('utmp-wtmp.c')
 endif
 
 #if 0 /// UNNEEDED by elogind
 # if conf.get('HAVE_SECCOMP') == 1
-#         shared_sources += ['seccomp-util.c']
+#         shared_sources += files('seccomp-util.c')
 # endif
 # 
 # if conf.get('HAVE_LIBIPTC') == 1
-#         shared_sources += ['firewall-util.c']
+#         shared_sources += files('firewall-util.c')
 # endif
 #endif // 0