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


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

PATCH: Support dynamic libraries on FreeBSD/i386


I would like to thank whomever updated the boehm-gc debugging
information recently.  It inspired me to take another crack at getting
my platform working in what should be its default configuration.  It
is clear (to me now ;-) that a shared library should not be built for
a port until DYNAMIC_LOADING is defined for that port in
include/private/gcconfig.h .

These words, in doc/README, just didn't make the point clear enough to
me (or, I dare say, they implied that I didn't need to worry about
this issue in the nominal case):

``4.  dyn_load.c
        This provides a routine that allows the collector to scan data
        segments associated with dynamic libraries.  Often it is not
        necessary to provide this routine unless user-written dynamic
        libraries are used.''

Is libgcjgc.so.1 considered a user-written dynamic library itself?  I
think the answer is yes since the typed allocator itself allocates
memory.  Since this data is referred to within the boehm-gc library
code and data segments only (i.e. a handle is given to the program),
the memory is freed too early since boehm-gc isn't even scanning
itself when it is built as a dynamic library for a platform that
doesn't setup to use DYNAMIC_LOADING...

This is a non-trivial issue since we made --enable-shared the default
for all gcc ports sometime back.  Since I don't know how to check all
that at run-time to help other port maintainers, I have updated the
debugging documentation to include an explicit step to try the static
library before going down other interesting debugging paths.

(Humm: How about we unconditionally define DYNAMIC_LOADING when
 configured to build a dynamic version of boehm-gc?  That way we will
 fail to compile dyn_load.c instead of building an untenable situation
 to be debugged later.)

With this patch, `gmake -C i386-unknown-freebsd4.3/boehm-gc check' now
succeeds with --disable-threads .  This puts us on par with the
version of boehm-gc in our ports collection (which, in retrospect, I
can plainly see was always built into static libraries).

I am requesting to apply this patch to the gcc mainline.  But I also
wanted this additional information to hit the archives so other port
maintainers might see it.

2001-08-20  Loren J. Rittle  <ljrittle@acm.org>

	* doc/debugging.html: Add another likely problem and solution.
	* dyn_load.c: Enable existing code path which supports FreeBSD.
	* include/private/gcconfig.h (FREEBSD): Define DYNAMIC_LOADING.

Regards,
Loren

Index: doc/debugging.html
===================================================================
RCS file: /cvs/gcc/egcs/boehm-gc/doc/debugging.html,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 debugging.html
*** debugging.html	2001/08/17 18:39:18	1.1.1.1
--- debugging.html	2001/08/21 01:52:35
***************
*** 209,214 ****
--- 209,216 ----
  <OL>
  <LI> If you are using the incremental collector try turning it off for
  debugging.
+ <LI> Is you are using a shared library try the static library (if that
+ works, you must ensure that DYNAMIC_LOADING is defined).
  <LI> Try to reproduce the problem with fully debuggable unoptimized code.
  This will eliminate the last possibility, as well as making debugging easier.
  <LI> Try replacing any suspect typed allocation and <TT>GC_malloc_atomic</tt>
Index: dyn_load.c
===================================================================
RCS file: /cvs/gcc/egcs/boehm-gc/dyn_load.c,v
retrieving revision 1.12
diff -c -r1.12 dyn_load.c
*** dyn_load.c	2001/08/18 01:04:43	1.12
--- dyn_load.c	2001/08/21 01:36:10
***************
*** 53,59 ****
      !(defined(ALPHA) && defined(OSF1)) && \
      !defined(HPUX) && !(defined(LINUX) && defined(__ELF__)) && \
      !defined(RS6000) && !defined(SCO_ELF) && \
!     !(defined(NETBSD) && defined(__ELF__)) && !defined(HURD)
   --> We only know how to find data segments of dynamic libraries for the
   --> above.  Additional SVR4 variants might not be too
   --> hard to add.
--- 53,60 ----
      !(defined(ALPHA) && defined(OSF1)) && \
      !defined(HPUX) && !(defined(LINUX) && defined(__ELF__)) && \
      !defined(RS6000) && !defined(SCO_ELF) && \
!     !(defined(NETBSD) && defined(__ELF__)) && !defined(HURD) && \
!     !(defined(FREEBSD) && defined(__ELF__))
   --> We only know how to find data segments of dynamic libraries for the
   --> above.  Additional SVR4 variants might not be too
   --> hard to add.
***************
*** 243,249 ****
  # endif /* SUNOS */
  
  #if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \
!     (defined(NETBSD) && defined(__ELF__)) || defined(HURD)
  
  
  #ifdef USE_PROC_FOR_LIBRARIES
--- 244,251 ----
  # endif /* SUNOS */
  
  #if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \
!     (defined(NETBSD) && defined(__ELF__)) || defined(HURD) || \
!     (defined(FREEBSD) && defined(__ELF__))
  
  
  #ifdef USE_PROC_FOR_LIBRARIES
Index: include/private/gcconfig.h
===================================================================
RCS file: /cvs/gcc/egcs/boehm-gc/include/private/gcconfig.h,v
retrieving revision 1.4
diff -c -r1.4 gcconfig.h
*** gcconfig.h	2001/08/18 01:04:43	1.4
--- gcconfig.h	2001/08/21 01:36:10
***************
*** 1005,1010 ****
--- 1005,1013 ----
  #	define OS_TYPE "FREEBSD"
  #	define MPROTECT_VDB
  #	define FREEBSD_STACKBOTTOM
+ #       ifdef __ELF__
+ #           define DYNAMIC_LOADING
+ #       endif
  #   endif
  #   ifdef NETBSD
  #	define OS_TYPE "NETBSD"


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