This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: PR libjava/32098: New libtool doesn't support libjava



On May 28, 2007, at 2:21 AM, Paolo Bonzini wrote:



No, that's wrong. You can try changing libtool.m4 to run tests on .class files instead; compile them with an old GCJ, and include the bytecode in libtool.m4, using tr or awk to turn ASCII strings into bytecode.

That is the best I can find. I don't know anything about .classs file
nor java bytecode.

So the attached patch (untested because the problem does not reproduce on my machine) should give you an idea of what I meant. Please test it and/or fix it.


Libtool maintainers, would you accept a patch like this one? The problem is that under some configurations, GCC 4.3 cannot compile Java source code until its build has finished.

Paolo
2007-05-27  Paolo Bonzini  <bonzini@gnu.org>

* libtool.m4 (_LT_LANG_GCJ_CONFIG): Run tests on .class files.

Index: libtool.m4
===================================================================
--- libtool.m4	(revision 125123)
+++ libtool.m4	(working copy)
@@ -6737,18 +6737,54 @@ m4_defun([_LT_LANG_GCJ_CONFIG],
 [AC_REQUIRE([LT_PROG_GCJ])dnl
 AC_LANG_SAVE

-# Source file extension for Java test sources.
-ac_ext=java
+# Source file extension for Java test sources. Actually, we use a list
+# of input files so that we can prepare binary .class files and keep
+# lt_simple_compile_test_code/lt_simple_link_test_code in ASCII.
+ac_ext=list


 # Object file extension for compiled Java test sources.
 objext=o
 _LT_TAGVAR(objext, $1)=$objext

# Code to be used in simple compile tests
-lt_simple_compile_test_code="class foo {}"
+# "class conftest_compile {}"
+# Turn it into hex using "od -x foo.class | sed s/^.......// | tr - d ' '"
+lt_simple_compile_test_code='conftest_compile.class'
+awk 'BEGIN { h = "0123456789abcdef" }
+ {
+ for (i = 1; i <= length; i+=2)
+ printf "%c", 16*index(h, substr($0, i, 1))+index(h, substr ($0, i+1, 1))-17
+ }' > conftest_compile.class << EOF
+cafebabe00000031000d0a0003000a07000b07000c0100063c696e69743e0100
+03282956010004436f646501000f4c696e654e756d6265725461626c6501000a
+536f7572636546696c65010015636f6e66746573745f636f6d70696c652e6a61
+76610c00040005010010636f6e66746573745f636f6d70696c650100106a6176
+612f6c616e672f4f626a65637400200002000300000000000100000004000500
+0100060000001d00010001000000052ab70001b1000000010007000000060001
+0000000100010008000000020009
+EOF

As I understand the theory (compile .class files instead of .java files) this is fine with me. However, being curious about the portability of the awk expression, I tried it on solaris, there with both awk and nawk, printf "%c",0; prints nothing at all, so all those 00 above do not end up in the output. Needs another method to convert text to binary.


% od -x < conftest_compile.class
0000000 cafe babe 310d 0a03 0a07 0b07 0c01 063c
0000020 696e 6974 3e01 0328 2956 0104 436f 6465
0000040 010f 4c69 6e65 4e75 6d62 6572 5461 626c
0000060 6501 0a53 6f75 7263 6546 696c 6501 1563
0000100 6f6e 6674 6573 745f 636f 6d70 696c 652e
0000120 6a61 7661 0c04 0501 1063 6f6e 6674 6573
0000140 745f 636f 6d70 696c 6501 106a 6176 612f
0000160 6c61 6e67 2f4f 626a 6563 7420 0203 0104
0000200 0501 061d 0101 052a b701 b101 0706 0101
0000220 0108 0209


Thanks, Peter -- Peter O'Gorman http://pogma.com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]