-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-Crate project - second try #1178
Multi-Crate project - second try #1178
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1178 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 73 73
Lines 12438 12438
=========================================
Hits 12438 12438 ☔ View full report in Codecov by Sentry. |
14e1d29
to
b8b5603
Compare
d8e4664
to
89c2cd7
Compare
This isn't required for the libraries published to crates.io, so this isn't specified in the workspace Cargo.toml.
No need to change the privacy of these; just need to have the symbols referenced within the staticlib crate.
This also adds cxx_qt::init_crate! and init_qml_module!
Previously, downstream QML modules weren't exported. This should now be fixed, as QML modules are always exported.
qml_multi_crates is the grand finale in our quest for CMake&Cargo compatibility. It is a project that can be built as a Cargo lib and binary, as well as imported into CMake with a C++ binary and uses multiple Cargo crates internally. It does rely on the init_crate! and init_qml_module! macros, but otherwise works quite seamless.
89c2cd7
to
5a82863
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, lets go with this :-)
Wow, good job finally figuring out this cursed puzzle! |
Next we need to ensure the initializers can be found by the linker. | ||
|
||
If you followed step 1, modern linkers like `mold` or `lld` should already be able to link everything correctly. | ||
We encourage switching to such a linker if you're still using the (now deprecated) `ld.gold` on Linux. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ld.bfd
is still the default linker on most distros?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be worth mentioning here that CXX-Qt will automatically prefer lld or mold if they are installed, and also that the linker can be configured for all Rust builds by putting
[target.x86_64-unknown-linux-gnu] # or whatever target
rustflags = [
"-C", "link-arg=-fuse-ld=mold"
]
in ~/.cargo/config.toml.
I just tested the main branch with ld.bfd and ld.gold, and with the recent changes, cargo build -p qml-minimal-no-cmake
links successfully. cargo build -p qml_multi_crates
works with all linkers, but if I comment out cxx_qt::init_crate!(qml_multi_crates);
then ld.bfd and ld.gold both fail.
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn initialize_eependencies() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who needs dependencies when you can have eependencies? 😀
A combination of #598 and #1169.
Closes #598
Closes #148
Closes #1135