clojure and robovm for binary executables? - clojure

I'm interested in compile clojure code to native app with robovm, similar to scala https://github.com/roboscala/roboscala-samples
I need run small scripts, create a native binary could help me to avoid a big jvm which consume a lot of resources and with slow start up, basically I dont need the nice oracle jvm performance, but I wish use a clean and simple language as clojure
Is possible run clojure in robovm similar to how scala do?..or the dynamic nature of clojure makes it impossible?...
I've found this lein plugin but it only allows compile to iOS and I wish use clojure and robovm for desktop apps
following the tutorial this start good but fails at the end
https://github.com/robovm/robovm/wiki/Get-started-on-Linux
a lot of compiled code here......................
Compiling clojure.lang.Var (linux x86 release)
Compiling clojure.lang.ARef (linux x86 release)
Compiling clojure.lang.IRef (linux x86 release)
Compiling clojure.lang.Settable (linux x86 release)
Compiling clojure.lang.Var$1 (linux x86 release)
Compiling clojure.lang.Var$2 (linux x86 release)
Compiling clojure.lang.Var$3 (linux x86 release)
Compiling clojure.lang.Var$Frame (linux x86 release)
Compiling clojure.lang.Var$TBox (linux x86 release)
Compiling clojure.lang.Var$Unbound (linux x86 release)
Compiled 666 classes in 78.42 seconds
Linking 1971 classes
Building executable /tmp/robovm5738725927760604511.tmp/robotry.core
g++ -o /tmp/robovm5738725927760604511.tmp/robotry.core -m32 #/tmp/robovm5738725927760604511.tmp/objects -L /home/yo/Downloads/proj/robovm-1.0.0-alpha-04/lib/vm/linux/x86 -Wl,-rpath=$ORIGIN -Wl,--gc-sections -lrobovm-bc -Wl,--whole-archive -lrobovm-rt -Wl,--no-whole-archive -lrobovm-debug -lrobovm-core -lgc -lpthread -ldl -lm -lrt
Linked 1971 classes in 223.52 seconds
/tmp/robovm5738725927760604511.tmp/robotry.core -rvm:log=warn
java.lang.ExceptionInInitializerError
at clojure.lang.Namespace.<init>(Namespace.java)
at clojure.lang.Namespace.findOrCreate(Namespace.java)
at clojure.lang.Var.internPrivate(Var.java)
at robotry.core.<clinit>(Unknown Source)
Caused by: java.lang.UnsupportedOperationException: can't load this type of class file, compiling:(clojure/core.clj:29:7)
at clojure.lang.Compiler.analyzeSeq(Compiler.java)
at clojure.lang.Compiler.analyze(Compiler.java)
at clojure.lang.Compiler.access$100(Compiler.java)
at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java)
at clojure.lang.Compiler.analyzeSeq(Compiler.java)
at clojure.lang.Compiler.analyze(Compiler.java)
at clojure.lang.Compiler.analyze(Compiler.java)
at clojure.lang.Compiler.eval(Compiler.java)
at clojure.lang.Compiler.load(Compiler.java)
at clojure.lang.RT.loadResourceScript(RT.java)
at clojure.lang.RT.loadResourceScript(RT.java)
at clojure.lang.RT.load(RT.java)
at clojure.lang.RT.load(RT.java)
at clojure.lang.RT.doInit(RT.java)
at clojure.lang.RT.<clinit>(RT.java)
... 4 more
Caused by: java.lang.UnsupportedOperationException: can't load this type of class file
at java.lang.ClassLoader.defineClass(ClassLoader.java)
at clojure.lang.DynamicClassLoader.defineClass(DynamicClassLoader.java)
at clojure.lang.Compiler$ObjExpr.getCompiledClass(Compiler.java)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java)
... 19 more
anyone has had luck compiling clojure with robovm?..are the some resources or tutorial about how achieve this?..thanks!

Related

Compilation flags to build runtime on linux machines

What compiler flags are used to build standard c/c++ libraries like glibc and libstdc++?
Are they same across the distributions like debian, fedora, archlinux etc?
On debian machines there is dpkg-buildflags but I'm not sure if they are overridden for critical runtime libraries.
The one common factor is -O2, with -O2 -g (enabling gdb debugging symbols) being the most common. -O2 is definitely the expected optimization level maintainers assume packages should be compiled at.
If you look at debian/rules in Debian source packages (or -debian.tar.* tarballs), you'll usually find HOST_CFLAGS and HOST_CXXFLAGS describing the C and C++ compiler flags used when the source package is built using Debian tools.
This is documented in for example the man 1 dpkg-buildflags man page: "The default value set by the vendor includes -g and the default optimization level (-O2 usually, or -O0 if the DEB_BUILD_OPTIONS environment variable defines noopt)."
Outside Debian, Gentoo recommends -O2 -pipe and a -march= for the current architecture. (The -pipe option tells GCC to use pipes instead of temporary files during the build, which is usually faster but uses more RAM, during the build. It has no effect on the compiled binaries.)
Embedded systems like OpenWRT often use -Os instead, to generate smaller binaries.

Is it possible to run CUDA program or library without CUDA driver installed?

Suppose I have a laptop with nvcc and CUDA Toolkit installed, and a network of 16 PCs with Nvidia GPUs and MPI. The PCs aren't aware of CUDA, they just have regular Nvidia drivers and supporting software.
I'd like to develop an MPI application for this network. The PCs are going to acquire tasks via MPI and use their GPUs to do these tasks. I plan to develop the CUDA part on my laptop, compile it in a static library and later link this static library at a PC using mpicxx compiler.
However, I can't find any evidence that such deployment is possible. On the contrary, most of the examples of so called separate compilation require CUDA installed for the final step (linking CUDA-aware static library with MPI-aware main program):
$ g++ main.cpp -L. -lgpu -o main -L/usr/local/cuda/lib64 -lcudart
So, is it possible to compile a program or library that uses CUDA and doesn't have any dependencies like installed drivers and CUDA libs?
everything should work if you deploy cuda runtime dynamic libraries along with your executable.
At the same time, ensure you have a recent enough driver installed on the target machine.

Cross compile google v8 library for raspberry pi

I am having a problem with cross compiling google v8 libraries for raspberry pi, and constantly getting "Illegal instruction" error when compiling official sample from site. These are the steps i followed:
Downloaded cross compile https://github.com/raspberrypi/tools/
Cloned v8 git https://chromium.googlesource.com/v8/v8.git
Exported CXX LINK point to arm-linux-gnueabihf-g++ from cross compile tools.
run make arm.release armv7=false hardfp=on snapshot=off armfpu=vfp armfloatabi=hard -j5
Copied generated executable shell and d8 from out/arm.release directory to pi (Raspbian kernel version 3.6.11) and it WORKS.
These steps prove that cross compilation toolchain is functional.
Problem occurs when trying to run other cross-compiled software that is linked to v8 libraries. For example sample code from https://developers.google.com/v8/get_started#intro.
Code is cross-compiled with this command (same as example, just changed compiler)
arm-linux-gnueabihf-g++ -I. hello_world.cc -o hello_world -Wl,--start-group out/x64.release/obj.target/{tools/gyp/libv8_{base,libbase,snapshot,libplatform},third_party/icu/libicu{uc,i18n,data}}.a -Wl,--end-group -lrt -pthread
When i copy that code to pi and run it i get SIGILL (Illegal instruction).
Note: cross compiled software that doesn't use v8 libraries works fine. Also x64 v8 libraries on host computer work fine.
On newer kernel versions shell and d8 were also throwing SIGILL but than i switched to older version 3.6.11 (problems with newer kernel https://groups.google.com/forum/#!topic/v8-users/IPT9EeYK9bg) and they started working, but compiled sample code is still showed same issues.
Did anyone have similar experience? Any suggestion on how to overcome this problem?
I found a solution thanks to post on v8 google group. https://groups.google.com/forum/#!topic/v8-users/LTppUbqNrzI
Problem was in make arguments it should be.
make arm arm_version=6 armfpu=vfp armfloatabi=hard

Compiling boost as i386 on AMD64 (Ubuntu 11.10)

I'm currently programming an extension to a program, which only supports
i386 (and I am running amd64 Ubuntu 11.10). Whenever I compile my extension source
I need to use the -m32 flag to force 32 bit architecture (otherwise the program will not be able to load my extension). Sooner or later it is inevitable to avoid boost
thanks to its huge and stable library, which leads to my problem.
I want to use the boost filesystem, which uses OS specific function calls, which in turn leads to the requirement of a library file instead of only a header implementation. The problem is; I can't/don't know how to setup the boost filesystem (i386 version) on my amd64 machine. If I download a prebuilt (.deb) package for i386 and install it using -force-architecture it still fails complaining about dependencies.
So basically; how do I setup boost with 32bit (i386) architecture on my (amd64) system?
It seems as if I did it right all along but I was too dumb to realize how to properly link libraries with the GCC linker, coming from a Windows environment. You can easily compile boost libraries by using the -m32 flag and by setting up bjam properly. See the first answer in this question for details: How do I force a 32 bit build of boost with gcc?

Compiling my C++ code for ARM Architecture

I am a java developer. I have some C++ code to make some system realted calls. This code is compiled on Intel 32-bit platform using GCC (I have make files) and it works fine on regular Intel based 32-bit linux machine. Now I need to run this on a linux OS running on Marvell ARM processor. When I load the shared objects in java I get the following error.
cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)
Please tell me how to resolve this issue. I looked at the GCC options and I found one option to specify the architecture (-march=armv5) and I can't compile with that option.
Thanks in advance.
You need more than just a switch, you need a cross-compiler. You can make your own, but probably the easiest way is :
Find the development tools for your board. It probably comes with a development kit that includes a cross-compilation toolchain
If you don't have these, you can try to install a precompiled cross-compilation like the ones provided freely by CodeSourcery
Then you have to make the location of your toolchain (look for something like arm-none-linux-gnueabi-gcc) available in your path.
Cross compiling simple project is then easy, just override the CC variable in your Makefile :
CROSS = arm-none-linux-gnueabi-
CC = $(CROSS)gcc
LD = $(CROSS)ld
Try using the -mcpu=armv5 switch for gcc.
Here is what's written on http://elinux.org/RPi_Software#ARM:
-Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s