From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14713 invoked by alias); 24 Oct 2014 13:33:01 -0000 Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org Received: (qmail 14667 invoked by uid 89); 24 Oct 2014 13:33:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f45.google.com Received: from mail-wg0-f45.google.com (HELO mail-wg0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 24 Oct 2014 13:32:59 +0000 Received: by mail-wg0-f45.google.com with SMTP id l18so1075423wgh.28 for ; Fri, 24 Oct 2014 06:32:56 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.194.78.113 with SMTP id a17mr2706599wjx.120.1414157576279; Fri, 24 Oct 2014 06:32:56 -0700 (PDT) Received: by 10.194.42.104 with HTTP; Fri, 24 Oct 2014 06:32:56 -0700 (PDT) In-Reply-To: <1414126365.4574.13.camel@neelix> References: <1413785951.4798.12.camel@neelix> <1414126365.4574.13.camel@neelix> Date: Fri, 24 Oct 2014 13:33:00 -0000 Message-ID: Subject: Re: Compiling Scala-generated bytecode From: Bryce McKinlay To: =?UTF-8?B?TWFya28gRGltamHFoWV2acSH?= Cc: GCC Java Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg00001.txt.bz2 On Fri, Oct 24, 2014 at 5:52 AM, Marko Dimja=C5=A1evi=C4=87 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.t= ar.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=3D$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=3D$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=3D/home/ec2-user/scala-2.9.2/lib/scala-library.jar -lscala -L$HOME/lib --indirect-dispatch --main=3DHelloWorld $ export LD_LIBRARY_PATH=3D$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