From 8b73f3d692f67da766f0d8f3dbcae2e842459c20 Mon Sep 17 00:00:00 2001 From: Damocles Date: Sun, 3 May 2026 22:58:04 +0200 Subject: [PATCH] plugin: switch dynamic-list to version-script (only the latter overrides local: *) --- plugin/build.rs | 20 ++++++++++---------- plugin/qt_plugin_exports.txt | 5 +++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/plugin/build.rs b/plugin/build.rs index cb64c23..b2f36ce 100644 --- a/plugin/build.rs +++ b/plugin/build.rs @@ -7,20 +7,20 @@ fn main() { // nothing internal references those symbols (moc emits them as dlsym // entry points), so the linker drops them entirely. --undefined= // anchors them past --gc-sections. - // 2. Rust's cdylib link passes an explicit --version-script that exports - // only Rust-public symbols - everything else, including our anchored C++ - // plugin symbols, is hidden as local. Neither --export-dynamic nor - // --export-dynamic-symbol overrides an explicit version script. The fix - // is --dynamic-list=, which is additive: it appends entries to the - // dynamic symtab without fighting the version script's hides. + // 2. Rust's cdylib link passes an explicit --version-script that lists Rust + // public symbols under `global:` and ends with `local: *;`, hiding + // everything else. --dynamic-list and --export-dynamic both lose to that + // `local: *;`. Multiple --version-script flags merge per ld(1), and + // explicit `global:` entries override the wildcard local, so we pass a + // second version script that adds the qt_plugin entry points. for sym in ["qt_plugin_instance", "qt_plugin_query_metadata_v2"] { println!("cargo:rustc-link-arg=-Wl,--undefined={sym}"); } - let dynlist = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("qt_plugin_exports.txt"); - println!("cargo:rerun-if-changed={}", dynlist.display()); + let vscript = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("qt_plugin_exports.txt"); + println!("cargo:rerun-if-changed={}", vscript.display()); println!( - "cargo:rustc-link-arg=-Wl,--dynamic-list={}", - dynlist.display() + "cargo:rustc-link-arg=-Wl,--version-script={}", + vscript.display() ); // Crane's deps-only build stubs out lib.rs and removes our bridge sources to diff --git a/plugin/qt_plugin_exports.txt b/plugin/qt_plugin_exports.txt index 321aafe..9747972 100644 --- a/plugin/qt_plugin_exports.txt +++ b/plugin/qt_plugin_exports.txt @@ -1,4 +1,5 @@ { - qt_plugin_instance; - qt_plugin_query_metadata_v2; + global: + qt_plugin_instance; + qt_plugin_query_metadata_v2; };