plugin: switch dynamic-list to version-script (only the latter overrides local: *)

This commit is contained in:
Damocles 2026-05-03 22:58:04 +02:00
parent 3fae09b2b6
commit 8b73f3d692
2 changed files with 13 additions and 12 deletions

View file

@ -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=<sym>
// 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=<file>, 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

View file

@ -1,4 +1,5 @@
{
global:
qt_plugin_instance;
qt_plugin_query_metadata_v2;
};