Skip to main content

Compiling for small architectures

5 replies [Last post]
rokklimber
Offline
Joined: 2008-02-12
Points: 0

I built squawk on linux and tested the Test Class. I am trying to port it to an 8051 platform, where do I start on removing the link to libjvm so that it can run independently? Many thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tugstugi
Offline
Joined: 2008-03-13
Points: 0

> I built squawk on linux and tested the Test Class. I
> am trying to port it to an 8051 platform, where do I
> start on removing the link to libjvm so that it can
> run independently? Many thanks.

Remove the rows 347 [b]new File(jdk.getHome(), "include"),[/b] and 348 [b]jdk.getJNI_MDIncludePath(),[/b]
from the function [b]run(String[] args)[/b] of [b]SQUAWKROOT/builder/src/com/sun/squawk/builder/commands/RomCommand.java[/b]. I think your goal directory in the directory [b]SQUAWKROOT/vmcore/src/rts[/b] should have [b]jni_md.h[/b] and [b]jni.h[/b] files.

rasped
Offline
Joined: 2008-01-31
Points: 0

Hi,
That will be some work:-). Perhaps you can also take a look at the message http://forums.java.net/jive/message.jspa?messageID=258473#258473 and then see under the [b]Building/Running[/b] section. If you enter
[i]d -nocomp rom cldc[/i] instead of step e, then it will produce the c files only. If you look at how [i]SQUAWKROOT/vmcore/src/vm/squawk.c[/i] includes its files, then you will see how some of it works. Also see [i]SQUAWKROOT/vmcore/src/rts/gcc-eb40a[/i] to see an actual example of how the platform dependent files (similar to what Eric explains above) can look.
Best, Rasmus

mazx
Offline
Joined: 2008-03-25
Points: 0

How does the build system figures out (in vmcore\src\rts) what platform to build for? Is there a way to specify to the build system what platform to build for?

tugstugi
Offline
Joined: 2008-03-13
Points: 0

> How does the build system figures out (in
> vmcore\src\rts) what platform to build for? Is there
> a way to specify to the build system what platform to
> build for?

1. You have to write your own [b]CCompiler[/b] class. See [b]SQUAWKROOT/builder/src/com/sun/squawk/builder/ccompiler/CCompiler.java[/b]. The parameter [b]name[/b] of the constructor should be the name of the goal directory in [b]SQUAWKROOT/vmcore/src/rts/[/b]. Something like [b]new MyCCompiler("gcc-eb40a", build, myplatform)[/b].

2. Patch the function [b]updateCCompiler(String name)[/b] of [b]SQUAWKROOT/builder/src/com/sun/squawk/builder/Build.java[/b].

3. Remove the rows 347 [b]new File(jdk.getHome(), "include"),[/b] and 348 [b]jdk.getJNI_MDIncludePath(),
[/b] from the function [b]run(String[] args)[/b] of [b]SQUAWKROOT/builder/src/com/sun/squawk/builder/commands/RomCommand.java[/b].

4. To romize, i.e. use [b]d -comp:gcc-eb40a rom cldc[/b]

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

The reference to libjvm is only for the Linux port of Squawk. You need to take a look at the contents of vmcore/src. You will find a vm/ and an rts/ folder. The vm folder holds the generic parts needed for all ports, and the rts folder holds the parts necessary for the target platform.

For example vmcore/rts/msc is the shell needed for Windows using the MS C compiler. The os.c file contains the appropriate main function.

When Squawk is running on a desktop it requires Java runtime to be available. We do this in order to allow Squawk to leverage services already implemented in Java, such as files, without having to re-implement it for each desktop platform.

There will be instructions on how to do ports, just need more time :(