-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
dart compile exe support static linking of C code #47718
Comments
was just trying to figure out how to do this, this would be great, yes. |
Yes. That's what we need. Compile C/C++ libs together into a standalone executable. I come up with an idea that. In the future we can have a function called This feature can be only for |
Work underway for MacOS: https://dart-review.googlesource.com/c/sdk/+/228080 cc @sstrickl |
Also please make the linker configurable, cross linking with lld works on all platforms these days and would be nice to support in addition/instead of the system linker. |
We would like to address this using the static bindings with |
Rust, Golang and even Python can be built into one single exe without external lib dependencies, i.e. static exe. Dart please add this, something like |
@laoshaw
This issue is specifically about being able to do so when also link in static libraries into that executable when using Dart FFI. |
Yes, I would like |
This issue tracks statically linking in C libraries that package developers provide. Statically linking in the C runtime dependencies of the dart aot runtime would be a different project. @laoshaw do you have any issues with deployment depending on the C runtime libraries that are available? These libraries are always pre-installed on Linux. And bundling them would significantly increase the binary size of your final program. |
Doing this may already be a showstopper as it may break a number of things, see e.g. discussion here. I also recall that such statically linked binaries will have trouble opening dynamic libraries, which is something |
musl-gcc can link dart:ffi statically? still, in cases without dart::ffi, it would be nice to support static linking like how Go provides. that Golang static binary made deployment really easy, and will help to expand Dart's usage as well. |
https://dart.dev/tools/dart-compile:
A standalone executable that depended on a glibc with correct version being present at runtime is not what I expect when I hear "standalone executable". Given that this will not be "fixed" any time soon (no activity for 1.5 years) this should be clarified / added to known limitations. |
@rusty-snake Much to my chagrin, there are tons of "standalone" applications in the wild that depend on a specific C standard library being installed to function. Regardless, this issue is discussing statically linking against user-supplied C libraries at compile-time. @dcharkes Consider renaming this issue to reduce confusion. |
dart compile exe
enables compiling Dart source code to a standalone executable.It would be nice if we could link in static libraries in this process so that we can use
DynamicLibrary.executable()
to look up the symbols.Current workaround: Use shared libraries, use
DynamicLibrary.open()
with a relative path, and ship a folder with thedart compile exe
executable and the shared libraries (*.so
/*.dll
/*.dylib
).Technical work that needs to happen for this:
dart compile exe
use a proper format instead of appending the precompiled programing as a blob to the dart precompiled runtime by using a a proper linker on each target platform.(cc @mkustermann, @cskau-g I don't think we had an issue tracking this yet.)
The text was updated successfully, but these errors were encountered: