This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: install libgtkpeer.so and libjawt.so in versioned library directory
Bryce McKinlay wrote:
Thomas Fitzsimmons wrote:
Maybe, but you simply cannot assume that argv[0] contains the path to
the current executable. It's a fragile technique that runs the risk
of horrors like this one. /proc/self/exe works on Linux.
OK, I'll re-add the GIJ_EXECUTABLE logic if Bryce agrees.
Well, I agree that argv[0] can't be used. However, using a hardcoded
path means that:
- gij won't work from the testsuite, or the wrong gij will be tested
- gij will break if the user moves an installed libgcj tree
On Linux/Solaris/etc, we can use readlink("/proc/self/exe") to get the
definitive path to the binary. On platforms where this is not available,
we could just fall back to not doing the exec, and leave a fixme for
those platforms to implement their equivalent if needed.
On IRC, tromey suggested simply linking gij with -rpath. This works and
eliminates the need for re-execing altogether. I've committed the attached
patch, which adds -rpath to the gij link line, removes the re-exec'ing from gij
and also changes the way the Qt peers are installed and loaded, to match the GTK
peer changes.
Tom
2006-06-07 Thomas Fitzsimmons <fitzsim@redhat.com>
* scripts/makemake.tcl (emit_bc_rule): Do not skip
gnu-java-awt-peer-qt.lo.
* configure.ac (QT_AWT): Remove conditional.
Do not add gnu/java/awt/peer/qt to standard.omit.
* classpath/native/jni/qt-peer/Makefile.am: Install libqtpeer.so
in GCJ's versioned library directory.
* classpath/gnu/java/awt/peer/qt/QtToolkit.java (initToolkit):
Load libqtpeer.so unconditionally.
* gij.cc (main): Do not re-exec gij.
* Makefile.am: Remove lib-gnu-java-awt-peer-qt.lo build logic.
(gij_LDFLAGS): Point -rpath at GCJ's versioned library directory
when linking gij.
Index: scripts/makemake.tcl
===================================================================
--- scripts/makemake.tcl (revision 114472)
+++ scripts/makemake.tcl (working copy)
@@ -256,11 +256,7 @@
puts "\t@rm -f $tname"
puts ""
- # We skip these because they are built into their own libraries and
- # are handled specially in Makefile.am.
- if {$loname != "gnu-java-awt-peer-qt.lo"} {
- lappend bc_objects $loname
- }
+ lappend bc_objects $loname
}
# Emit a rule for a 'package' package.
Index: configure.ac
===================================================================
--- configure.ac (revision 114472)
+++ configure.ac (working copy)
@@ -236,7 +236,6 @@
done
AM_CONDITIONAL(XLIB_AWT, test "$use_xlib_awt" = yes)
-AM_CONDITIONAL(QT_AWT, test "$use_qt_awt" = yes)
# Create standard.omit based on decisions we just made.
cp $srcdir/standard.omit.in standard.omit
@@ -244,9 +243,6 @@
echo gnu/awt/xlib >> standard.omit
echo gnu/gcj/xlib >> standard.omit
fi
-if test "$use_qt_awt" != yes; then
- echo gnu/java/awt/peer/qt >> standard.omit
-fi
if test -z "${with_multisubdir}"; then
builddotdot=.
Index: classpath/native/jni/qt-peer/Makefile.am
===================================================================
--- classpath/native/jni/qt-peer/Makefile.am (revision 114472)
+++ classpath/native/jni/qt-peer/Makefile.am (working copy)
@@ -1,8 +1,11 @@
# Qt AWT backend for Classpath
#
-## GCJ LOCAL: don't install this library
-noinst_LTLIBRARIES = libqtpeer.la
+## GCJ LOCAL: install this library in GCJ's versioned library
+## directory
+gcc_version := $(shell cat $(top_srcdir)/../../gcc/BASE-VER)
+gcjversionedlibdir = $(libdir)/gcj-$(gcc_version)
+gcjversionedlib_LTLIBRARIES = libqtpeer.la
AM_LDFLAGS = @CLASSPATH_MODULE@ @QT_LIBS@
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
@@ -74,6 +77,10 @@
slotcallbacks.cpp \
slotcallbacks.h
+## GCJ LOCAL: encode the library path and use GCJ's library version
+libqtpeer_la_LDFLAGS = -rpath $(gcjversionedlibdir) \
+ -version-info `grep -v '^\#' $(top_srcdir)/../libtool-version`
+
BUILT_SOURCES = $(libqtpeer_la_MOC)
CLEANFILES = so_locations $(BUILT_SOURCES)
Index: classpath/gnu/java/awt/peer/qt/QtToolkit.java
===================================================================
--- classpath/gnu/java/awt/peer/qt/QtToolkit.java (revision 114472)
+++ classpath/gnu/java/awt/peer/qt/QtToolkit.java (working copy)
@@ -136,8 +136,7 @@
{
eventQueue = new EventQueue();
repaintThread = new QtRepaintThread();
- if (Configuration.INIT_LOAD_LIBRARY)
- System.loadLibrary("qtpeer");
+ System.loadLibrary("qtpeer");
String theme = null;
try
Index: gij.cc
===================================================================
--- gij.cc (revision 114472)
+++ gij.cc (working copy)
@@ -14,7 +14,6 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include <unistd.h>
static void
help ()
@@ -72,52 +71,6 @@
int
main (int argc, char const** argv)
{
- // libjawt.so must be installed in GCJ's versioned directory and not
- // the main library directory so that it doesn't override other
- // libjawt.so implementations. Programs that use the AWT Native
- // Interface contain a JNI library that links to libjawt.so. We do
- // not want to require that users explicitly add GCJ's versioned
- // directory to LD_LIBRARY_PATH when running such programs.
-
- // Simply adding GCJ's versioned directory to the module load path
- // does not solve this problem since libltdl searches its module
- // load path only for object that it will dlopen; dependencies of
- // these dynamically loaded objects are searched for in
- // LD_LIBRARY_PATH.
-
- // In addition, setting LD_LIBRARY_PATH from within the current
- // process does not alter the dependency search path, since it is
- // computed on startup. This behaviour makes sense since
- // LD_LIBRARY_PATH is designed to allow users to override the path
- // set by a program. This re-spawning trick makes it impossible to
- // override, using LD_LIBRARY_PATH, the versioned directories
- // searched by gij.
-
- // Check if LD_LIBRARY_PATH is already prefixed with
- // GCJ_VERSIONED_LIBDIR. If not, export LD_LIBRARY_PATH prefixed
- // with GCJ_VERSIONED_LIBDIR and re-spawn gij.
- char *libpath = getenv (LTDL_SHLIBPATH_VAR);
- char *newpath = _Jv_PrependVersionedLibdir (libpath);
-
- if (! libpath || strcmp (libpath, newpath))
- {
- char *buffer = (char *) JvMalloc (strlen (LTDL_SHLIBPATH_VAR)
- + strlen (newpath) + 2);
- strcpy (buffer, LTDL_SHLIBPATH_VAR);
- strcat (buffer, "=");
- strcat (buffer, newpath);
- putenv (buffer);
- JvFree (newpath);
-
- int error_code = execvp (argv[0], (char* const*) argv);
-
- fprintf (stderr, "error re-spawning gij with new "
- LTDL_SHLIBPATH_VAR " value: %s\n", strerror (error_code));
-
- return error_code;
- }
- JvFree (newpath);
-
JvVMInitArgs vm_args;
bool jar_mode = false;
Index: Makefile.am
===================================================================
--- Makefile.am (revision 114472)
+++ Makefile.am (working copy)
@@ -40,10 +40,6 @@
toolexeclib_LTLIBRARIES += lib-gnu-awt-xlib.la
endif
-if QT_AWT
-toolexeclib_LTLIBRARIES += lib-gnu-java-awt-peer-qt.la
-endif
-
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libgcj.pc
@@ -247,18 +243,6 @@
## not available.
./gcj-dbtool -n $(db_name) || touch $(db_name)
-lib_gnu_java_awt_peer_qt_la_SOURCES =
-lib_gnu_java_awt_peer_qt_la_LIBADD = \
- gnu-java-awt-peer-qt.lo \
- classpath/native/jni/qt-peer/libqtpeer.la
-lib_gnu_java_awt_peer_qt_la_DEPENDENCIES = gnu-java-awt-peer-qt.lo \
- classpath/native/jni/qt-peer/libqtpeer.la \
- libgcj-$(gcc_version).jar libgcj.la libgcj.spec
-## The mysterious backslash in the grep pattern is consumed by make.
-lib_gnu_java_awt_peer_qt_la_LDFLAGS = \
- -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LIBGCJ_LD_SYMBOLIC) $(X_LIBS) -lXtst
-lib_gnu_java_awt_peer_qt_la_LINK = $(LIBLINK)
-
lib_gnu_awt_xlib_la_SOURCES = $(xlib_nat_source_files)
lib_gnu_awt_xlib_la_LIBADD = gnu/awt/xlib.lo gnu/gcj/xlib.lo
lib_gnu_awt_xlib_la_DEPENDENCIES = libgcj-$(gcc_version).jar \
@@ -696,7 +680,8 @@
## We need -nodefaultlibs because we want to avoid gcj's `-lgcj'. We
## need this because we are explicitly using libtool to link using the
## `.la' file.
-gij_LDFLAGS = -rpath $(toolexeclibdir) -shared-libgcc $(THREADLDFLAGS)
+gij_LDFLAGS = -rpath $(libdir)/gcj-$(gcc_version) -rpath $(toolexeclibdir) \
+ -shared-libgcc $(THREADLDFLAGS)
gij_LINK = $(GCJLINK)
## See jv_convert_LDADD.
gij_LDADD = -L$(here)/.libs libgij.la