public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Compiling Scala-generated bytecode
       [not found] ` <CALUNu-qQ-k-F8w5ekc+GXOhyo-V=Ppsxe7wmEXtahOxK6-d7Fw@mail.gmail.com>
@ 2014-10-24  4:52   ` Marko Dimjašević
  2014-10-24 13:33     ` Bryce McKinlay
  0 siblings, 1 reply; 2+ messages in thread
From: Marko Dimjašević @ 2014-10-24  4:52 UTC (permalink / raw)
  To: Bryce McKinlay; +Cc: java

[-- Attachment #1: Type: text/plain, Size: 679 bytes --]

On Thu, 2014-10-23 at 10:36 +0100, Bryce McKinlay wrote:
> gcj -O2 --shared scala-library-2.9.2.jar -o libScala.so
> gcj *.class -L. -lscala
> LD_LIBRARY_PATH=. ./a.out 

Have you actually executed this on a machine? If so, I'd like to know
which version of GCJ you used for this.

As I've reported in one of my previous mails, the first command fails.
This happens with GCC 4.7.2. I've tried to build GCC 4.9.1 because
Andrew Hughes pointed out I might have a too old GCJ version to include
Pattern.quote(String), but something was failing with the build process,
so I can't really give it a shot with 4.9.1.


-- 
Cheers,
Marko
http://dimjasevic.net/marko


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Compiling Scala-generated bytecode
  2014-10-24  4:52   ` Compiling Scala-generated bytecode Marko Dimjašević
@ 2014-10-24 13:33     ` Bryce McKinlay
  0 siblings, 0 replies; 2+ messages in thread
From: Bryce McKinlay @ 2014-10-24 13:33 UTC (permalink / raw)
  To: Marko Dimjašević; +Cc: GCC Java

On Fri, Oct 24, 2014 at 5:52 AM, Marko Dimjašević <marko@dimjasevic.net> wrote:

> Have you actually executed this on a machine? If so, I'd like to know
> which version of GCJ you used for this.
>
> As I've reported in one of my previous mails, the first command fails.
> This happens with GCC 4.7.2. I've tried to build GCC 4.9.1 because
> Andrew Hughes pointed out I might have a too old GCJ version to include
> Pattern.quote(String), but something was failing with the build process,
> so I can't really give it a shot with 4.9.1.

I just built GCC 4.9.1 and gave it a try on a fresh EC2 instance.

$ uname -a
Linux ip-172-30-1-126 3.14.20-20.44.amzn1.x86_64 #1 SMP Mon Oct 6
22:52:46 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

$ sudo yum install gcc-c++ libmpc-devel mpfr-devel gmp-devel
$ curl -O http://mirrors-uk.go-parts.com/gcc/releases/gcc-4.9.1/gcc-4.9.1.tar.bz2
$ tar jxvf gcc-4.9.1.tar.bz2

$ mkdir gcc-build; cd gcc-build
$ ../gcc-4.9.1/configure --enable-java --disable-multilib --prefix=$HOME/gcc-bin
$ make -j35
$ make install

$ cd $HOME
$ curl -O http://www.scala-lang.org/files/archive/scala-2.9.2.tgz
$ tar zxvf scala-2.9.2.tgz

$ export PATH=$PATH:$HOME/gcc-bin/bin:$HOME/scala-2.9.2/bin

$ mkdir lib
$ gcj --indirect-dispatch -O2 --shared
scala-2.9.2/lib/scala-library.jar -o lib/libscala.so

$ scalac HelloWorld.scala
$ gcj HelloWorld$.class HelloWorld.class
--classpath=/home/ec2-user/scala-2.9.2/lib/scala-library.jar -lscala
-L$HOME/lib --indirect-dispatch --main=HelloWorld

$ export LD_LIBRARY_PATH=$HOME/lib:$HOME/gcc-bin/lib64

$ ./a.out
Hello, Scala World!



The "--indirect-dispatch" option is the key here. This defers class
and method resolution to runtime, so any missing ones will be runtime
errors, not compile time errors.

Even in 4.9.1, the scala-library.jar references a few methods (e.g. in
sun.misc.Unsafe, and java.math.BigInteger) that libgcj doesn't have,
but it doesn't need them to run. At least for this simple example.

Bryce

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-10-24 13:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1413785951.4798.12.camel@neelix>
     [not found] ` <CALUNu-qQ-k-F8w5ekc+GXOhyo-V=Ppsxe7wmEXtahOxK6-d7Fw@mail.gmail.com>
2014-10-24  4:52   ` Compiling Scala-generated bytecode Marko Dimjašević
2014-10-24 13:33     ` Bryce McKinlay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).