[pacman-dev] [PATCH 1/2] meson: fix libcommon being publicly exposed as a static link dependency
libcommon isn't even installed, so that means libalpm.a (if installed) is fatally broken as it misses objects. The problem is that meson doesn't handle this case correctly: https://github.com/mesonbuild/meson/issues/3934 https://github.com/mesonbuild/meson/issues/3937 https://github.com/mesonbuild/meson/pull/3939 Work around this by manually extracting libcommon's .o files into the list of objects used to create libalpm. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 389a95b7..5199759f 100644 --- a/meson.build +++ b/meson.build @@ -317,9 +317,10 @@ libcommon = static_library( libalpm_a = static_library( 'alpm', libalpm_sources, + # https://github.com/mesonbuild/meson/issues/3937 + objects : libcommon.extract_all_objects(), include_directories : includes, dependencies : [crypto_provider, libarchive, libcurl, gpgme], - link_with : [libcommon], install : true) if get_option('default_library') != 'static' @@ -336,7 +337,6 @@ install_headers( 'lib/libalpm/alpm.h', 'lib/libalpm/alpm_list.h') -# TODO: libs.private seem quite wrong here pkgconfig = import('pkgconfig') pkgconfig.generate( libalpm, -- 2.23.0
In addition to the general issue of staticlibs linkage, linking a static lib to a library() does not seem to generate the needed Libs.private. Rework how we handle this entirely. Instead of relying on convenience libraries, we will *sigh* go extract a boatload of .o files again, then relink those to the installable libalpm, while mentioning our dependencies again. We still have our guaranteed static library for linking arbitrary programs with (e.g. vercmp), and we still only generate one identical copy of the .o files, but now we potentially `ar` it up twice, which isn't so bad. And linking still works, and pkg-config files also still work. One alternative would be to explicitly list our dependencies to pkgconfig.generate with requires_private, but since gpgme might be an elevated config-tool dependency, this can fail with: meson.build:341:10: ERROR: requires argument not a string, library with pkgconfig-generated file or pkgconfig-dependency object, got <GpgmeDependency gpgme: True> Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- meson.build | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build index 5199759f..650e599f 100644 --- a/meson.build +++ b/meson.build @@ -314,24 +314,22 @@ libcommon = static_library( include_directories : includes, install : false) +alpm_deps = [crypto_provider, libarchive, libcurl, gpgme] + libalpm_a = static_library( - 'alpm', + 'alpm_objlib', libalpm_sources, # https://github.com/mesonbuild/meson/issues/3937 objects : libcommon.extract_all_objects(), include_directories : includes, - dependencies : [crypto_provider, libarchive, libcurl, gpgme], - install : true) + dependencies : alpm_deps) -if get_option('default_library') != 'static' - libalpm = library( - 'alpm', - version : libalpm_version, - link_whole: [libalpm_a], - install : true) -else - libalpm = libalpm_a -endif +libalpm = library( + 'alpm', + version : libalpm_version, + objects: [libalpm_a.extract_all_objects(), libcommon.extract_all_objects()], + dependencies : alpm_deps, + install : true) install_headers( 'lib/libalpm/alpm.h', -- 2.23.0
In addition to the general issue of staticlibs linkage, linking a static lib to a library() does not seem to generate the needed Libs.private. Rework how we handle this entirely. Instead of relying on convenience libraries, we will *sigh* go extract a boatload of .o files again, then relink those to the installable libalpm, while mentioning our dependencies again. We still have our guaranteed static library for linking arbitrary programs with (e.g. vercmp), and we still only generate one identical copy of the .o files, but now we potentially `ar` it up twice, which isn't so bad. And linking still works, and pkg-config files also still work. One alternative would be to explicitly list our dependencies to pkgconfig.generate with requires_private, but since gpgme might be an elevated config-tool dependency, this can fail with: meson.build:341:10: ERROR: requires argument not a string, library with pkgconfig-generated file or pkgconfig-dependency object, got <GpgmeDependency gpgme: True> Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- v2: extract_all_objects can be recursive meson.build | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build index 5199759f..e895c671 100644 --- a/meson.build +++ b/meson.build @@ -314,24 +314,22 @@ libcommon = static_library( include_directories : includes, install : false) +alpm_deps = [crypto_provider, libarchive, libcurl, gpgme] + libalpm_a = static_library( - 'alpm', + 'alpm_objlib', libalpm_sources, # https://github.com/mesonbuild/meson/issues/3937 objects : libcommon.extract_all_objects(), include_directories : includes, - dependencies : [crypto_provider, libarchive, libcurl, gpgme], - install : true) + dependencies : alpm_deps) -if get_option('default_library') != 'static' - libalpm = library( - 'alpm', - version : libalpm_version, - link_whole: [libalpm_a], - install : true) -else - libalpm = libalpm_a -endif +libalpm = library( + 'alpm', + version : libalpm_version, + objects: libalpm_a.extract_all_objects(recursive: true), + dependencies : alpm_deps, + install : true) install_headers( 'lib/libalpm/alpm.h', -- 2.23.0
participants (1)
-
Eli Schwartz