discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC/RFA] PR 11572 GNU ObjC Runtime for Darwin


From: David Ayers
Subject: [RFC/RFA] PR 11572 GNU ObjC Runtime for Darwin
Date: Tue, 26 Aug 2003 15:06:33 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030507

 Hello,

This patch reactivates the GNU ObjC Runtime on Darwin and installs its headers into a special subdirectory of /include called /libobjc_gnu and also appends _gnu to the library name (i.e.: libobjc_gnu and libobjc_gnu_gc respectively) when installing on Darwin. This is intended to fix:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11572

This patch also includes the gcc-lib->gcc fixes, which haven't been committed yet for easy testing. (Any insight on the hold up? Alex doesn't have write access, just in case someone's waiting on him to commit it.)
http://gcc.gnu.org/ml/gcc-patches/2003-08/msg01357.html
http://gcc.gnu.org/ml/gcc-patches/2003-08/msg01370.html
http://gcc.gnu.org/ml/gcc-patches/2003-08/msg01406.html
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12034

This patch hasn't been tested on Darwin, as I don't have a Darwin to test it. But I've been tested and bootstrapped a slightly modified version that does the same for linux. I'm also not sure how to create a test case for this. Any pointers are appreciated.

I have cc'ed Bill Northcott, as the SWARM project has recently seen some trouble with the Apple compiler when porting to OS X and may be interested in the availability of the GNU ObjC Runtime on Darwin.

I previously tried playing with specs to allow -fgnu-runtime to implicitly correct the include path to find the correct <objc/objc.h> and to set either -L or -l flags. I've added some comments below about this endeavour. But the result was, "don't have -f imply anything about -I, -L or -l" so I've also added a note the description of the flag.

Nicola, I think we can sort the flags out during configuration of gnustep-make on Darwin by parsing gcc -print-search-dirs and testing for the installed runtime libraries, insulating the complexity for our GNUstep users. Does this sound acceptable? Carl?

About Using SPECS to imply -I, -L and -l flags...
To determine the location of the libobjc_gnu directory during spec evaluation, I've had added a gcc_include_dir_spec_function to gcc.c. I then considered a more general function named something like: gcc_config_spec_function() that took a key as an argument. A key from a well known set, which specifies which type of gcc configuration specific information is requested. Candidates for keys would have been something like:

gcc_include_dir
standard_exec_prefix
standard_libexec_prefix
standard_bindir_prefix
tool_base_prefix
default_target_version
default_target_machine
...
[someone with a better understanding of the different configuration possibilities should propose a better list]

I also played with keeping the library name but installing it into a special directory and use a similar mechanism to set a -L flag. But at execution time one would still have to play with ld.so.conf/LD_LIBRARY_PATH to find the "correct" library. That's when I decided to install it in the standard location but to give it a new name. But the new name (-lobjc_gnu)would have to be provided explicitly and most current projects provide -lobjc already. Therefore I've decided that the -I SPEC handling should also be left to the developer.

top:
2003-08-26  David Ayers  <d.ayers@inode.at>

   libobjc/11572
   * configure.in: Allow configuration of libobjc on Darwin.
   * configure: Regenerate.

gcc:
2003-08-26  David Ayers  <d.ayers@inode.at>

   libobjc/11572
   * doc/invoke.texi:  Clarify the implications of
   -fgnu-runtime and -fnext-runtime.

libobjc:
2003-08-26  David Ayers  <d.ayers@inode.at>

   libobjc/11572
   * configure.in: Set special libobjc_gnu directory name
   for headers and append '_gnu' to library names on Darwin.
   Updated some comments.
   * configure: Regenerate.
   * Makefile.in:  Allow for installing headers in special
   subdirectory and libraries with special extension.
   Reformat for coding standards.

Index: configure
===================================================================
RCS file: /cvsroot/gcc/gcc/configure,v
retrieving revision 1.112
diff -u -r1.112 configure
--- configure   23 Aug 2003 04:17:04 -0000      1.112
+++ configure   26 Aug 2003 10:19:33 -0000
@@ -1087,7 +1087,7 @@
     ;;
   *-*-darwin*)
     noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes gdb gprof"
-    noconfigdirs="$noconfigdirs target-libobjc ${libgcj}"
+    noconfigdirs="$noconfigdirs ${libgcj}"
     ;;
   *-*-freebsd[12] | *-*-freebsd[12].* | *-*-freebsd*aout*)
     noconfigdirs="$noconfigdirs target-newlib target-libgloss ${libgcj}"
Index: configure.in
===================================================================
RCS file: /cvsroot/gcc/gcc/configure.in,v
retrieving revision 1.253
diff -u -r1.253 configure.in
--- configure.in        23 Aug 2003 04:17:04 -0000      1.253
+++ configure.in        26 Aug 2003 10:19:33 -0000
@@ -338,7 +338,7 @@
     ;;
   *-*-darwin*)
     noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes gdb gprof"
-    noconfigdirs="$noconfigdirs target-libobjc ${libgcj}"
+    noconfigdirs="$noconfigdirs ${libgcj}"
     ;;
   *-*-freebsd[[12]] | *-*-freebsd[[12]].* | *-*-freebsd*aout*)
     noconfigdirs="$noconfigdirs target-newlib target-libgloss ${libgcj}"
Index: gcc/doc/invoke.texi
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.330
diff -u -r1.330 invoke.texi
--- gcc/doc/invoke.texi 22 Aug 2003 22:36:42 -0000      1.330
+++ gcc/doc/invoke.texi 26 Aug 2003 10:19:39 -0000
@@ -1783,6 +1783,9 @@
 @opindex fgnu-runtime
 Generate object code compatible with the standard GNU Objective-C
 runtime.  This is the default for most types of systems.
+Note this option does not imply any -I, -L or -l flags to determine
+which runtime headers are included and against which runtime library
+the executable is linked.
 
 @item -fnext-runtime
 @opindex fnext-runtime
@@ -1790,6 +1793,9 @@
 for NeXT-based systems, including Darwin and Mac OS X@.  The macro
 @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
 used.
+Note this option does not imply any -I, -L or -l flags to determine
+which runtime headers are included and against which runtime library
+the executable is linked.
 
 @item -gen-decls
 @opindex gen-decls
Index: libobjc/Makefile.in
===================================================================
RCS file: /cvsroot/gcc/gcc/libobjc/Makefile.in,v
retrieving revision 1.24
diff -u -r1.24 Makefile.in
--- libobjc/Makefile.in 23 May 2003 20:04:58 -0000      1.24
+++ libobjc/Makefile.in 26 Aug 2003 10:19:43 -0000
@@ -39,11 +39,12 @@
 toolexecdir = @glibcpp_toolexecdir@
 glibcpp_toolexecdir = @glibcpp_toolexecdir@
 glibcpp_toolexeclibdir = @glibcpp_toolexeclibdir@
+install_inc_subdir = @install_inc_subdir@
 
 top_builddir = .
 
 libdir = $(exec_prefix)/lib
-libsubdir = $(libdir)/gcc-lib/$(target_alias)/$(gcc_version)
+libsubdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)
 
 # Multilib support variables.
 MULTISRCTOP =
@@ -103,6 +104,8 @@
 OBJC_THREAD_FILE=thr-objc
 OBJC_BOEHM_GC=@OBJC_BOEHM_GC@
 
+LIBOBJCNAME=@LIBOBJCNAME@
+
 .SUFFIXES:
 .SUFFIXES: .c .m .lo
 
@@ -137,7 +140,7 @@
        "libsubdir=$(libsubdir)" \
        "tooldir=$(tooldir)"
 
-all: libobjc.la $(OBJC_BOEHM_GC)
+all: $(LIBOBJCNAME).la $(OBJC_BOEHM_GC)
        : $(MAKE) ; exec $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all
 
 # User-visible header files.
@@ -261,12 +264,12 @@
 
 doc: info dvi html
 
-libobjc.la: $(OBJS)
+$(LIBOBJCNAME).la: $(OBJS)
        $(LIBTOOL_LINK) $(CC) -o $@ $(OBJS) \
                -rpath $(glibcpp_toolexeclibdir) \
                -version-info $(LIBOBJC_VERSION)
 
-libobjc_gc.la: $(OBJS_GC)
+$(LIBOBJCNAME)_gc.la: $(OBJS_GC)
        $(LIBTOOL_LINK) $(CC) -o $@ $(OBJS_GC) \
                -rpath $(glibcpp_toolexeclibdir) \
                -version-info $(LIBOBJC_GC_VERSION)
@@ -277,23 +280,30 @@
 # without extra code but since I don't have a win machine to test 
 # if it already works, I leave the old code here.
 #
-libobjc_s.a: libobjc.la
-       mv libobjc.a libobjc_s.a
+$(LIBOBJCNAME)_s.a: $(LIBOBJCNAME).la
+       mv $(LIBOBJCNAME).a $(LIBOBJCNAME)_s.a
 
 # Create a relocatable DLL
-libobjc.dll: libobjc_s.a libobjc_entry.o
-       $(CC) -mdll -Wl,--base-file -Wl,libobjc.base \
-               -o libobjc.dll libobjc_s.a libobjc_entry.o -lkernel32
-       $(DLLTOOL) --dllname libobjc.dll --def $(srcdir)/libobjc.def \
-               --base-file libobjc.base --output-exp libobjc.exp
-       $(GCC_FOR_TARGET) -mdll -Wl,--base-file libobjc.base libobjc.exp \
-               -o libobjc.dll libobjc_s.a libobjc_entry.o -lkernel32
-       $(DLLTOOL) --dllname libobjc.dll --def $(srcdir)/libobjc.def \
-               --base-file libobjc.base --output-exp libobjc.exp
-       $(GCC_FOR_TARGET) libobjc.exp -mdll \
-               -o libobjc.dll libobjc_s.a libobjc_entry.o -lkernel32
-       $(DLLTOOL) --dllname libobjc.dll --def $(srcdir)/libobjc.def \
-               --output-lib libobjc.a
+$(LIBOBJCNAME).dll: $(LIBOBJCNAME)_s.a $(LIBOBJCNAME)_entry.o
+       $(CC) -mdll -Wl,--base-file -Wl,$(LIBOBJCNAME).base \
+               -o $(LIBOBJCNAME).dll $(LIBOBJCNAME)_s.a \
+               $(LIBOBJCNAME)_entry.o -lkernel32
+       $(DLLTOOL) --dllname $(LIBOBJCNAME).dll \
+               --def $(srcdir)/$(LIBOBJCNAME).def \
+               --base-file $(LIBOBJCNAME).base --output-exp $(LIBOBJCNAME).exp
+       $(GCC_FOR_TARGET) -mdll -Wl,--base-file $(LIBOBJCNAME).base \
+               $(LIBOBJCNAME).exp \
+               -o $(LIBOBJCNAME).dll $(LIBOBJCNAME)_s.a \
+               $(LIBOBJCNAME)_entry.o -lkernel32
+       $(DLLTOOL) --dllname $(LIBOBJCNAME).dll \
+               --def $(srcdir)/$(LIBOBJCNAME).def \
+               --base-file $(LIBOBJCNAME).base --output-exp $(LIBOBJCNAME).exp
+       $(GCC_FOR_TARGET) $(LIBOBJCNAME).exp -mdll \
+               -o $(LIBOBJCNAME).dll $(LIBOBJCNAME)_s.a \
+               $(LIBOBJCNAME)_entry.o -lkernel32
+       $(DLLTOOL) --dllname $(LIBOBJCNAME).dll \
+               --def $(srcdir)/$(LIBOBJCNAME).def \
+               --output-lib $(LIBOBJCNAME).a
 #
 #
 #
@@ -319,28 +329,33 @@
 install: install-libs install-headers
 
 install-libs: installdirs
-       $(SHELL) $(toplevel_srcdir)/mkinstalldirs 
$(DESTDIR)$(glibcpp_toolexeclibdir)
-       $(LIBTOOL_INSTALL) $(INSTALL) libobjc.la 
$(DESTDIR)$(glibcpp_toolexeclibdir);
+       $(SHELL) $(toplevel_srcdir)/mkinstalldirs \
+         $(DESTDIR)$(glibcpp_toolexeclibdir)
+       $(LIBTOOL_INSTALL) $(INSTALL) $(LIBOBJCNAME).la \
+         $(DESTDIR)$(glibcpp_toolexeclibdir)/$(LIBOBJCNAME).la;
        if [ "$(OBJC_BOEHM_GC)" ]; then \
-         $(LIBTOOL_INSTALL) $(INSTALL) libobjc_gc.la \
-                               $(DESTDIR)$(glibcpp_toolexeclibdir);\
+         $(LIBTOOL_INSTALL) $(INSTALL) $(LIBOBJCNAME)_gc.la \
+           $(DESTDIR)$(glibcpp_toolexeclibdir)/$(LIBOBJCNAME)_gc.la;\
        fi
        $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO="$@"
-       @-$(LIBTOOL) --mode=finish $(DESTDIR)$(glibcpp_toolexeclibdir)
+       @-$(LIBTOOL) --mode=finish \
+         $(DESTDIR)$(glibcpp_toolexeclibdir)
 
 # Copy Objective C headers to installation include directory.
 install-headers:
-       $(SHELL) $(toplevel_srcdir)/mkinstalldirs 
$(DESTDIR)$(libsubdir)/include/objc
+       $(SHELL) $(toplevel_srcdir)/mkinstalldirs \
+         $(DESTDIR)$(libsubdir)/include$(install_inc_subdir)/objc
        for file in $(OBJC_H); do \
          realfile=$(srcdir)/objc/$${file}; \
-         $(INSTALL_DATA) $${realfile} $(DESTDIR)$(libsubdir)/include/objc; \
+         $(INSTALL_DATA) $${realfile} \
+           $(DESTDIR)$(libsubdir)/include$(install_inc_subdir)/objc; \
        done
 
 check uninstall install-strip dist installcheck installdirs:
 
 mostlyclean:
-       -$(LIBTOOL_CLEAN) rm -f libobjc.la libobjc_gc.la *.lo
-       -rm -f runtime-info.h tmp-runtime.s *.o *.lo libobjc* xforward \
+       -$(LIBTOOL_CLEAN) rm -f $(LIBOBJCNAME).la $(LIBOBJCNAME)_gc.la *.lo
+       -rm -f runtime-info.h tmp-runtime.s *.o *.lo $(LIBOBJCNAME)* xforward \
                fflags *.aux *.cp *.dvi *.fn *.info *.ky *.log *.pg \
                *.toc *.tp *.vr *.html libobj.exp
        @$(MULTICLEAN) multi-clean DO=mostlyclean
Index: libobjc/aclocal.m4
===================================================================
RCS file: /cvsroot/gcc/gcc/libobjc/aclocal.m4,v
retrieving revision 1.7
diff -u -r1.7 aclocal.m4
--- libobjc/aclocal.m4  12 Mar 2003 21:34:21 -0000      1.7
+++ libobjc/aclocal.m4  26 Aug 2003 10:19:43 -0000
@@ -196,7 +196,7 @@
   # and header files if --enable-version-specific-runtime-libs option
   # is selected.
   changequote(,)dnl
-  glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
+  glibcpp_toolexecdir='$(libdir)/gcc/$(target_alias)'
   glibcpp_toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)'
   changequote([,])dnl
 fi
@@ -209,7 +209,7 @@
     glibcpp_toolexecdir='$(exec_prefix)/$(target_alias)'
     glibcpp_toolexeclibdir='$(toolexecdir)/lib'
   else
-    glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
+    glibcpp_toolexecdir='$(libdir)/gcc/$(target_alias)'
     glibcpp_toolexeclibdir='$(libdir)'
   fi
   multi_os_directory=`$CC -print-multi-os-directory`
Index: libobjc/configure
===================================================================
RCS file: /cvsroot/gcc/gcc/libobjc/configure,v
retrieving revision 1.30
diff -u -r1.30 configure
--- libobjc/configure   11 Apr 2003 04:20:16 -0000      1.30
+++ libobjc/configure   26 Aug 2003 10:19:44 -0000
@@ -1255,7 +1255,7 @@
   # Need the gcc compiler version to know where to install libraries
   # and header files if --enable-version-specific-runtime-libs option
   # is selected.
-    glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
+    glibcpp_toolexecdir='$(libdir)/gcc/$(target_alias)'
   glibcpp_toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)'
   fi
 
@@ -1267,7 +1267,7 @@
     glibcpp_toolexecdir='$(exec_prefix)/$(target_alias)'
     glibcpp_toolexeclibdir='$(toolexecdir)/lib'
   else
-    glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
+    glibcpp_toolexecdir='$(libdir)/gcc/$(target_alias)'
     glibcpp_toolexeclibdir='$(libdir)'
   fi
   multi_os_directory=`$CC -print-multi-os-directory`
@@ -2750,7 +2750,7 @@
 { echo "configure: error: Can't find stdio.h.
 You must have a usable C system for the target already installed, at least
 including headers and, preferably, the library, before you can configure
-the Objective C runtime system.  If necessary, install gcc now with 
+the Objective-C runtime system.  If necessary, install gcc now with 
 \`LANGUAGES=c', then the target library, then build with \`LANGUAGES=objc'." 
1>&2; exit 1; }
 fi
 
@@ -2920,13 +2920,37 @@
 GTHREAD_FLAGS=$objc_cv_gthread_flags
 
 
+
+# Darwin preinstalls the NeXT/Apple Objective-C runtime.  To insure that
+# installing the GNU Objective-C runtime does not conflict with that
+# installation, we add an extra level of indirection for the headers
+# (include/libobjc_gnu), which user code should take into account with
+# an appropriate -I flag.  The libraries are suffixed with _gnu
+# accordingly (libobjc_gnu, libobjc_gnu_gc) so user code must also
+# take this into account when specifing the -l option.  This currently
+# only applies to Darwin.  
+
+case "${target}" in
+  *-*-darwin*)
+    install_inc_subdir="/libobjc_gnu"
+    LIBOBJCNAME="libobjc_gnu"
+    ;;
+  *-*-*)
+    install_inc_subdir=""
+    LIBOBJCNAME="libobjc"
+    ;;
+esac
+
+
+
+
 # Check whether --enable-objc-gc or --disable-objc-gc was given.
 if test "${enable_objc_gc+set}" = set; then
   enableval="$enable_objc_gc"
   if [ x$enable_objc_gc = xno ]; then
         OBJC_BOEHM_GC=''
 else
-        OBJC_BOEHM_GC=libobjc_gc.la
+        OBJC_BOEHM_GC="$LIBOBJCNAME"_gc.la
 fi
 else
   OBJC_BOEHM_GC=''
@@ -3109,6 +3133,8 @@
 s%@SET_MAKE@%$SET_MAKE%g
 s%@CPP@%$CPP%g
 s%@GTHREAD_FLAGS@%$GTHREAD_FLAGS%g
+s%@install_inc_subdir@%$install_inc_subdir%g
+s%@LIBOBJCNAME@%$LIBOBJCNAME%g
 s%@OBJC_BOEHM_GC@%$OBJC_BOEHM_GC%g
 
 CEOF
Index: libobjc/configure.in
===================================================================
RCS file: /cvsroot/gcc/gcc/libobjc/configure.in,v
retrieving revision 1.20
diff -u -r1.20 configure.in
--- libobjc/configure.in        20 Feb 2003 09:08:24 -0000      1.20
+++ libobjc/configure.in        26 Aug 2003 10:19:44 -0000
@@ -66,7 +66,7 @@
   [AC_MSG_ERROR([Can't find stdio.h.
 You must have a usable C system for the target already installed, at least
 including headers and, preferably, the library, before you can configure
-the Objective C runtime system.  If necessary, install gcc now with 
+the Objective-C runtime system.  If necessary, install gcc now with 
 \`LANGUAGES=c', then the target library, then build with \`LANGUAGES=objc'.])])
 
 AC_HEADER_STDC
@@ -85,13 +85,37 @@
 GTHREAD_FLAGS=$objc_cv_gthread_flags
 AC_SUBST(GTHREAD_FLAGS)
 
+
+# Darwin preinstalls the NeXT/Apple Objective-C runtime.  To insure that
+# installing the GNU Objective-C runtime does not conflict with that
+# installation, we add an extra level of indirection for the headers
+# (include/libobjc_gnu), which user code should take into account with
+# an appropriate -I flag.  The libraries are suffixed with _gnu
+# accordingly (libobjc_gnu, libobjc_gnu_gc) so user code must also
+# take this into account when specifing the -l option.  This currently
+# only applies to Darwin.  
+
+case "${target}" in
+  *-*-darwin*)
+    install_inc_subdir="/libobjc_gnu"
+    LIBOBJCNAME="libobjc_gnu"
+    ;;
+  *-*-*)
+    install_inc_subdir=""
+    LIBOBJCNAME="libobjc"
+    ;;
+esac
+
+AC_SUBST(install_inc_subdir)
+AC_SUBST(LIBOBJCNAME)
+
 AC_ARG_ENABLE(objc-gc,
 [  --enable-objc-gc       enable the use of Boehm's garbage collector with
                           the GNU Objective-C runtime.],
 if [[[ x$enable_objc_gc = xno ]]]; then
         OBJC_BOEHM_GC=''
 else
-        OBJC_BOEHM_GC=libobjc_gc.la
+        OBJC_BOEHM_GC="$LIBOBJCNAME"_gc.la
 fi,
 OBJC_BOEHM_GC='')
 AC_SUBST(OBJC_BOEHM_GC)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]