difference of the Solaris 2 ABI symbols bound to the base version.

During bootstrap, I get tons of warnings from Sun ld, though (with
COLLECT_NO_DEMANGLE set in the environment to make it easier to find
what's going on):

ld: warning: symbol `_ZGAN3gnu9classpath4jdwp7VMFrame8setValueEJviPNS1_5value5ValueE' has conflicting visibilities:
	(file libgcj.ver-sun visibility=D; file gnu/classpath/jdwp/.libs/natVMFrame.o visibility=H);
	gnu/classpath/jdwp/.libs/natVMFrame.o definition taken

What happens here is that the symbol, a virtual function, has been added
(with default visibility) to the generated mapfile, while in the object
file, it is marked hidden.  This cannot be detected in the nm -P output
used; one could try to run nm again without -P and detect this from
there.  I'm not sure this is worth the effort, though.  The fix would be
restricted to the make_sunver.pl script and completely transparent.  In
recent versions of Solaris 11 ld, the warning has been remove since ld
does the right thing here anyway.

Bootstrapped without regressions on Solaris 8 to 11, SPARC and x86, Sun
as and GNU as, Sun ld and GNU ld.

Ok for mainline after it becomes unfrozen again?

Besides, there are a couple of other shared libraries installed by
libjava, which may be internal implementation details and not usable by
end users.  Perhaps they should be installed into $pkglibdir instead?
Currently, this affects libgij, libgcj-tools, libjvm, lib-gnu-awt-xlib,
and libgcj_bc.  The maintainers should be able to easily decide where
this might apply.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2010-02-22  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* configure.ac (ANONVERSCRIPT): Handle sun style.
	Define ANONVERSCRIPT_GNU, ANONVERSCRIPT_SUN automake conditionals.
	* configure: Regenerate.

	* Makefile.am [ANONVERSCRIPT]: Protect GNU section with
	ANONVERSCRIPT_GNU.
	Introduce per-library $(lib)_la_version_arg, $(lib)_la_version_dep
	variables.
	[ANONVERSCRIPT_GNU] (version_arg): Default ld arg for version map.
	(version_dep): Likewise for dependency.
	Use them to set the per-library variables.
	[!ANONVERSCRIPT]: Provide them vor the unversioned case.
	[ANONVERSCRIPT_SUN]: Handle Sun symbol versioning.
	(libgcj_la_DEPENDENCIES): Unconditionally use
	$(libgcj_la_version_dep).
	(libgcj_la_LINK): Add $(libgcj_la_version_arg).
	(libgcj_noncore_la_DEPENDENCIES): Unconditionally use
	$(libgcj_la_version_dep).
	(libgcj_tools_la_LIBADD): Move -lm ...
	(libgcj_tools_la_LDFLAGS): ... here.
	(libgcj_tools_la_DEPENDENCIES): Add
	$(libgcj_tools_la_version_dep).
	(libgcj_tools_la_LINK): Add $(libgcj_tools_la_version_arg).
	(lib_gnu_awt_xlib_la_DEPENDENCIES): Add
	$(lib_gnu_awt_xlib_la_version_dep).
	(lib_gnu_awt_xlib_la_LINK): Add
	$(lib_gnu_awt_xlib_la_version_arg).
	(libgcj_bc_la_DEPENDENCIES): Add $(libgcj_bc_la_version_dep).
	(libgcj_bc_la_LINK): $(libgcj_bc_la_version_arg).
	[ANONVERSCRIPT && ANONVERSCRIPT_SUN] (%.ver-sun): New pattern rule.
	* Makefile.in: Regenerate.

	* libgcj.ver: Reformat.

diff -r f599dd8df876 libjava/Makefile.am
--- a/libjava/Makefile.am	Thu Jun 17 23:14:16 2010 +0200
+++ b/libjava/Makefile.am	Thu Jun 17 23:15:30 2010 +0200
@@ -291,7 +291,45 @@
 extra_ldflags = @extra_ldflags@
 
 if ANONVERSCRIPT
-extra_ldflags_libjava += -Wl,--version-script=$(srcdir)/libgcj.ver
+if ANONVERSCRIPT_GNU
+version_arg = -Wl,--version-script=$(srcdir)/libgcj.ver
+libgcj_la_version_arg = $(version_arg)
+libgcj_tools_la_version_arg = $(version_arg)
+lib_gnu_awt_xlib_la_version_arg = $(version_arg)
+libgcj_bc_la_version_arg = $(version_arg)
+
+version_dep = $(srcdir)/libgcj.ver
+libgcj_la_version_dep = $(version_dep)
+libgcj_tools_la_version_dep = $(version_dep)
+lib_gnu_awt_xlib_la_version_dep = $(version_dep)
+libgcj_bc_la_version_dep = $(version_dep)
+endif
+if ANONVERSCRIPT_SUN
+libgcj_la_version_arg = -Wl,-M,libgcj.ver-sun
+libgcj_tools_la_version_arg = -Wl,-M,libgcj_tools.ver-sun
+lib_gnu_awt_xlib_la_version_arg = -Wl,-M,lib_gnu_awt_xlib.ver-sun
+libgcj_bc_la_version_arg = -Wl,-M,libgcj_bc.ver-sun
+
+libgcj_la_version_dep = libgcj.ver-sun
+libgcj_tools_la_version_dep = libgcj_tools.ver-sun
+lib_gnu_awt_xlib_la_version_dep = lib_gnu_awt_xlib.ver-sun
+libgcj_bc_la_version_dep = libgcj_bc.ver-sun
+
+# The pattern rule necessary to build the *.ver-sun mapfiles is at the end
+# of the file, see below.
+endif
+else
+version_arg =
+libgcj_la_version_arg = $(version_arg)
+libgcj_tools_la_version_arg = $(version_arg)
+lib_gnu_awt_xlib_la_version_arg = $(version_arg)
+libgcj_bc_la_version_arg = $(version_arg)
+
+version_dep =
+libgcj_la_version_dep = $(version_dep)
+libgcj_tools_la_version_dep = $(version_dep)
+lib_gnu_awt_xlib_la_version_dep = $(version_dep)
+libgcj_bc_la_version_dep = $(version_dep)
 endif
 
 LTLDFLAGS = $(shell $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
@@ -463,11 +501,9 @@
 	java/process-$(PLATFORM).lo \
 	$(ALL_PACKAGE_SOURCE_FILES_LO) \
 	$(LIBLTDL) $(libgcj_la_LIBADD) \
-	$(LIBJAVA_CORE_EXTRA)
-if ANONVERSCRIPT
-libgcj_la_DEPENDENCIES += $(srcdir)/libgcj.ver
-endif
-libgcj_la_LINK = $(LIBLINK) $(libgcj_la_LDFLAGS)
+	$(LIBJAVA_CORE_EXTRA) \
+	$(libgcj_la_version_dep)
+libgcj_la_LINK = $(LIBLINK) $(libgcj_la_LDFLAGS) $(libgcj_la_version_arg)
 
 ## A hack to make sure the various gcj-related macros, like
 ## LTGCJCOMPILE, are defined by automake.  This is never actually
@@ -490,10 +526,7 @@
 libgcj_noncore_la_LDFLAGS = $(libgcj_la_LDFLAGS)
 libgcj_noncore_la_LIBADD = $(libgcj_noncore_la_LIBADD_SUBOBJECTS) libgcj.la
 libgcj_noncore_la_DEPENDENCIES = libgcj-$(gcc_version).jar $(LIBLTDL) \
-		$(libgcj_noncore_la_LIBADD) libgcj.la
-if ANONVERSCRIPT
-libgcj_noncore_la_DEPENDENCIES += $(srcdir)/libgcj.ver
-endif
+		$(libgcj_noncore_la_LIBADD) libgcj.la $(libgcj_la_version_dep)
 libgcj_noncore_la_LINK = $(libgcj_la_LINK)
 
 endif	# BUILD_SUBLIBS
@@ -509,13 +542,15 @@
  -fsource-filename=$(here)/classpath/tools/all-classes.lst
 libgcj_tools_la_LDFLAGS = -rpath $(toolexeclibdir) \
  -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
- $(LIBGCJ_LD_SYMBOLIC_FUNCTIONS) $(LIBJAVA_LDFLAGS_NOUNDEF)
-libgcj_tools_la_LIBADD = libgcj.la -lm
-libgcj_tools_la_DEPENDENCIES = libgcj.la libgcj.spec
+ $(LIBGCJ_LD_SYMBOLIC_FUNCTIONS) $(LIBJAVA_LDFLAGS_NOUNDEF) -lm
+libgcj_tools_la_LIBADD = libgcj.la
+libgcj_tools_la_DEPENDENCIES = libgcj.la libgcj.spec \
+ $(libgcj_tools_la_version_dep)
 if BUILD_SUBLIBS
 libgcj_tools_la_DEPENDENCIES += libgcj-noncore.la
 endif
-libgcj_tools_la_LINK = $(LIBLINK) $(libgcj_tools_la_LDFLAGS)
+libgcj_tools_la_LINK = $(LIBLINK) $(libgcj_tools_la_LDFLAGS) \
+ $(libgcj_tools_la_version_arg)
 
 ## libjvm.so
 libjvm_la_SOURCES = jni-libjvm.cc
@@ -543,6 +578,7 @@
 lib_gnu_awt_xlib_la_LIBADD = gnu/awt/xlib.lo gnu/gcj/xlib.lo
 lib_gnu_awt_xlib_la_DEPENDENCIES = libgcj-$(gcc_version).jar \
 	libgcj.la libgcj.spec \
+	$(lib_gnu_awt_xlib_la_version_dep) \
 	$(lib_gnu_awt_xlib_la_LIBADD)
 if BUILD_SUBLIBS
 lib_gnu_awt_xlib_la_DEPENDENCIES += libgcj-noncore.la
@@ -558,7 +594,8 @@
 	@X_PRE_LIBS@ @X_LIBS@ -lX11 @X_EXTRA_LIBS@ \
         -rpath $(toolexeclibdir) $(LIBJAVA_LDFLAGS_NOUNDEF) \
         -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LIBGCJ_LD_SYMBOLIC)
-lib_gnu_awt_xlib_la_LINK = $(LIBLINK) $(lib_gnu_awt_xlib_la_LDFLAGS)
+lib_gnu_awt_xlib_la_LINK = $(LIBLINK) $(lib_gnu_awt_xlib_la_LDFLAGS) \
+	$(lib_gnu_awt_xlib_la_version_arg)
 
 ## Support for libgcj_bc: dummy shared library.
 ##
@@ -567,8 +604,9 @@
 libgcj_bc_la_SOURCES = libgcj_bc.c
 libgcj_bc_la_LDFLAGS = -rpath $(toolexeclibdir) -no-static -version-info 1:0:0 \
 	$(LIBGCJ_LD_SYMBOLIC_FUNCTIONS) $(LIBJAVA_LDFLAGS_NOUNDEF)
-libgcj_bc_la_DEPENDENCIES = libgcj.la
-libgcj_bc_la_LINK = $(LIBLINK) $(libgcj_bc_la_LDFLAGS)
+libgcj_bc_la_DEPENDENCIES = libgcj.la $(libgcj_bc_la_version_dep)
+libgcj_bc_la_LINK = $(LIBLINK) $(libgcj_bc_la_LDFLAGS) \
+	$(libgcj_bc_la_version_arg)
 ## This is specific to Linux/{Free,Net,Open}BSD/Hurd and perhaps few others.
 ## USE_LIBGCJ_BC shouldn't be set on other targets.
 libgcj_bc_dummy_LINK = $(CC) -L$(here)/.libs $(CFLAGS) $(LDFLAGS) -shared \
@@ -1574,3 +1612,22 @@
 	$(MULTICLEAN) $(AM_MAKEFLAGS) DO=distclean multi-clean
 maintainer-clean-multi:
 	$(MULTICLEAN) $(AM_MAKEFLAGS) DO=maintainer-clean multi-clean
+
+if ANONVERSCRIPT
+if ANONVERSCRIPT_SUN
+# This must be at the end of the Makefile, otherwise .SECONDEXPANSION
+# causes expansion of filenames with $ in their names, which breaks the build.
+# .SECONDEXPANSION is necessary to allow the use of automatic variables ($@
+# in this case) in the requisites of pattern rules.
+.SECONDEXPANSION:
+
+%.ver-sun : $(srcdir)/libgcj.ver \
+		$(top_srcdir)/../contrib/make_sunver.pl \
+		$$($$(basename $$@)_la_OBJECTS) $$($$(basename $$@)_la_LIBADD)
+	perl $(top_srcdir)/../contrib/make_sunver.pl \
+	  $(srcdir)/libgcj.ver \
+	 `echo $($(basename $@)_la_OBJECTS) $($(basename $@)_la_LIBADD) | \
+	    sed 's,\([^/ 	]*\)\.l\([ao]\),.libs/\1.\2,g'` \
+	 > $@ || (rm -f $@ ; exit 1)
+endif
+endif
diff -r f599dd8df876 libjava/configure.ac
--- a/libjava/configure.ac	Thu Jun 17 23:14:16 2010 +0200
+++ b/libjava/configure.ac	Thu Jun 17 23:15:30 2010 +0200
@@ -1772,13 +1772,24 @@
   [libjava_cv_anon_version_script],
   [save_CFLAGS="$CFLAGS"; save_LDFLAGS="$LDFLAGS"
    libjava_cv_anon_version_script=no
-   CFLAGS="$CFLAGS -fPIC"; LDFLAGS="$LDFLAGS -shared -Wl,--version-script,conftest.map"
+   CFLAGS="$CFLAGS -fPIC";
+   LDFLAGS="$LDFLAGS -shared -Wl,--version-script,conftest.map"
    echo '{ global: globalsymb*; local: *; };' > conftest.map
    AC_TRY_LINK(void globalsymbol (void) {} void localsymbol (void) {},,
-	       [libjava_cv_anon_version_script=yes], [])
+	       [libjava_cv_anon_version_script=gnu], [])
+   if test x$libjava_cv_anon_version_script = xno; then
+     LDFLAGS="$save_LDFLAGS"
+     LDFLAGS="$LDFLAGS -shared -Wl,-M,conftest.map"
+     # Sun ld doesn't understand wildcards here.
+     echo '{ global: globalsymbol; local: *; };' > conftest.map
+     AC_TRY_LINK(void globalsymbol (void) {} void localsymbol (void) {},,
+	         [libjava_cv_anon_version_script=sun], [])
+   fi
    CFLAGS="$save_CFLAGS"; LDFLAGS="$save_LDFLAGS"
   ])
-AM_CONDITIONAL(ANONVERSCRIPT, test "$libjava_cv_anon_version_script" = yes)
+AM_CONDITIONAL(ANONVERSCRIPT, test "$libjava_cv_anon_version_script" != no)
+AM_CONDITIONAL(ANONVERSCRIPT_GNU, test "$libjava_cv_anon_version_script" = gnu)
+AM_CONDITIONAL(ANONVERSCRIPT_SUN, test "$libjava_cv_anon_version_script" = sun)
 
 # Check if linker supports static linking on a per library basis
 LD_START_STATIC_SPEC=
diff -r f599dd8df876 libjava/libgcj.ver
--- a/libjava/libgcj.ver	Thu Jun 17 23:14:16 2010 +0200
+++ b/libjava/libgcj.ver	Thu Jun 17 23:15:30 2010 +0200
@@ -2,6 +2,12 @@
 # symbols in libgcj.so.
 
 {
-  global: Jv*; _Jv_*; __gcj_personality_v0; __gcj_personality_sj0; _Z*;
-  local: *;
+  global:
+    Jv*;
+    _Jv_*;
+    __gcj_personality_v0;
+    __gcj_personality_sj0;
+    _Z*;
+  local:
+    *;
 };
