From: Bryce McKinlay <bmckinlay@gmail.com>
To: "Marko Dimjašević" <marko@dimjasevic.net>
Cc: GCC Java <java@gcc.gnu.org>
Subject: Re: Compiling Scala-generated bytecode
Date: Fri, 24 Oct 2014 13:33:00 -0000 [thread overview]
Message-ID: <CALUNu-oQen8xgHMHt=vZAKxDJb7ccTFB0tGWGww_Hs2Te4P02g@mail.gmail.com> (raw)
In-Reply-To: <1414126365.4574.13.camel@neelix>
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
prev parent reply other threads:[~2014-10-24 13:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 ` Marko Dimjašević
2014-10-24 13:33 ` Bryce McKinlay [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALUNu-oQen8xgHMHt=vZAKxDJb7ccTFB0tGWGww_Hs2Te4P02g@mail.gmail.com' \
--to=bmckinlay@gmail.com \
--cc=java@gcc.gnu.org \
--cc=marko@dimjasevic.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).