plugin: anchor qt_plugin entry symbols past --gc-sections so qt finds them
This commit is contained in:
parent
bf5cb913fc
commit
d47200932d
1 changed files with 11 additions and 6 deletions
|
|
@ -1,12 +1,17 @@
|
||||||
use cxx_qt_build::{CxxQtBuilder, PluginType, QmlModule};
|
use cxx_qt_build::{CxxQtBuilder, PluginType, QmlModule};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Rust cdylib uses a version script that hides everything not declared
|
// cc-rs compiles with -ffunction-sections, Rust's cdylib link runs --gc-sections,
|
||||||
// `#[no_mangle] pub extern "C"`. cxx-qt's QQmlEngineExtensionPlugin entry
|
// and nothing internal references qt_plugin_instance/qt_plugin_query_metadata_v2
|
||||||
// points (qt_plugin_instance, qt_plugin_query_metadata_v2) come from
|
// - moc generates them as Qt's plugin entry points for dlopen, not for in-binary
|
||||||
// compiled C++ and would otherwise be stripped to local visibility, so Qt's
|
// calls. So the linker drops them entirely (verified: `nm libNovaStats.so | grep
|
||||||
// plugin loader finds nothing exported. --export-dynamic re-exposes them.
|
// qt_plugin_instance` returns nothing, only the static const inside the dropped
|
||||||
println!("cargo:rustc-link-arg=-Wl,--export-dynamic");
|
// function survives). --undefined anchors them past --gc-sections, then
|
||||||
|
// --export-dynamic-symbol exposes them for Qt's dlsym lookup.
|
||||||
|
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,--export-dynamic-symbol={sym}");
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
// build a dummy crate that only compiles dependencies. Skip cxx-qt codegen in
|
// build a dummy crate that only compiles dependencies. Skip cxx-qt codegen in
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue