Skip to content

Instantly share code, notes, and snippets.

@DavidGregory084
Last active August 1, 2018 12:33
Show Gist options
  • Save DavidGregory084/7cddf7d41acafc5502131b55d88cfab0 to your computer and use it in GitHub Desktop.
Save DavidGregory084/7cddf7d41acafc5502131b55d88cfab0 to your computer and use it in GitHub Desktop.
mill-native-image.diff
2 files changed, 14 insertions(+), 10 deletions(-)
build.sc | 6 ++----
main/client/src/mill/main/client/MillClientMain.java | 18 ++++++++++++------
modified build.sc
@@ -112,11 +112,9 @@ object main extends MillModule {
}
object client extends MillPublishModule{
+ def mainClass = Some("mill.main.client.MillClientMain")
def ivyDeps = Agg(
- ivy"org.scala-sbt.ipcsocket:ipcsocket:1.0.0".exclude(
- "net.java.dev.jna" -> "jna",
- "net.java.dev.jna" -> "jna-platform"
- )
+ ivy"org.scala-sbt.ipcsocket:ipcsocket:1.0.0"
)
object test extends Tests{
def testFrameworks = Seq("com.novocode.junit.JUnitFramework")
modified main/client/src/mill/main/client/MillClientMain.java
@@ -1,6 +1,8 @@
package mill.main.client;
-import org.scalasbt.ipcsocket.*;
+import org.scalasbt.ipcsocket.UnixDomainSocket;
+
+import com.sun.jna.Platform;
import java.io.*;
import java.net.Socket;
@@ -11,7 +13,8 @@ import java.util.*;
public class MillClientMain {
static void initServer(String lockBase, boolean setJnaNoSys) throws IOException,URISyntaxException{
- String[] selfJars = System.getProperty("MILL_CLASSPATH").split(",");
+ String[] selfJars = new String[] { "/Users/davidgregory/Repos/mill/out/release/dest/mill" };
+ //System.getProperty("MILL_CLASSPATH").split(",");
List<String> l = new ArrayList<>();
List<String> vmOptions = new ArrayList<>();
@@ -47,6 +50,7 @@ public class MillClientMain {
.start();
}
public static void main(String[] args) throws Exception{
+ System.loadLibrary(Platform.C_LIBRARY_NAME);
System.exit(main0(args));
}
public static int main0(String[] args) throws Exception{
@@ -105,7 +109,7 @@ public class MillClientMain {
try(FileOutputStream f = new FileOutputStream(lockBase + "/run")){
f.write(System.console() != null ? 1 : 0);
- Util.writeString(f, System.getProperty("MILL_VERSION"));
+ Util.writeString(f, "0.2.6-2-f19824"); // System.getProperty("MILL_VERSION"));
Util.writeArgs(args, f);
Util.writeMap(env, f);
}
@@ -127,10 +131,12 @@ public class MillClientMain {
while(ioSocket == null && System.currentTimeMillis() - retryStart < 1000){
try{
- ioSocket = Util.isWindows?
- new Win32NamedPipeSocket(Util.WIN32_PIPE_PREFIX + new File(lockBase).getName())
- : new UnixDomainSocket(lockBase + "/io");
+ // ioSocket = Util.isWindows?
+ // new Win32NamedPipeSocket(Util.WIN32_PIPE_PREFIX + new File(lockBase).getName())
+ // : new UnixDomainSocket(lockBase + "/io");
+ ioSocket = new UnixDomainSocket(lockBase + "/io");
}catch(Throwable e){
+ e.printStackTrace();
Thread.sleep(1);
}
}
$ echo $MILL_JAR
/Users/davidgregory/Repos/mill/out/release/dest/mill
$ /Users/davidgregory/Downloads/graalvm-ee-1.0.0-rc4/Contents/Home/bin/native-image -H:CLibraryPath=/usr/lib -H:+JNI -cp /Users/davidgregory/Repos/mill/out/main/client/assembly/dest/out.jar -DMILL_CLASSPATH=$MILL_JAR -DMILL_VERSION=0.2.6-2-f19824 mill.main.client.MillClientMain
Build on Server(pid: 32757, port: 59547)
classlist: 421.98 ms
(cap): 1,136.67 ms
setup: 1,745.67 ms
(typeflow): 3,518.00 ms
(objects): 956.55 ms
(features): 34.57 ms
analysis: 4,580.52 ms
universe: 183.45 ms
(parse): 1,039.45 ms
(inline): 748.14 ms
(compile): 6,545.11 ms
compile: 8,560.97 ms
image: 640.27 ms
write: 682.57 ms
[total]: 16,851.96 ms
$ time ./mill.main.client.millclientmain _.compile
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.lang.Throwable.<init>(Throwable.java:310)
at java.lang.Exception.<init>(Exception.java:102)
at java.lang.ReflectiveOperationException.<init>(ReflectiveOperationException.java:89)
at java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:72)
at com.oracle.svm.reflect.proxies.Proxy_20_MillClientMain_main.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:173)
Caused by: java.lang.UnsatisfiedLinkError: /Users/davidgregory/Repos/mill/libc.dylib: dlopen(/Users/davidgregory/Repos/mill/libc.dylib, 1): image not found
at java.lang.Throwable.<init>(Throwable.java:265)
at java.lang.Error.<init>(Error.java:70)
at java.lang.LinkageError.<init>(LinkageError.java:55)
at java.lang.UnsatisfiedLinkError.<init>(UnsatisfiedLinkError.java:54)
at com.oracle.svm.core.posix.PosixNativeLibrarySupport$PosixNativeLibrary.load(PosixNativeLibraryFeature.java:96)
at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibrary0(NativeLibrarySupport.java:148)
at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibrary(NativeLibrarySupport.java:109)
at com.oracle.svm.core.jdk.Target_java_lang_ClassLoader.loadLibrary(Target_java_lang_ClassLoader.java:117)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at com.oracle.svm.core.jdk.Target_java_lang_Runtime.loadLibrary(JavaLangSubstitutions.java:235)
at com.oracle.svm.core.jdk.Target_java_lang_System.loadLibrary(JavaLangSubstitutions.java:382)
at mill.main.client.MillClientMain.main(MillClientMain.java:53)
... 3 more
./mill.main.client.millclientmain _.compile 0.00s user 0.01s system 42% cpu 0.031 total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment