Bug 40868 - ecjx.cc should be compiled by host gcc
Summary: ecjx.cc should be compiled by host gcc
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcj (show other bugs)
Version: 4.4.1
: P3 normal
Target Milestone: ---
Assignee: Tom Tromey
URL:
Keywords:
: 42311 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-07-27 03:54 UTC by dsdsdds
Modified: 2010-09-27 22:13 UTC (History)
8 users (show)

See Also:
Host: x86_64-linux-gnu
Target: arm-none-linux-gnueabi
Build: x86_64-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2009-09-01 12:03:59


Attachments
Proposed patch (710 bytes, patch)
2009-12-04 12:54 UTC, Diego Elio Pettenò
Details | Diff
backport (1.12 KB, patch)
2010-09-27 21:20 UTC, Dima
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description dsdsdds 2009-07-27 03:54:42 UTC
gcc version: 4.4.1 with gcc-4.4.1-branch_update-1.patch
host system: Ubuntu 9.04 x86_64

configured by:
     ./configure --prefix=/usr --build=x86_64-linux-gnu \
	--host=x86_64-linux-gnu \
	--target=arm-none-linux-gnueabi --with-sysroot=$TOOLCHAIN_DIR \
	--with-gmp=$STATIC_LIB_DIR --with-mpfr=$STATIC_LIB_DIR \
	--disable-multilib --disable-nls --enable-shared \
	--enable-__cxa_atexit --enable-c99 --enable-long-long \
	--enable-threads=posix --enable-languages=c,c++,java \
	--with-float=soft --with-cpu=arm926ej-s \
	--enable-libgcj-bc --disable-sjlj-exceptions \
	--with-ecj-jar=/source/ecj.jar
compiled by:
     make AS_FOR_TARGET=arm-none-linux-gnueabi-as LD_FOR_TARGET=arm-none-linux-gnueabi-ld

error message:
     architecture of input file `ecjx.o' is incompatible with i386:x86_64 output 

I solved this error message as follows:
First chdir to 'arm-none-linux-gnueabi/libjava',
then run 'gcc ecjx.cc -o ecjx.o'
then run 'make AS_FOR_TARGET=arm-none-linux-gnueabi-as LD_FOR_TARGET=arm-none-linux-gnueabi-ld' and no more error happens, and the toolchain works without problem.

This error is because ecjx.cc is compiled by arm-none-linux-gnueabi-gcc, not by gcc. I think that libjava/Makefile.in should be changed, as 

diff -Narup gcc-4.4.1.origin/libjava/Makefile.in gcc-4.4.1/libjava/Makefile.in
--- gcc-4.4.1.origin/libjava/Makefile.in	2009-07-22 15:43:59.000000000 +0800
+++ gcc-4.4.1/libjava/Makefile.in	2009-07-27 08:40:50.702375251 +0800
@@ -9739,6 +9739,9 @@ distclean-compile:
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
 
+ecjx.o:
+	gcc -c -o $@ $<
+
 .cc.o:
 @am__fastdepCXX_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`; \
 @am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$$depbase.Tpo" -c -o $@ $<; \
Comment 1 Ramana Radhakrishnan 2009-09-01 12:03:58 UTC
This sounds correct to me . Adding one of the libjava maintainers to comment on this. Patches should be submitted to the correct mailing list.
Comment 2 Andrew Haley 2009-09-01 14:06:44 UTC
Assigning to Tom tromey: this is his area.
Comment 3 Tom Tromey 2009-09-01 16:58:30 UTC
I think it isn't correct to use "gcc" directly.
You probably have to introduce a new variable.

But, I don't see why we need ecjx.cc at all.
I think it must be to work around some other problem.
Maybe instead we could just fix that problem directly.

Apparently it came in here, though I don't see why:
http://gcc.gnu.org/ml/java-patches/2008-q4/msg00067.html
See also PR 38396
Comment 4 Andrew Haley 2009-09-01 17:09:18 UTC
Hmm, I seem to have approved that patch.
I agree with you: I can't see why the specfile change requires ecjx.cc.


Comment 5 Jakub Jelinek 2009-09-01 21:38:31 UTC
I believe libtool wasn't doing the right thing without any sources, but it has been a while, so I don't remember the details.
Comment 6 Diego Elio Pettenò 2009-12-04 12:54:48 UTC
Created attachment 19222 [details]
Proposed patch

With this patch applied, gcj cross-builds fine (not a canadian cross though).
Comment 7 Ramana Radhakrishnan 2009-12-10 15:25:11 UTC
(In reply to comment #6)
> Created an attachment (id=19222) [edit]
> Proposed patch
> 
> With this patch applied, gcj cross-builds fine (not a canadian cross though).
> 

Please submit patches to gcc-patches@gcc.gnu.org 
Comment 8 Roumen Petrov 2010-07-10 08:56:31 UTC
Bug cannot be resolved with updates in libjava/Makefile. You could see my comments in issue #40868 (clone of #30591)

Comment 9 Roumen Petrov 2010-07-10 08:57:09 UTC
*** Bug 42311 has been marked as a duplicate of this bug. ***
Comment 10 Ralf Wildenhues 2010-08-27 04:27:58 UTC
Subject: Bug 40868

Author: rwild
Date: Fri Aug 27 04:27:40 2010
New Revision: 163580

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163580
Log:
Fix building ecjx in cross compile mode.

libjava/:
	PR libgcj/40868
	* configure.ac: Add GCC_FOR_ECJX variable.  Ensure
	GCJ_FOR_ECJX is always set.
	* Makefile.am [!NATIVE] (ecjx.$(OBJEXT)): New rule.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* gcj/Makefile.in: Regenerate.
	* include/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.

Modified:
    trunk/libjava/ChangeLog
    trunk/libjava/Makefile.am
    trunk/libjava/Makefile.in
    trunk/libjava/configure
    trunk/libjava/configure.ac
    trunk/libjava/gcj/Makefile.in
    trunk/libjava/include/Makefile.in
    trunk/libjava/testsuite/Makefile.in

Comment 11 Ralf Wildenhues 2010-08-27 04:30:32 UTC
Fixed.
Comment 12 Fraxinas 2010-09-23 22:36:05 UTC
Hi Ralf,
i tried destilling your rev 163580 patches into one accumulated backport to gcc-4.4.4. in our openembedded cross development toolchain. 
http://pastebin.com/pU3zF6MP

the patch actually does apply correctly, but during compile time, fails in the libjava directory:
...
libtool: link: ( cd ".libs" && rm -f "libgcj_bc.la" && ln -s "../libgcj_bc.la" "libgcj_bc.la" )
/bin/bash: GCC_FOR_ECJX@: command not found

turns out that the generated Makefile has the line GCC_FOR_ECJX = @GCC_FOR_ECJX@ in it, so the variable wasn't substituted correctly during configure, even though config.log says GCC_FOR_ECJX='x86_64-linux-gcc'

i probably need to backport other parts to be able to apply this patch correctly on gcc release 4.4.4. but unfortunately the revision log http://gcc.gnu.org/viewcvs/trunk/libjava/configure.ac?view=log&pathrev=163580 doesn't have information about the releases

is there an easy way to find out what else i need?

greetings,
fraxinas
Comment 13 Andrew Haley 2010-09-24 07:54:17 UTC
On 23/09/10 23:36, andreas.frisch@multimedia-labs.de wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40868
> 
> Fraxinas <andreas.frisch@multimedia-labs.de> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |andreas.frisch@multimedia-l
>                    |                            |abs.de
> 
> --- Comment #12 from Fraxinas <andreas.frisch@multimedia-labs.de> 2010-09-23 22:36:05 UTC ---
> Hi Ralf,
> i tried destilling your rev 163580 patches into one accumulated backport to
> gcc-4.4.4. in our openembedded cross development toolchain. 
> http://pastebin.com/pU3zF6MP
> 
> the patch actually does apply correctly, but during compile time, fails in the
> libjava directory:
> ...
> libtool: link: ( cd ".libs" && rm -f "libgcj_bc.la" && ln -s "../libgcj_bc.la"
> "libgcj_bc.la" )
> /bin/bash: GCC_FOR_ECJX@: command not found
> 
> turns out that the generated Makefile has the line GCC_FOR_ECJX =
> @GCC_FOR_ECJX@ in it, so the variable wasn't substituted correctly during
> configure, even though config.log says GCC_FOR_ECJX='x86_64-linux-gcc'
> 
> i probably need to backport other parts to be able to apply this patch
> correctly on gcc release 4.4.4. but unfortunately the revision log
> http://gcc.gnu.org/viewcvs/trunk/libjava/configure.ac?view=log&pathrev=163580
> doesn't have information about the releases
> 
> is there an easy way to find out what else i need?

It's hard to say.  I'd just import libgcj from gcc trunk.

Andrew.
Comment 14 Dima 2010-09-27 21:20:33 UTC
Created attachment 21898 [details]
backport

This is the backport I use against gcc-4.4
Comment 15 Fraxinas 2010-09-27 21:57:43 UTC
(In reply to comment #14)
> Created attachment 21898 [details]
> backport
> 
> This is the backport I use against gcc-4.4

dear dima, thanks for that patch but it's not sufficient. it even applies and configures right but too many things had changed between release 4.4.4 and revision 163580. so the resulting generated makefile is faulty and leaves the variable @GCC_FOR_ECJX@ unsubtituted which causes compile to fail.
instead, i did it like Andrew proposed and simply imported the entire libjava directory from svn head with which it works correctly.


now i am struggeling to cross compile statically linked mipsel java code with a c++ .so linked to it...
Comment 16 Dima 2010-09-27 22:13:18 UTC
(In reply to comment #15)
> (In reply to comment #14)
> > Created attachment 21898 [details] [details]
> > backport
> > 
> > This is the backport I use against gcc-4.4
> 
> dear dima, thanks for that patch but it's not sufficient. it even applies and
> configures right but too many things had changed between release 4.4.4 and
> revision 163580. so the resulting generated makefile is faulty and leaves the
> variable @GCC_FOR_ECJX@ unsubtituted which causes compile to fail.

This patch does apply against snapshot gcc-4.4 branch 26-09-2010. And does build libgcj & java cross-compiler from i386|x86_64-gnu-linux to i686-w64-mingw32.
After the patch is applied you do need to rerun correct autoreconf (2.59).

Buildlog - http://launchpadlibrarian.net/56490712/buildlog_ubuntu-lucid-i386.w64-toolchain_1.0b%2B201009260029-0w2228g93841b22110p11~lucid1_FULLYBUILT.txt.gz