-
Notifications
You must be signed in to change notification settings - Fork 6k
[Desktop][Linux] Add RUNPATH $ORIGIN to flutter_linux_gtk #28525
Conversation
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.
/cc @cbracken
It seems reasonable to have a default here, but shouldn't we also override this to $ORIGIN/lib/
in the install step in the template so that just loading the library by name works?
Thanks for the quick review!
Using The install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime) I'd need to do some more digging on how to teach CMake to change the Edit: I do not see such functionality in https://cmake.org/cmake/help/latest/command/install.html#files. |
Isn't
I've swapped this out from when I did all the CMake setup, but IIRC CMake automatically does rpath adjustment during the install phase. IIRC that's part of why I used it to do the bundling. |
Apparently it is the dynamic library. (At least that is my conclusion after experimenting with this and seeing
CMake only does RPATH for non-IMPORTED libraries/executables as far as I can see. And we're building this library in GN/ninja and there we don't have an install step afaik. |
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.
Isn't
$ORIGIN
always the executable? I'm having trouble finding much documentation, but it sounds like that's its behavior.Apparently it is the dynamic library. (At least that is my conclusion after experimenting with this and seeing
$ORIGIN/lib
fail in the dynamic library. I also could not find a lot of documentation.)
Interesting. Well, that renders the CMake question moot, so LGTM.
When using
dart:ffi
'sDynamicLibrary.open(...)
, theRUNPATH
ofbundle/lib/libflutter_linux_gtk.so
is used rather thanbundle/flutter_app
.libflutter_linux_gtk.so
did not have aRUNPATH
set, makingdlopen
only succeed on absolute paths and dynamically linked libraries. SettingRUNPATH
enables us to dynamically load shared libraries without dynamically linking them upfront.With this fix, the
${plugin}_bundled_libraries
can work without modifying a flutter app:${plugin}/linux/CMakeLists.txt
Before this fix, we also needed to modify a
flutter_app
to dynamically link the libraries:${flutter_app}/linux/CMakeLists.txt
This
flutter_app
modification is obsolete after this PR.Tested locally with this patch and
flutter --local-engine=host_release --local-engine-src-path=$HOME/flt/engine/src run linux
.Change can be observed with
readelf -d flutter_app/build/linux/x64/release/bundle/lib/libflutter_linux_gtk.so | grep RUNPATH
.Relevant issues: flutter/flutter#78819 (comment) and dart-archive/ffi#118.
Pre-launch Checklist
writing and running engine tests.
///
).