Creating and using GCJ ARM cross compiler

Andrew Haley aph@redhat.com
Fri Apr 18 17:18:00 GMT 2008


Matthijs van de Water wrote:
> Hello,
> 
> I'm trying to create an arm-linux toolchain based on GCC 4.2.3 with
> working ARM EABI support, inside the Poky Linux OpenEmbedded
> environment.
> In order to get GCC 4.2.3 with the ARM EABI GCJ, I'm working from the
> GCC SVN branch 'branches/ubuntu/gcc-4_2-branch', which should have
> full ARM EABI support merged from trunk. Reason for not using GCC 4.3
> is that there is no support to create a GCC 4.3-based toolchain in
> OpenEmbedded yet.
> 
> I have the build process completing successfully and I now have an a
> libgcj for arm and arm-poky-linux-gnueabi-gcj. When trying to use
> them, I run into some trouble though, so I presume I'm still doing
> something wrong (even though the build is successful).
> 
> 1) arm-poky-linux-gnueabi-gcj can successfully compile an existing
> .jar file into an ARM .so file (using -fPIC). So far so good.
>
> 2) arm-poky-linux-gnueabi-gcj --main=helloworld -o hello hello.java
> complains about ecj1 being missing; it looks like this might be some
> configure problem? Is this only a matter of putting ecj.jar with my
> sources before configuring and compiling? Looking at the logs, it
> seems that the /usr/bin/javac from my local system is used to compile
> *.java into *.class during GCC compilation. Is that expected?

Yes.

> The
> build does not create an ecj1 executable, only a jc1. I'm currently
> just using ecj1 from my Ubuntu host, which enables me to compile my
> Hello World test.

Sounds good.

> How would I make sure that ecj1 is also generated in the build?

This one is documented:

--with-ecj-jar=filename

    This option can be used to specify the location of an external jar
    file containing the Eclipse Java compiler. A specially modified
    version of this compiler is used by gcj to parse .java source
    files. If this option is given, the `libjava' build will create
    and install an ecj1 executable which uses this jar file at
    runtime.

    If this option is not given, but an ecj.jar file is found in the
    topmost source tree at configure time, then the `libgcj' build
    will create and install ecj1, and will also install the discovered
    ecj.jar into a suitable place in the install tree.

    If ecj1 is not installed, then the user will have to supply one on
    his path in order for gcj to properly parse .java source files. A
    suitable jar is available from ftp://sourceware.org/pub/java/.

Run contrib/download_ecj to get ecj.jar.

> 3) When I try to use the Java shared library that I compiled in (1), I
> run into trouble immediately:

> error: stray '$' in program
> [error repeated a lot of times]
> 
> If I add "-fdollars-in-identifiers" to my compile statement, it
> completes without error, but I would expect this not to be necessary.

Well, it is.  For some reason I could never understand, it's needed on arm.
I added -fdollars-in-identifiers in several places in the libgcj build.

> Could anyone give me some pointers to create a completely valid build?

Looks to me like it's working as expected.

Andrew.



More information about the Java mailing list