Bug 43839 - libjava incorrectly uses -liconv in testsuite, jni.exp when using --with-libiconv-prefix
Summary: libjava incorrectly uses -liconv in testsuite, jni.exp when using --with-libi...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 43086 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-04-21 18:37 UTC by mrs@gcc.gnu.org
Modified: 2010-10-06 19:46 UTC (History)
4 users (show)

See Also:
Host: x86_64-apple-darwin10
Target: x86_64-apple-darwin10
Build: x86_64-apple-darwin10
Known to work:
Known to fail:
Last reconfirmed:


Attachments
proposed patch (577 bytes, patch)
2010-04-22 22:07 UTC, Jack Howarth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mrs@gcc.gnu.org 2010-04-21 18:37:00 UTC
libjava doesn't link libgcj with -liconv during build when --with-libiconv-prefix=/opt/local is used, and no corresponding -L for the -liconv is issued on the link line when running the libjava testsuite (jni.exp) for the FAIL: PR16923 run testcase:

Executing on host: /Users/mrs/net/gcc-java/gcc/xgcc -B/Users/mrs/net/gcc-java/gcc/ /Users/mrs/net/gcc/libjava/testsuite/libjava.jni/invocation/PR16923.c   -bind_at_load -multiply_defined suppress -I. -I.. -I/Users/mrs/net/gcc/libjava/testsuite/libjava.jni -I/Users/mrs/net/gcc/libjava/testsuite/../include -I/Users/mrs/net/gcc/libjava/testsuite/../classpath/include -fdollars-in-identifiers -L/Users/mrs/net/gcc-java/x86_64-apple-darwin10/./libjava/.libs -ljvm -shared-libgcc -lgcj -liconv  -lm   -o PR16923    (timeout = 300)

The correct bit can be found in the Makefile:

$ grep LTLIBICO x86_64-apple-darwin10/libjava/Makefile 
LTLIBICONV = -L/opt/local/lib -liconv -R/opt/local/lib

The spec file appears it would work:
$ cat x86_64-apple-darwin10/libjava/libgcj.spec
[ ... ]
%rename lib liborig
*lib:  %{s-bc-abi:} -lgcj  -lm -L/opt/local/lib -liconv  -lpthread  -allow_stack_execute \
 -ldl %(libgcc)  %(liborig)
[ ... ]

as well.

This was reported by Jack, in http://gcc.gnu.org/ml/java/2010-02/msg00003.html, but seems unresolved.

xgcc (GCC) 4.5.0 20100324 (experimental) [trunk revision 157698]
Comment 1 mrs@gcc.gnu.org 2010-04-21 18:44:48 UTC
I think this is the root cause of PR43086.
Comment 2 mrs@gcc.gnu.org 2010-04-21 18:52:17 UTC
Found it:

  if { [istarget "*-*-darwin*"] } {
    lappend cxxflags -shared-libgcc -lgcj -liconv
  }

in libjava/testsuite/libjava.jni/jni.exp.  This needs the proper -L added just before -liconv, or libgcj linked with -L... -liconv.  So, the question is, which solution is desired?  Normally I like adding -liconv to the libgcj link line, so that all consumers of libgcj just work.
Comment 3 mrs@gcc.gnu.org 2010-04-21 19:00:27 UTC
Nasty hack around:

Index: testsuite/libjava.jni/jni.exp
===================================================================
--- testsuite/libjava.jni/jni.exp	(revision 157698)
+++ testsuite/libjava.jni/jni.exp	(working copy)
@@ -267,7 +267,7 @@
   # to just make the linker find libgcc using -L options.
   # Similar logic applies to libgcj.
   if { [istarget "*-*-darwin*"] } {
-    lappend cxxflags -shared-libgcc -lgcj -liconv
+    lappend cxxflags -shared-libgcc -lgcj -L/opt/local/lib -liconv
   }
 
   if { [istarget "*-*-solaris*"] } {

seems to fix this issue.
Comment 4 mrs@gcc.gnu.org 2010-04-21 19:02:45 UTC
*** Bug 43086 has been marked as a duplicate of this bug. ***
Comment 5 mrs@gcc.gnu.org 2010-04-21 19:23:00 UTC
Came in with http://gcc.gnu.org/ml/java-patches/2007-q4/msg00053.html
Comment 6 mrs@gcc.gnu.org 2010-04-21 19:26:31 UTC
Ah, that wasn't the original work, just some mods along the way.
Comment 7 Jack Howarth 2010-04-21 23:33:44 UTC
This may be fixable with...

Index: testsuite/Makefile.in
===================================================================
--- testsuite/Makefile.in	(revision 158487)
+++ testsuite/Makefile.in	(working copy)
@@ -401,6 +401,7 @@
 	@echo 'set host_triplet $(host_triplet)' >>site.tmp
 	@echo 'set target_alias "$(target_alias)"' >>site.tmp
 	@echo 'set target_triplet $(target_triplet)' >>site.tmp
+	@echo 'set libiconv "$(LIBICONV)"' >>site.tmp
 	@echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
 	@test ! -f site.exp || \
 	  sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp

will test with current build.
Comment 8 Jack Howarth 2010-04-22 02:00:54 UTC
This almost works...

Index: testsuite/Makefile.in
===================================================================
--- testsuite/Makefile.in	(revision 158624)
+++ testsuite/Makefile.in	(working copy)
@@ -401,6 +401,7 @@
 	@echo 'set host_triplet $(host_triplet)' >>site.tmp
 	@echo 'set target_alias "$(target_alias)"' >>site.tmp
 	@echo 'set target_triplet $(target_triplet)' >>site.tmp
+	@echo 'set libiconv "$(LIBICONV)"' >>site.tmp
 	@echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
 	@test ! -f site.exp || \
 	  sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
Index: testsuite/libjava.jni/jni.exp
===================================================================
--- testsuite/libjava.jni/jni.exp	(revision 158624)
+++ testsuite/libjava.jni/jni.exp	(working copy)
@@ -251,6 +251,7 @@
 }
 
 proc gcj_jni_get_cxxflags_invocation {} {
+  global libiconv
   global LIBJAVA
   if [info exists LIBJAVA] {
       set libjava $LIBJAVA;
@@ -267,7 +268,7 @@
   # to just make the linker find libgcc using -L options.
   # Similar logic applies to libgcj.
   if { [istarget "*-*-darwin*"] } {
-    lappend cxxflags -shared-libgcc -lgcj -liconv
+    lappend cxxflags "-shared-libgcc -lgcj $libiconv"
   }
 
   if { [istarget "*-*-solaris*"] } {

However it ends up compiling...

xecuting on host: /sw/src/fink.build/gcc46-4.5.999-20100421/darwin_objdir/gcc/xgcc -B/sw/src/fink.build/gcc46-4.5.999-20100421/darwin_objdir/gcc/ /sw/src/fink.build/gcc46-4.5.999-20100421/gcc-4.6-20100421/libjava/testsuite/libjava.jni/invocation/PR16923.c   -bind_at_load -multiply_defined suppress -I. -I.. -I/sw/src/fink.build/gcc46-4.5.999-20100421/gcc-4.6-20100421/libjava/testsuite/libjava.jni -I/sw/src/fink.build/gcc46-4.5.999-20100421/gcc-4.6-20100421/libjava/testsuite/../include -I/sw/src/fink.build/gcc46-4.5.999-20100421/gcc-4.6-20100421/libjava/testsuite/../classpath/include -fdollars-in-identifiers -L/sw/src/fink.build/gcc46-4.5.999-20100421/darwin_objdir/x86_64-apple-darwin10.3.0/./libjava/.libs -ljvm {-shared-libgcc -lgcj -L/sw/lib -liconv}  -lm   -o PR16923    (timeout = 300)
xgcc: unrecognized option '-shared-libgcc -lgcj -L/sw/lib -liconv'^M
output is:
xgcc: unrecognized option '-shared-libgcc -lgcj -L/sw/lib -liconv'^M

I don't understand why $libiconv in jni.exp gets expanded as...

 {-shared-libgcc -lgcj -L/sw/lib -liconv}

instead of just...

-shared-libgcc -lgcj -L/sw/lib -liconv.
Comment 9 Jack Howarth 2010-04-22 22:07:11 UTC
Created attachment 20465 [details]
proposed patch
Comment 10 mrs@gcc.gnu.org 2010-05-03 22:38:08 UTC
Subject: Bug 43839

Author: mrs
Date: Mon May  3 22:37:50 2010
New Revision: 159009

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159009
Log:
	PR 43839
	* testsuite/Makefile.am: Override automake for site.exp creation
	and add entry to set libiconv.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/libjava.jni/jni.exp (gcj_jni_get_cxxflags_invocation):
	Add new global variable libiconv to handle alternative libiconv
	locations.

Modified:
    trunk/libjava/ChangeLog
    trunk/libjava/testsuite/Makefile.am
    trunk/libjava/testsuite/Makefile.in
    trunk/libjava/testsuite/libjava.jni/jni.exp

Comment 11 mrs@gcc.gnu.org 2010-06-09 17:21:52 UTC
Fixed.
Comment 12 mrs@gcc.gnu.org 2010-10-06 18:54:31 UTC
Author: mrs
Date: Wed Oct  6 18:54:14 2010
New Revision: 165061

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=165061
Log:
2010-10-06  Jack Howarth <howarth@bromo.med.uc.edu>

	Backport from mainline
	2010-05-03  Jack Howarth <howarth@bromo.med.uc.edu>

	PR java/43839
	* testsuite/Makefile.am: Override automake for site.exp creation
	and add entry to set libiconv.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/libjava.jni/jni.exp (gcj_jni_get_cxxflags_invocation):
	Add new global variable libiconv to handle alternative libiconv
	locations.

Modified:
    branches/gcc-4_5-branch/libjava/ChangeLog
    branches/gcc-4_5-branch/libjava/testsuite/Makefile.am
    branches/gcc-4_5-branch/libjava/testsuite/Makefile.in
    branches/gcc-4_5-branch/libjava/testsuite/libjava.jni/jni.exp