This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: 3.0 and trunk: gcj/libgcj -vs- iconv()
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Subject: Patch: 3.0 and trunk: gcj/libgcj -vs- iconv()
- From: Tom Tromey <tromey at redhat dot com>
- Date: 06 Jul 2001 14:22:57 -0600
- Cc: Java Patch List <java-patches at gcc dot gnu dot org>
- Reply-To: tromey at redhat dot com
This patch adds support for the use of libiconv to gcj and libgcj.
This fixes a recently reported build failure on Solaris, as well as PR
2812.
I tested this by rebuilding on my x86 Linux box. Then I rebuilt on a
Solaris box. Then I installed libiconv on the Solaris box and rebuilt
gcc using `--with-libiconv-prefix'. The first two builds went fine;
with the last one I found I was unable to build 3.1 on Solaris for
several days (since Friday; see my bug report from a few days back).
So then I instead applied the patch to the 3.0 branch and built on
Solaris 2.6 using libiconv (I had to work around a libstdc++ problem
which I reported today). This worked fine.
These builds implicitly test the patch as proper encoding handling is
required to rebuild libgcj.
Anyway, I'd like to commit this to the 3.0 branch as well as the
trunk. Ok?
[ gcc ]
2001-06-29 Tom Tromey <tromey@redhat.com>
For PR java/2812:
* configure: Rebuilt.
* configure.in: Don't check for iconv.h or iconv(); use AM_ICONV
instead.
* aclocal.m4 (AM_ICONV): New macro from Bruno Haible.
[ gcc/java ]
2001-06-29 Tom Tromey <tromey@redhat.com>
For PR java/2812:
* lex.h: Use HAVE_ICONV, not HAVE_ICONV_H.
* lex.c (java_new_lexer): Use ICONV_CONST.
(java_read_char): Likewise.
* Make-lang.in (jc1$(exeext)): Link against LIBICONV.
(jv-scan$(exeext)): Likewise.
[ libjava ]
2001-07-06 Tom Tromey <tromey@redhat.com>
For PR java/2812:
* libgcj.spec.in (*lib): Added LIBICONV.
* Makefile.am (GCJLINK): Added ICONV_LDFLAGS.
(LIBLINK): Likewise.
* configure: Rebuilt.
* configure.in: Call AM_ICONV. Don't check for iconv function.
* acinclude.m4 (AM_ICONV): New macro, from Bruno Haible. Then
modified to generate ICONV_LDFLAGS.
Tom
Index: gcc/aclocal.m4
===================================================================
RCS file: /cvs/gcc/gcc/gcc/aclocal.m4,v
retrieving revision 1.49
diff -u -r1.49 aclocal.m4
--- aclocal.m4 2001/05/26 04:54:42 1.49
+++ aclocal.m4 2001/06/29 17:55:47
@@ -1469,3 +1469,73 @@
multi-word integers.])
fi
])
+
+#serial AM2
+
+dnl From Bruno Haible.
+
+AC_DEFUN([AM_ICONV],
+[
+ dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
+ dnl those with the standalone portable GNU libiconv installed).
+
+ AC_ARG_WITH([libiconv-prefix],
+[ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
+ for dir in `echo "$withval" | tr : ' '`; do
+ if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
+ if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
+ done
+ ])
+
+ AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
+ am_cv_func_iconv="no, consider installing GNU libiconv"
+ am_cv_lib_iconv=no
+ AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+ [iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);],
+ am_cv_func_iconv=yes)
+ if test "$am_cv_func_iconv" != yes; then
+ am_save_LIBS="$LIBS"
+ LIBS="$LIBS -liconv"
+ AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+ [iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);],
+ am_cv_lib_iconv=yes
+ am_cv_func_iconv=yes)
+ LIBS="$am_save_LIBS"
+ fi
+ ])
+ if test "$am_cv_func_iconv" = yes; then
+ AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
+ AC_MSG_CHECKING([for iconv declaration])
+ AC_CACHE_VAL(am_cv_proto_iconv, [
+ AC_TRY_COMPILE([
+#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
+ am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
+ am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
+ AC_MSG_RESULT([$]{ac_t:-
+ }[$]am_cv_proto_iconv)
+ AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
+ [Define as const if the declaration of iconv() needs const.])
+ fi
+ LIBICONV=
+ if test "$am_cv_lib_iconv" = yes; then
+ LIBICONV="-liconv"
+ fi
+ AC_SUBST(LIBICONV)
+])
Index: gcc/config.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.in,v
retrieving revision 1.113
diff -u -r1.113 config.in
--- config.in 2001/05/26 04:54:42 1.113
+++ config.in 2001/06/29 17:55:48
@@ -125,9 +125,6 @@
/* Define if you have the gettimeofday function. */
#undef HAVE_GETTIMEOFDAY
-/* Define if you have the iconv function. */
-#undef HAVE_ICONV
-
/* Define if you have the isascii function. */
#undef HAVE_ISASCII
@@ -200,9 +197,6 @@
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
-/* Define if you have the <iconv.h> header file. */
-#undef HAVE_ICONV_H
-
/* Define if you have the <langinfo.h> header file. */
#undef HAVE_LANGINFO_H
@@ -364,6 +358,12 @@
/* Define if read-only mmap of a plain file works. */
#undef HAVE_MMAP_FILE
+
+/* Define if you have the iconv() function. */
+#undef HAVE_ICONV
+
+/* Define as const if the declaration of iconv() needs const. */
+#undef ICONV_CONST
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_GETENV
Index: gcc/configure.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure.in,v
retrieving revision 1.531
diff -u -r1.531 configure.in
--- configure.in 2001/06/13 03:10:43 1.531
+++ configure.in 2001/06/29 17:55:54
@@ -457,7 +457,7 @@
AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h \
fcntl.h unistd.h sys/file.h sys/time.h \
sys/resource.h sys/param.h sys/times.h sys/stat.h \
- direct.h malloc.h langinfo.h iconv.h)
+ direct.h malloc.h langinfo.h)
# Check for thread headers.
AC_CHECK_HEADER(thread.h, [have_thread_h=yes], [have_thread_h=])
@@ -578,7 +578,7 @@
AC_CHECK_FUNCS(strtoul bsearch popen times clock \
strchr strrchr kill getrlimit setrlimit atoll atoq \
sysconf isascii gettimeofday strsignal putc_unlocked fputc_unlocked \
- fputs_unlocked getrusage iconv nl_langinfo lstat)
+ fputs_unlocked getrusage nl_langinfo lstat)
AC_CHECK_TYPE(ssize_t, int)
@@ -616,6 +616,8 @@
AC_FUNC_VFORK
AC_FUNC_MMAP_ANYWHERE
AC_FUNC_MMAP_FILE
+
+AM_ICONV
# We will need to find libiberty.h and ansidecl.h
saved_CFLAGS="$CFLAGS"
Index: gcc/java/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Make-lang.in,v
retrieving revision 1.62
diff -u -r1.62 Make-lang.in
--- Make-lang.in 2001/06/01 16:51:18 1.62
+++ Make-lang.in 2001/06/29 17:56:10
@@ -121,7 +121,7 @@
jc1$(exeext): $(JAVA_OBJS) $(BACKEND) $(LIBDEPS)
rm -f $@
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
- $(JAVA_OBJS) $(BACKEND) $(ZLIB) $(LIBS)
+ $(JAVA_OBJS) $(BACKEND) $(ZLIB) $(LIBICONV) $(LIBS)
gcjh$(exeext): $(GCJH_OBJS) $(LIBDEPS)
rm -f $@
@@ -129,7 +129,7 @@
jv-scan$(exeext): $(JVSCAN_OBJS) $(LIBDEPS)
rm -f $@
- $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JVSCAN_OBJS) $(LIBS)
+ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JVSCAN_OBJS) $(LIBICONV) $(LIBS)
jcf-dump$(exeext): $(JCFDUMP_OBJS) $(LIBDEPS)
rm -f $@
Index: gcc/java/lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lex.c,v
retrieving revision 1.66
diff -u -r1.66 lex.c
--- lex.c 2001/06/20 16:21:24 1.66
+++ lex.c 2001/06/29 17:56:12
@@ -268,7 +268,8 @@
outp = (char *) &result;
outc = 2;
- r = iconv (handle, (const char **) &inp, &inc, &outp, &outc);
+ r = iconv (handle, (ICONV_CONST char **) &inp, &inc,
+ &outp, &outc);
iconv_close (handle);
/* Conversion must be complete for us to use the result. */
if (r != (size_t) -1 && inc == 0 && outc == 0)
@@ -370,8 +371,8 @@
out_save = out_count;
inp = &lex->buffer[lex->first];
outp = &lex->out_buffer[lex->out_last];
- ir = iconv (lex->handle, (const char **) &inp, &inbytesleft,
- &outp, &out_count);
+ ir = iconv (lex->handle, (ICONV_CONST char **) &inp,
+ &inbytesleft, &outp, &out_count);
/* If we haven't read any bytes, then look to see if we
have read a BOM. */
Index: gcc/java/lex.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lex.h,v
retrieving revision 1.23
diff -u -r1.23 lex.h
--- lex.h 2001/05/26 01:31:47 1.23
+++ lex.h 2001/06/29 17:56:12
@@ -1,5 +1,5 @@
/* Language lexer definitions for the GNU compiler for the Java(TM) language.
- Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
This file is part of GNU CC.
@@ -35,7 +35,7 @@
/* A Unicode character, as read from the input file */
typedef unsigned short unicode_t;
-#ifdef HAVE_ICONV_H
+#ifdef HAVE_ICONV
#include <iconv.h>
#endif /* HAVE_ICONV */
Index: libjava/acinclude.m4
===================================================================
RCS file: /cvs/gcc/gcc/libjava/acinclude.m4,v
retrieving revision 1.7.4.3
diff -u -r1.7.4.3 acinclude.m4
--- libjava/acinclude.m4 2001/07/03 22:34:57 1.7.4.3
+++ libjava/acinclude.m4 2001/07/06 20:01:04
@@ -117,3 +117,78 @@
AC_SUBST(GCJ)
AC_SUBST(LIBTOOL)
])
+
+#serial AM2
+
+dnl From Bruno Haible.
+
+AC_DEFUN([AM_ICONV],
+[
+ dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
+ dnl those with the standalone portable GNU libiconv installed).
+
+ ICONV_LDFLAGS=
+ AC_ARG_WITH([libiconv-prefix],
+[ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
+ for dir in `echo "$withval" | tr : ' '`; do
+ if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
+ if test -d $dir/lib; then
+ LDFLAGS="$LDFLAGS -L$dir/lib"
+ ICONV_LDFLAGS=-L$dir/lib
+ fi
+ done
+ ])
+ AC_SUBST(ICONV_LDFLAGS)
+
+ AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
+ am_cv_func_iconv="no, consider installing GNU libiconv"
+ am_cv_lib_iconv=no
+ AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+ [iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);],
+ am_cv_func_iconv=yes)
+ if test "$am_cv_func_iconv" != yes; then
+ am_save_LIBS="$LIBS"
+ LIBS="$LIBS -liconv"
+ AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+ [iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);],
+ am_cv_lib_iconv=yes
+ am_cv_func_iconv=yes)
+ LIBS="$am_save_LIBS"
+ fi
+ ])
+ if test "$am_cv_func_iconv" = yes; then
+ AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
+ AC_MSG_CHECKING([for iconv declaration])
+ AC_CACHE_VAL(am_cv_proto_iconv, [
+ AC_TRY_COMPILE([
+#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
+ am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
+ am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
+ AC_MSG_RESULT([$]{ac_t:-
+ }[$]am_cv_proto_iconv)
+ AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
+ [Define as const if the declaration of iconv() needs const.])
+ fi
+ LIBICONV=
+ if test "$am_cv_lib_iconv" = yes; then
+ LIBICONV="-liconv"
+ fi
+ AC_SUBST(LIBICONV)
+])
Index: libjava/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.129.2.13
diff -u -r1.129.2.13 Makefile.am
--- libjava/Makefile.am 2001/06/08 17:58:11 1.129.2.13
+++ libjava/Makefile.am 2001/07/06 20:01:07
@@ -76,8 +76,10 @@
GCJ_WITH_FLAGS = $(GCJ) --encoding=UTF-8
GCJCOMPILE = $(LIBTOOL) --tag=GCJ --mode=compile $(GCJ_WITH_FLAGS) -fassume-compiled -fclasspath=$(here) -L$(here) $(JC1FLAGS) -MD -MT $@ -MF $(@:.lo=.d) -c
-GCJLINK = $(LIBTOOL) --mode=link $(GCJ) -L$(here) $(JC1FLAGS) $(LDFLAGS) -o $@
-LIBLINK = $(LIBTOOL) --mode=link $(CC) -L$(here) $(JC1FLAGS) $(LDFLAGS) -o $@
+GCJLINK = $(LIBTOOL) --mode=link $(GCJ) -L$(here) $(JC1FLAGS) \
+ $(ICONV_LDFLAGS) $(LDFLAGS) -o $@
+LIBLINK = $(LIBTOOL) --mode=link $(CC) -L$(here) $(JC1FLAGS) \
+ $(ICONV_LDFLAGS) $(LDFLAGS) -o $@
## We define this because otherwise libtool can be run with different
## values of `CXX' and will then get confused and fail to work. So,
Index: libjava/configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/configure.in,v
retrieving revision 1.94
diff -u -r1.94 configure.in
--- configure.in 2001/06/08 23:40:17 1.94
+++ configure.in 2001/06/29 17:57:03
@@ -411,7 +411,7 @@
AC_CHECK_FUNCS(strerror ioctl select fstat open fsync sleep)
AC_CHECK_FUNCS(gmtime_r localtime_r readdir_r getpwuid_r getcwd)
AC_CHECK_FUNCS(access stat mkdir rename rmdir unlink realpath utime chmod)
- AC_CHECK_FUNCS(iconv nl_langinfo setlocale)
+ AC_CHECK_FUNCS(nl_langinfo setlocale)
AC_CHECK_FUNCS(inet_aton inet_addr, break)
AC_CHECK_FUNCS(inet_pton uname inet_ntoa)
AC_CHECK_FUNCS(backtrace fork execvp pipe sigaction)
@@ -420,6 +420,8 @@
AC_DEFINE(HAVE_DLADDR)])
AC_CHECK_FILES(/proc/self/exe, [
AC_DEFINE(HAVE_PROC_SELF_EXE)])
+
+ AM_ICONV
AC_CHECK_FUNCS(gethostbyname_r, [
AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Index: libjava/libgcj.spec.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/libgcj.spec.in,v
retrieving revision 1.18
diff -u -r1.18 libgcj.spec.in
--- libgcj.spec.in 2001/06/02 19:13:52 1.18
+++ libgcj.spec.in 2001/06/29 17:57:03
@@ -4,6 +4,6 @@
# to link with libgcj.
#
%rename lib liborig
-*lib: -lgcj -lm @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(libgcc) %(liborig)
+*lib: -lgcj -lm @LIBICONV@ @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(libgcc) %(liborig)
*jc1: @HASH_SYNC_SPEC@ @DIVIDESPEC@ @JC1GCSPEC@ @EXCEPTIONSPEC@