Substrate VM: Unable to launch the native image generator - graalvm

I wanted to check out the mx image generator:
./mx image -cp $PWD/svmbuild -H:Class=HelloWorld -H:Name=helloworld
mx: unknown command 'image'
It seems that the "image" command is not available (anymore?)
Any replacement available?
Thanks

There's an mx native-image command.
The README file in the GraalVM project repository lists the following quick start snippet:
cd substratevm
mx build
echo "public class HelloWorld { public static void main(String[] args) {
System.out.println(\"Hello World\"); } }" > HelloWorld.java
$JAVA_HOME/bin/javac HelloWorld.java
mx native-image HelloWorld
./helloworld
Allegedly, one needs a JDK 8 with the JVMCI for this to work, here's a relevant quote from the README:
Install mx and point JAVA_HOME to a labsjdk.
For compilation native-image depends on the local toolchain, so make
sure: glibc-devel, zlib-devel (header files for the C library and
zlib) and gcc are available on your system.

Related

How to get the library paths of a meson dependency?

Use case: I have a dependency that falls back to a subproject:
./
./subprojects/
./subprojects/mylib.wrap
src/meson.build contains:
mylib_dep = dependency('mylib') # Searches for mylib with pkg-config then fall backs to mylib.wrap.
myexec_exe = executable ('myexec', 'myexec.c', dependencies : mylib_dep)
Dependency mylib_dep provides libraries, which, if not installed on the system, make the main executable of my project unusable:
$ meson build && cd build && meson compile src/my_exec
...snip'd...
$ src/my_exec
src/my_exec: error while loading shared libraries: libmylib.so: cannot open shared object file: No such file or directory
My testing script build/tests/mytests.sh is configure_filed from tests/mytests.sh.in to indicate the location of myexec, and I'd like to pass to it the library paths, so that it can adjust LD_LIBRARY_PATH and run the executable. For instance, in tests/meson.build:
conf_data = configuration_data ()
conf_data.set_quoted ('MYEXEC_PATH', myexec_exe.full_path ())
conf_data.set_quoted ('MYLIB_PATH', mylib_dep.??????)
mytest_exe = configure_file (input : 'mytests.sh.in', output : 'mytests.sh', configuration : conf_data)
and in tests/mytests.sh.in:
MYEXEC_PATH=#MYEXEC_PATH#
MYLIB_PATH=#MYLIB_PATH#
export LD_LIBRARY_PATH=$(dirname "$MYLIB_PATH"):$LD_LIBRARY_PATH
$MYEXEC_PATH
Question: What should go at the ?????? above? In other words, given a dependency object, how can I extract the libraries within it, and get their full paths?
Usually in meson you wouldn't configure_file this, you'd pass the library/executable(s) to the script as arguments in the test command:
test(
'mytest',
find_program('mytest.sh')
args : [executable_target, library_target, ...],
)
It can be frustrating trying to get this sort of info out of Meson. Fortunately, if Meson used CMake to find the dependency, you may be able to get the library path from the underlying CMake variables, which are available in the Meson dependency object. Eg, something along the following lines worked for me:
mylib_dep = dependency('mylib')
if mylib_dep.found()
mylib_path = mylib_dep.get_variable(default_value : '', cmake : 'PACKAGE_LIBRARIES')
message('Library path is:', mylib_path)
endif

Unable to build the library using cargo lipo --release

Unable to build the library using cargo lipo --release
I am trying to make a cross-platform library using rust for ios target. I am following this article (Building and Deploying a Rust library on iOS).
*Note: I followed the same steps and my project structure also looks the same *
After completing the code and project setup the last step is to build the library. When I try to build the library using cargo lipo --release. It throws this error:
[ERROR cargo_lipo] No library target found for "my-project-name"
Also, note that I am only able to install support for two platforms. (aarch64-apple-ios and x86_64-apple-darwin). I think the reason is that they have dropped the support for 32-bit architectures.
So, when I run
rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i386-apple-ios.
It throws error: error: component 'rust-std' for target 'armv7-apple-ios' is unavailable for download for channel stable
Cargo.toml
[package]
name = "rustylib"
version = "0.1.0"
edition = "2018"
crate-type = ["staticlib", "cdylib"]
rustylib.rs
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
char *hello(const char *to);
void hello_release(char *s);
The rest of the project structure is the usual rust code.
The output of rustup show
Default host: x86_64-apple-darwin
rustup home: /Users/my-username/.rustup
installed toolchains
stable-x86_64-apple-darwin
nightly-x86_64-apple-darwin (default)
installed targets for active toolchain
aarch64-apple-ios
x86_64-apple-darwin
active toolchain
nightly-x86_64-apple-darwin (default)
rustc 1.52.0-nightly (acca81892 2021-03-13)
OS & Rust
Rust: rustc 1.50.0 (cb75ad5db 2021-02-10)
OS: macOS Bug Sur (11.2.3)
Xcode & Command line tools: 12.4
Your Cargo.toml is wrong.
If you look into the guide you linked in your question, you can see, that the crate-type has to be below the [lib] tag like so:
[package]
name = "greetings"
version = "0.1.1"
authors = ["fluffyemily <fluffyemily#mozilla.com>"]
description = "Example static library project built for iOS"
publish = false
[lib]
name = "greetings"
crate-type = ["staticlib", "cdylib"]
Also your code has to be in cargo/src/lib.rs by default as stated in the document (and not in rustylib.rs).
You can run cargo new rustylib --lib from the command line to create all the boilerplate, so that you only have to add the dependencies and the crate-type in the [lib] section of your Cargo.toml.
Edit
I think there is another problem:
You have entered C code in your rustylib.rs file, which can not work. I think what you intended to do, was to create the C bridge, which is called cargo/src/greetings.h in the guide you linked.

Sourcecode not found by Javac - windows

I am new to java programming and I am learning the basics.
I am trying to use the java compiler (javac) via the windows Command Prompt for running a first "Hello World!" program. These are the steps I undertook:
1) I have created a file with Notepad with the following code:
public class Hello {
public static void main(String[] argumente) {
System.out.println("Hello World!");
}
}
2) I saved it as Hello.java in the following folders/ directories:
C:\Users\Ema\eclipse-workspace\classes
3) I opened the Windows 10 Command Prompt and inputted the following code:
C:\Users\Ema>javac -Xlint:all Hello.java
unfortunately I get this answer back when I "enter" the code line:
error: file not found: Hello.java
Usage: javac
use --help for a list of possible options
Could you please help me with some tips on how to run the program?
I have also already tried to give the targeted path via the javac -cp function, but I get always the same type of error.
Thank you in advance

What Parameter set is correct for translating Java files to pascal units with Java2OP

My goal is to translate a Java Project (3 .java files) to .pas files with Embarcadero's Java2OP tool.
I'm using it via cmd, started in the java2op directory. After several unsuccessful tries, and a lot of time of googling, I am frustrated.
Commands in the documentation:
Input Options
-------------
-classes Space-separated list of names of classes or packages to export. -classes lets
you define a specific subset of the specified Java sources (-jar or -source options)
or the Android API.
-jar Space-separated list of input Java compiled libraries (.jar files).
-source Space-separated list of input folders containing Java source files (.java files).
Output Options
--------------
-unit File name of the output unit.
Default: Android.JNI.Interfaces
Examples
--------
Exporting some classes and packages from the Android API:
Java2OP.exe -classes android.net.ConnectivityManager android.location.*
Exporting all classes from mylib.jar:
Java2OP.exe -jar mylib.jar
Exporting a single class from mylib.jar:
Java2OP.exe -jar mylib.jar -classes com.mypackage.ClassName
Exporting all the classes from a folder of Java sources specifying the
file name of the output Delphi unit:
Java2OP.exe -source myproject/src -unit Android.JNI.UnitName
My commands:
java2op.exe -src A:\Tests -unit Android.JNI.TestFile
So it matches the guidelines:
Java2OP.exe -source myproject/src -unit Android.JNI.UnitName
If I try to change -src to the suggested -source, I get the following error:
Invalid option: -source
After executing the command, 1 error occurs:
Command: javadoc -J-Xmx1024m -encoding "UTF-8" -sourcepath "A:\java2op\Java"
-subpackages "" -classpath "" -bootclasspath "A:\java2op\bootclasses.jar" -docletpath "A:\java2op\doclava.jar"
-doclet com.google.doclava.Doclava -nodocs -public -apixml "A:\java2op\temp.xml"
Output: javadoc: error - Illegal package name: "" 1 error
I read the following post about the same issue:
How can I extract a Delphi class from this JAVA file for use with Android?
but without success.
What am I missing or doing wrong?

How to write Hello World for OpenWRT and/or dd-wrt

I'm working on running a Hello World program on the Linksys WRT54G-V4 running either dd-wrt or OpenWRT.
Right now this router is running dd-wrt for reasons I'll explain below. I'd like to switch this router to OpenWRT, because I've not been able to build dd-wrt or its toolchain. I 'assume' that the OpenWRT toolchain should produce executable binaries that will run on dd-wrt also.
OpenWRT was pretty straightforward to build, since it has a nice menu driven make system. Using this handy tool I built a toolchain that will cross compile from my x86 Ubuntu box to a MIPS target.
Following the instructions I've been able to build OpenWRT and produce images for brcm47xx and brcm63xx.
For example, here is a successful compile of my little Hello World program:
jim#ubuntu:~/Desktop/tests$ cat helloC.c
#include <stdio.h>
int main (int argc, char **argv)
{
printf("Hello World\n");
return 0;
}
jim#ubuntu:~/Desktop/tests$
jim#ubuntu:~/Desktop/tests$ mipsel-openwrt-linux-gcc -o HelloWorld helloC.c
jim#ubuntu:~/Desktop/tests$
jim#ubuntu:~/Desktop/tests$ file HelloWorld
HelloWorld: ELF 32-bit LSB executable, MIPS, MIPS32 version 1, dynamically linked (uses shared libs), with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x3040000, not stripped
jim#ubuntu:~/Desktop/tests$
Sadly, when I try to run HelloWorld on my WRT54G-V4 running dd-wrt I get a seg fault.
Looking at Wikipedia, I see that this router uses the Broadcom BCM5352.
When I run make menuconfig in by OpenWRT/trunk directory I don't see an option for the BCM5352, which is why I'm reluctant to flash my router with one of the images I've created in the brcm47xx or brcm63xx directories. I don't want to guess wrong and brick the router.
Question 1 - Which Broadcom configuration should I select using make menuconfig to target my WRT54G-V4 with its BCM5352 chipset?
Question 2 - Should my 'HelloWorld' executable file I generated above run directly from the command line on the 54G, or must I make it a package per http://www.gargoyle-router.com/wiki/doku.php?id=openwrt_coding ?
TIA
You can follow the official howto (from: http://www.dd-wrt.com/forum/viewtopic.php?p=21499&sid=de90601a8d51747d1c8ccec29284127d)
1. The helloworld.c source
Code:
#include <stdio.h>
int main ( void ) {
printf( "Hello world!\n" );
}
2. Get and unpack the toolchain in your homedir
Code:
cd ~
wget ftp://ftp.dd-wrt.com/sourcecode/toolchains.x86.debian.sp1.tar.bz2
tar -jxf toolchains.x86.debian.sp1.tar.bz2
3. Add the path to your cross-compiler executable to your path environment variable and compile helloworld.c
Code:
PATH=~/toolchains/4.1.0-uclibc-0.9.28/bin:$PATH mipsel-linux-uclibc-gcc helloworld.c -o helloworld
4. Check if its correctly compiled with the cross-compiler
Code:
file helloworld
helloworld: ELF 32-bit LSB executable, MIPS, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
5. Finally, transfer the helloworld binary file to your router, set the executable bit and run it.
Tested with Ubuntu 6.06.1 LTS.

Resources