Can mill native launcher be statically linked? #5568
Replies: 7 comments 4 replies
-
Mill delegates the native image building to Graal. Perhaps you could try following https://www.graalvm.org/latest/reference-manual/native-image/guides/build-static-executables/ and adding |
Beta Was this translation helpful? Give feedback.
-
Building a native executable with $ git diff
diff --git a/dist/package.mill b/dist/package.mill
index fc069e6357c..5012e87e684 100644
--- a/dist/package.mill
+++ b/dist/package.mill
@@ -306,7 +306,8 @@ object `package` extends MillJavaModule with DistModule {
def nativeImageOptions = Seq(
"--no-fallback",
"--enable-url-protocols=https",
- "-Os"
+ "-Os",
+ "--static-nolibc"
// Enable JVisualVM support
// https://www.graalvm.org/latest/tools/visualvm/#using-visualvm-with-graalvm-native-executables
// "--enable-monitoring=jvmstat,heapdump" @jackkoenig probably need you to try it out and see if it fixes the problem in your environment, if it does then we can just turn it on by default |
Beta Was this translation helpful? Give feedback.
-
Hey @lihaoyi, I did some digging and here is what I figured out and think. I think That doesn't actually solve my original problem though, as it specifically is the system libraries like libc that cause issues on older Linux distributions. For circt/firtool we fully statically link using musl libc1. I am not certain if a fully statically linked binary should be the default as there is disagreement about that, but it's worth considering. Another option that might be simpler would be to have the Mill boostrap script check the system's glibc version (at least on Linux). If it's new enough then it can fetch the native binary, if it isn't, then it can fall back to the JVM client. My main concern is Chisel users (who as I mentioned are often on older Linux distros) following default Mill instructions and being confused. I could add Footnotes
|
Beta Was this translation helpful? Give feedback.
-
I ran into the same issue as @jackkoenig on a Ubuntu 20.04 installation. Getting the following error when trying to run Mill 1.0.5:
|
Beta Was this translation helpful? Give feedback.
-
In Scala CLI and coursier, the native Linux launchers are built from docker. This allows to build them from Ubuntu 20.04 for example, which generates launchers that work all the way back to Ubuntu 20.04. This is setup in the build like this, using my mill-native-image plugin. |
Beta Was this translation helpful? Give feedback.
-
I'm kind of surprised (and suspicious) that |
Beta Was this translation helpful? Give feedback.
-
Apologies, I always wanted to follow up on this but always struggling to find the time. A couple of observations from doing this with llvm/circt for similar reasons:
Those latter two points may be of less concern to the Mill client, but I think are worth getting right. It is my understanding that the Rust community follows this advice (it uses muslc, sets default stack size to 2 MiB, and uses mimalloc). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In the hardware industry, it's common to have an older Linux distro, e.g. RHEL8 is really common which will gives the following linkage error when trying out Mill 1.0.0.
This can be worked around by using the JVM version of the client, but it would be nice if the client could be statically linked.
Beta Was this translation helpful? Give feedback.
All reactions