-
Notifications
You must be signed in to change notification settings - Fork 599
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
Set the rpath to Qt for Rust binaries #797
Conversation
What do you think? Is this too controversial? :) |
I don't really like this hack and i whish there was better way. Then there is also the question whether the rpath should be set at all. This will break when shipping apps, wouldn't it? |
Me, too - FWIW.
I wish so, too - but you might also remember the discussion we had upstream...
Yes. Another option would be to create a different file per-backend, but I don't know how to determine which backends are actually linked in.
Yes, that's a valid question and I think it's a bit orthogonal since it applies to the qttypes crate as well. The create also unconditionally sets rpath for cdylib target crates. The current cargo behavior is inconsistent IMO:
Maybe (2) will be removed in the future, but that still leaves me thinking that (1) and (3) are not consistent with each other. I think that we can either try to work around this inconsistency or - alternatively - we should drop all special handling. That includes qttypes emitting cdylib-link-args with rpath. Users of SixtyFPS, regardless of C++ or Rust, will always have to set Instead we could try to invest time into enhancing tooling that facilitates creating bundles with relative rpaths on macOS (we don't have a deployment story there at all right now) and for Linux either adding relative rpaths or making it easy to create snaps/flatpacks. I was thinking that this approach would make life easier for existing users (since it's been reported before as an issue), especially in the light of us needing such a mechanism (propagating linker flags) for the mcu build. |
Right, in fact, the qttypes create is the crate that should somehow set the rpath. But unfortunately that's impossible :-( |
I am probably missing something since I never tried this in practice, but this is how I understood this to work in theory: A crate can export arbitrary metadata by just printing What am I missing? |
I think your observation is correct, this is also how I understand the meta-data handling works. |
The So what we have is a graph like this:
as you see, sixtyfps_backend_qt is not a direct dependency of sixtyfps_build. Not even a dependency at all. Ideally, since it is the |
So why do you need that file? qttypes has a build.rs script, so it can export the Our qt backend has another build.rs file, so that can read
The User programs directly depend on sixtyfps, shouldn't they just do the right thing if all the forwarding was implemented? |
How do user programs get the rpath into their rust link flags? |
I thought that
|
That's the problem: they don't. See the linked rust issue from the comment and the original issue. |
Ahhhh! I understood that the flags do not get passed on, but I had had read the issue to be limited to transitiv dependencies and had somehow assumed direct ones would be fine for some reason. Now this patch actually makes sense:-) |
Could you propagate the link flags up to the default rendering backend and have that export the file though? We would have one place to aggregate all the different linker flags then. |
I think that's a good idea. I discarded it earlier because the default backend wouldn't depend on the mcu backend (because we won't publish it for now), but that could be dealt with in a patch on top in the mcu branch. |
0776518
to
f6e7c12
Compare
For C++ apps we apply rpath to the cdylib implicitly via qttypes, but link flags for rust binaries are not transitively propagated but require explicit opt-in by the top-level crate. However we want that convenience, to avoid Rust apps having to deal with Qt backend specific code in their build.rs. Therefore we use the _DEP mechanism to get the qt library path from the qttypes crate, forward it to the default backend crate and write it into a generic file in the qt backend's build.rs, which is then picked up by sixtyfps-build. In the future, we'll use the same mechanism to propagate link flags and extend the linker serach path for the MCU build (such as the linker script). cc #566
f6e7c12
to
bc8fd2f
Compare
Another reason why not do this is that this doesn't work with the |
Ok, so we're back to feature flags in the public sixtyfps-build crate for the MCU then :( (which also doesn't work with the macro, but that's a different topic) Shall I make changes to qttypes to remove the rpath emission there? |
For C++ apps we apply rpath to the cdylib implicitly via qttypes, but
link flags for rust binaries are not transitively propagated but require
explicit opt-in by the top-level crate. However we want that
convenience, to avoid Rust apps having to deal with Qt backend specific
code in their build.rs. Therefore we use the _DEP mechanism to get the
qt library path from the qttypes crate and write it into a generic file
in the qt backend's build.rs, which is then picked up by sixtyfps-build.
We'll use the same mechanism to propagate link flags for the MCU build
(such as the linker script).
cc #566