How to build a statically linked native executable #3142
rusty-snake
started this conversation in
General
Replies: 1 comment 2 replies
-
I'm not sure why it might not be working for you. In general it should work, but would be depending on the used libraries and environment on which we're building. Here's one example from gitpod (linux) env: scala --power package -f --native -o hello sandbox/src/main/scala/Test.scala --native-linking=-static --native-compile=-static
Compiling project (Scala 3.5.0, Scala Native 0.5.4)
Compiled project (Scala 3.5.0, Scala Native 0.5.4)
...
[info] Linking with [pthread, dl]
[error] clang++: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
[info] Linking native code (immix gc, none lto) (212 ms)
[info] Postprocessing (0 ms)
[info] Total (12614 ms)
Wrote /workspace/scala-native/hello, run it with
./hello
gitpod /workspace/scala-native (main) $ ./hello
Hello, World!
gitpod /workspace/scala-native (main) $ ldd ./hello
not a dynamic executable
gitpod /workspace/scala-native (main) $ file ./hello
./hello: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=23276673357367558b823759e485502ed9fbf239, for GNU/Linux 3.2.0, not stripped I'm aware of issues on MacOS when compiling with I believe their logs are missing something that would hint why the build failed. For example, here's what I get when building on MacOS:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What I'm trying to do:
I want a native app (i.e.
scc --power package [-f] --native [--native-mode=release-fast --native-lto=thin] -o hello hello.sc
) that is statically linked (I only are about Linux, special dependencies on e.g. MacOS are not relevant).I tried with combinations of
--native-compile="-static"
,--native-linking="-static"
,--native-target=static-app
. However they either fail to build or the result is still dynamically linked.Is it possible to build a statically linked app?
If yes, how¹?
If no, is it realistic to get support for it? Should I open a feature request?
build error
¹ W/o creating a dedicated musl/alpine build environment.
Beta Was this translation helpful? Give feedback.
All reactions