shared libgcc build support

Richard Henderson rth@cygnus.com
Fri Oct 6 15:26:00 GMT 2000


On Fri, Oct 06, 2000 at 05:00:23PM -0400, David Edelsohn wrote:
> 	I still need multiple commands because the current version
> produces libgcc_s.so.  Your SHLIB_EXT hook will allow me to produce
> libgcc_s.a (or libgcc_s.o), but what I need is shr<VER>.o archived into
> libgcc_s.a.  Naming the shared object libgcc_s.a will work, but will not
> allow for symbol versioning.

Try this.  If it works well enough for you, I'll fix up the other
platforms to match.  You now have to methods to get at the pthread
thing, btw, as we now have @multilib_flags@.


r~


Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/Makefile.in,v
retrieving revision 1.520
diff -c -p -d -r1.520 Makefile.in
*** Makefile.in	2000/10/06 05:46:00	1.520
--- Makefile.in	2000/10/06 22:22:25
*************** libgcc.mk: config.status Makefile mklibg
*** 980,986 ****
  	MULTILIBS=`$(GCC_FOR_TARGET) --print-multi-lib` \
  	EXTRA_MULTILIB_PARTS='$(EXTRA_MULTILIB_PARTS)' \
  	SHLIB_LINK='$(SHLIB_LINK)' \
! 	SHLIB_LIBS='$(SHLIB_LIBS)' \
  	SHLIB_MULTILIB='$(SHLIB_MULTILIB)' \
  	SHLIB_MKMAP='$(SHLIB_MKMAP)' \
  	SHLIB_MAPFILES='$(SHLIB_MAPFILES)' \
--- 980,986 ----
  	MULTILIBS=`$(GCC_FOR_TARGET) --print-multi-lib` \
  	EXTRA_MULTILIB_PARTS='$(EXTRA_MULTILIB_PARTS)' \
  	SHLIB_LINK='$(SHLIB_LINK)' \
! 	SHLIB_EXT='$(SHLIB_EXT)' \
  	SHLIB_MULTILIB='$(SHLIB_MULTILIB)' \
  	SHLIB_MKMAP='$(SHLIB_MKMAP)' \
  	SHLIB_MAPFILES='$(SHLIB_MAPFILES)' \
Index: mklibgcc.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/mklibgcc.in,v
retrieving revision 1.18
diff -c -p -d -r1.18 mklibgcc.in
*** mklibgcc.in	2000/10/06 05:46:01	1.18
--- mklibgcc.in	2000/10/06 22:22:25
***************
*** 23,30 ****
  # LIBGCC
  # MULTILIBS
  # EXTRA_MULTILIB_PARTS
  # SHLIB_LINK
- # SHLIB_LIBS
  # SHLIB_MULTILIB
  # SHLIB_MKMAP
  # SHLIB_MAPFILES
--- 23,30 ----
  # LIBGCC
  # MULTILIBS
  # EXTRA_MULTILIB_PARTS
+ # SHLIB_EXT
  # SHLIB_LINK
  # SHLIB_MULTILIB
  # SHLIB_MKMAP
  # SHLIB_MAPFILES
*************** for ml in $MULTILIBS; do
*** 286,297 ****
  
    if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
      mapfile="libgcc.map"
-     shlib_deps="$shlib_deps $mapfile"
      echo ""
      echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_objs"
      echo '	{ $(NM_FOR_TARGET) -pg'" $libgcc_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
      echo '	mv tmp-$@ $@'
    fi
  
    # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
    # usually are put in a true multilib situation.
--- 286,297 ----
  
    if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
      mapfile="libgcc.map"
      echo ""
      echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_objs"
      echo '	{ $(NM_FOR_TARGET) -pg'" $libgcc_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
      echo '	mv tmp-$@ $@'
    fi
+   shlib_deps="$shlib_deps $mapfile"
  
    # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
    # usually are put in a true multilib situation.
*************** for ml in $MULTILIBS; do
*** 315,327 ****
  	shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
        fi
        echo ""
!       echo "${dir}/${shlib_base_name}.so: $shlib_deps"
!       echo "	$SHLIB_LINK $flags -o ${shlib_base_name}.so $libgcc_objs $SHLIB_LIBS" | sed "s/@shlib_base_name@/$shlib_base_name/g"
      elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
        shlib_base_name="libgcc_s";
        echo ""
!       echo "${shlib_base_name}.so: $shlib_deps"
!       echo "	$SHLIB_LINK $flags -o ${shlib_base_name}.so $libgcc_objs $SHLIB_LIBS" | sed "s/@shlib_base_name@/$shlib_base_name/g"
      fi
    fi
  done
--- 315,335 ----
  	shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
        fi
        echo ""
!       echo "${dir}/${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
!       echo "	$SHLIB_LINK" \
! 	 | sed -e "s%@multilib_flags@%$flags%g" \
! 	       -e "s%@shlib_objs@%$libgcc_objs%g" \
! 	       -e "s%@shlib_base_name@%$shlib_base_name%g" \
! 	       -e "s%@shlib_map_file@%$mapfile%g"
      elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
        shlib_base_name="libgcc_s";
        echo ""
!       echo "${shlib_base_name}${SHLIB_EXT}: $shlib_deps"
!       echo "	$SHLIB_LINK" \
! 	 | sed -e "s%@multilib_flags@%$flags%g" \
! 	       -e "s%@shlib_objs@%$libgcc_objs%g" \
! 	       -e "s%@shlib_base_name@%$shlib_base_name%g" \
! 	       -e "s%@shlib_map_file@%$mapfile%g"
      fi
    fi
  done
*************** for ml in $MULTILIBS; do
*** 359,373 ****
        else
  	suff=_`echo $dir | sed s,/,_,g`
        fi
!       all="$all ${dir}/libgcc_s${suff}.so"
      elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
!       all="$all libgcc_s.so"
      fi
-       if [ "$dir" = "." ]; then
- 	suff="";
-       else
- 	suff=_`echo $dir | sed s,/,_,g`
-       fi
    fi
  done
  
--- 367,376 ----
        else
  	suff=_`echo $dir | sed s,/,_,g`
        fi
!       all="$all ${dir}/libgcc_s${suff}${SHLIB_EXT}"
      elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
!       all="$all libgcc_s${SHLIB_EXT}"
      fi
    fi
  done
  
Index: config/t-linux
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/t-linux,v
retrieving revision 1.5
diff -c -p -d -r1.5 t-linux
*** t-linux	2000/10/06 05:46:01	1.5
--- t-linux	2000/10/06 22:22:26
*************** CRTSTUFF_T_CFLAGS_S = -fPIC
*** 9,18 ****
  # Compile libgcc2.a with pic.
  TARGET_LIBGCC2_CFLAGS = -fPIC
  # Build a shared libgcc library.
  SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
  	-Wl,--soname=@shlib_base_name@.so.0 \
! 	-Wl,--version-script=libgcc.map
! SHLIB_LIBS = -lc
  SHLIB_MKMAP = $(srcdir)/mkmap-symver.awk
  SHLIB_MAPFILES = $(srcdir)/libgcc-std.ver $(srcdir)/config/libgcc-glibc.ver
  
--- 9,19 ----
  # Compile libgcc2.a with pic.
  TARGET_LIBGCC2_CFLAGS = -fPIC
  # Build a shared libgcc library.
+ SHLIB_EXT = .so
  SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
  	-Wl,--soname=@shlib_base_name@.so.0 \
! 	-Wl,--version-script=@shlib_map_file@ \
! 	-o @shlib_base_name@.so @multilib_flags@ @shlib_objs@ -lc
  SHLIB_MKMAP = $(srcdir)/mkmap-symver.awk
  SHLIB_MAPFILES = $(srcdir)/libgcc-std.ver $(srcdir)/config/libgcc-glibc.ver
  


More information about the Gcc-patches mailing list