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 // nothing internal references those symbols (moc emits them as dlsym
// entry points), so the linker drops them entirely. --undefined=<sym> // entry points), so the linker drops them entirely. --undefined=<sym>
// anchors them past --gc-sections. // anchors them past --gc-sections.
// 2. Rust's cdylib link passes an explicit --version-script that exports // 2. Rust's cdylib link passes an explicit --version-script that lists Rust
// only Rust-public symbols - everything else, including our anchored C++ // public symbols under `global:` and ends with `local: *;`, hiding
// plugin symbols, is hidden as local. Neither --export-dynamic nor // everything else. --dynamic-list and --export-dynamic both lose to that
// --export-dynamic-symbol overrides an explicit version script. The fix // `local: *;`. Multiple --version-script flags merge per ld(1), and
// is --dynamic-list=<file>, which is additive: it appends entries to the // explicit `global:` entries override the wildcard local, so we pass a
// dynamic symtab without fighting the version script's hides. // second version script that adds the qt_plugin entry points.
for sym in ["qt_plugin_instance", "qt_plugin_query_metadata_v2"] { for sym in ["qt_plugin_instance", "qt_plugin_query_metadata_v2"] {
println!("cargo:rustc-link-arg=-Wl,--undefined={sym}"); println!("cargo:rustc-link-arg=-Wl,--undefined={sym}");
} }
let dynlist = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("qt_plugin_exports.txt"); let vscript = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("qt_plugin_exports.txt");
println!("cargo:rerun-if-changed={}", dynlist.display()); println!("cargo:rerun-if-changed={}", vscript.display());
println!( println!(
"cargo:rustc-link-arg=-Wl,--dynamic-list={}", "cargo:rustc-link-arg=-Wl,--version-script={}",
dynlist.display() vscript.display()
); );
// Crane's deps-only build stubs out lib.rs and removes our bridge sources to // Crane's deps-only build stubs out lib.rs and removes our bridge sources to

View file

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