Skip to content

meson: avoid duplicate library entries on executable link lines#228

Open
igoropaniuk wants to merge 1 commit intolinux-msm:masterfrom
igoropaniuk:fix/meson_duplicate_library_entries
Open

meson: avoid duplicate library entries on executable link lines#228
igoropaniuk wants to merge 1 commit intolinux-msm:masterfrom
igoropaniuk:fix/meson_duplicate_library_entries

Conversation

@igoropaniuk
Copy link
Copy Markdown
Contributor

Both the qdl_common static library and each of the qdl/qdl-ramdump/qdl-ks executables were declared with the same dependencies: common_dep (libusb-1.0, libxml-2.0, libzip, plus ws2_32 on Windows). Meson propagates a static library's dependencies to its consumers via link_with, so listing those dependencies again on each executable caused every common library to appear twice on the final link line. Apple's ld surfaced this as:

ld: warning: ignoring duplicate libraries: '-lxml2'

The other dependencies are passed by absolute dylib path on macOS (libusb-1.0, libzip), so the linker silently deduplicated those while still warning about libxml2, which is referenced as -lxml2 from the system path.

Fix it by introducing a compile-only view of the common dependencies using partial_dependency(compile_args: true, includes: true) and attaching that to the executables instead of the full deps. The executables still see the headers needed to compile their own sources (e.g. usb.c -> libusb.h, file.c -> zip.h), while link arguments now flow to them exactly once via the static library's automatic propagation.

Fixes: ff189b1 ("build: migrate from GNU Make to Meson build system")

@igoropaniuk igoropaniuk force-pushed the fix/meson_duplicate_library_entries branch from 736dc58 to b0ff75a Compare May 6, 2026 08:48
Both the qdl_common static library and each of the
qdl/qdl-ramdump/qdl-ks executables were declared with the same
`dependencies: common_dep` (libusb-1.0, libxml-2.0, libzip,
plus ws2_32 on Windows). Meson propagates a static library's
dependencies to its consumers via `link_with`, so listing those
dependencies again on each executable caused every common library to
appear twice on the final link line. Apple's ld surfaced this as:

  ld: warning: ignoring duplicate libraries: '-lxml2'

The other dependencies are passed by absolute dylib path on macOS
(libusb-1.0, libzip), so the linker silently deduplicated those while
still warning about libxml2, which is referenced as `-lxml2` from the
system path.

Fix it by introducing a compile-only view of the common dependencies
using `partial_dependency(compile_args: true, includes: true)` and
attaching that to the executables instead of the full deps. The
executables still see the headers needed to compile their own sources
(e.g. usb.c -> libusb.h, file.c -> zip.h), while link arguments now
flow to them exactly once via the static library's automatic
propagation.

Fixes: ff189b1 ("build: migrate from GNU Make to Meson build system")
Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
@igoropaniuk igoropaniuk force-pushed the fix/meson_duplicate_library_entries branch from b0ff75a to dd7fc1a Compare May 6, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant