A patch for shared libgcc
H . J . Lu
hjl@lucon.org
Sun Mar 25 09:25:00 GMT 2001
Here is my proposal for shared libgcc. For the time being, libgcc is
an add-on. I am still working on a gcc patch to help building shared
libgcc. I'd like to add a few things to the gcc driver:
1. gcc -dumprelease should print
3.0|3.0-20010322
i.e., the string in version.c to uniquely identify the version of gcc.
2. gcc should install libgcc.map along with libgcc.a even if
libgcc_s.so.0 is not built.
3. gcc -build-shared-libgcc should build libgcc_s.so.0 automatically
from libgcc.a and libgcc.map. Should it build
libgcc_s-`gcc -dumprelease'.so
instead of libgcc_s.so.0? We can drop it into /lib and run ldconfig.
It will help installation.
The libgcc add-on will take advantage of them. BTW, with #3, building
libgcc_s.so.0 from an install gcc will be trivial. Installing it is
entirely a different matter.
Any comments?
Thanks.
H.J.
----
2001-03-24 H.J. Lu <hjl@gnu.org>
* aclocal.m4 (AC_CHECK_LIBGCC_VER): New.
* config.make.in (build-shared-libgcc): New.
* configure.in (shared_libgcc): New. Set if libgcc is enabled
as an add-on. Check with AC_CHECK_LIBGCC_VER.
* configure: Rebuild.
* Makeconfig (rpath-dirs): Add libgcc if $(build-shared-libgcc)
is yes.
(all-subdirs): Filter out libgcc if $(build-shared-libgcc) is
not yes.
* Makerules (LDFLAGS-c.so): Make libgcc_s.so as the auxiliary
filter for libc.so if $(build-shared-libgcc) is yes.
--- libc/aclocal.m4.libgcc Sat May 29 15:54:11 1999
+++ libc/aclocal.m4 Sun Mar 25 09:06:13 2001
@@ -139,3 +139,31 @@ AC_CACHE_CHECK(whether $LD is GNU ld, li
[LIBC_PROG_FOO_GNU($LD, libc_cv_prog_ld_gnu=yes, libc_cv_prog_ld_gnu=no)])
gnu_ld=$libc_cv_prog_ld_gnu
])
+
+dnl check that gcc version is acceptable for libgcc.so.
+dnl AC_CHECK_LIBGCC_VER(version-switch,
+dnl [version-extract-regexp], version-glob [, do-if-fail])
+AC_DEFUN(AC_CHECK_LIBGCC_VER,
+[if test -z "$CC"; then
+ ac_verc_fail=yes
+else
+ # Found it, now check the version.
+ AC_MSG_CHECKING([version of $CC for shared libgcc])
+changequote(<<,>>)dnl
+ ac_prog_version=`<<$>>CC $1 2>&1 ifelse(<<$2>>,,,
+ <<| sed -n 's/^.*patsubst(<<$2>>,/,\/).*$/\1/p'>>)`
+ case $ac_prog_version in
+ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
+ <<$3>>)
+changequote([,])dnl
+ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
+ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
+
+ esac
+ AC_MSG_RESULT([$ac_prog_version])
+fi
+ifelse([$4],,,
+[if test $ac_verc_fail = yes; then
+ $4
+fi])
+])
--- libc/config.make.in.libgcc Mon Mar 19 10:36:15 2001
+++ libc/config.make.in Sat Mar 24 20:57:11 2001
@@ -67,6 +67,7 @@ build-profile = @profile@
build-omitfp = @omitfp@
build-bounded = @bounded@
build-static-nss = @static_nss@
+build-shared-libgcc = @shared_libgcc@
stdio = @stdio@
add-ons = @subdirs@
cross-compiling = @cross_compiling@
--- libc/configure.in.libgcc Mon Mar 19 10:36:16 2001
+++ libc/configure.in Sun Mar 25 09:07:51 2001
@@ -146,6 +146,7 @@ AC_ARG_ENABLE(add-ons, dnl
AC_CONFIG_SUBDIRS($add_ons)
add_ons_pfx=
+shared_libgcc=no
if test x"$add_ons" != x; then
for f in $add_ons; do
# Some sanity checks
@@ -166,6 +167,9 @@ if test x"$add_ons" != x; then
# Test whether such a subdir really exists.
if test -d $srcdir/$f; then
add_ons_pfx="$add_ons_pfx $f/"
+ if test "$f" = "libgcc"; then
+ shared_libgcc=yes
+ fi
else
AC_MSG_ERROR(add-on directory \"$f\" does not exist)
fi
@@ -569,6 +573,14 @@ AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --
AC_CHECK_PROG_VER(SED, gsed sed, --version,
[GNU sed version \([0-9]*\.[0-9.]*\)],
[3.0[2-9]*|3.[1-9]*|[4-9]*], SED=: aux_missing=t)
+
+# FIXME: We should check if libgcc in $CC is really ok.
+if test "$shared_libgcc" = "yes"; then
+ AC_CHECK_LIBGCC_VER(-v, [version \([egcygnustpi-]*[0-9.]*\)],
+ [3.[0-9]*],
+ shared_libgcc=no)
+fi
+AC_SUBST(shared_libgcc)
AC_PROG_CC_LOCAL
AC_CANONICAL_BUILD
--- libc/Makeconfig.libgcc Sat Jan 6 16:37:33 2001
+++ libc/Makeconfig Sat Mar 24 21:18:10 2001
@@ -431,6 +431,9 @@ link-libc = -Wl,-rpath-link=$(rpath-link
$(common-objpfx)$(patsubst %,$(libtype.oS),c) $(gnulib)
# This is how to find at build-time things that will be installed there.
rpath-dirs = math elf dlfcn nss nis rt resolv crypt
+ifeq (yes,$(build-shared-libgcc))
+rpath-dirs += libgcc
+endif
rpath-link = \
$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
@@ -833,6 +836,9 @@ all-subdirs = csu assert ctype locale in
gnulib iconv iconvdata wctype manual shadow po argp \
crypt $(add-ons) nss localedata timezone rt conform debug \
$(sysdep-subdirs) $(dlfcn) $(binfmt-subdir)
+ifneq (yes,$(build-shared-libgcc))
+all-subdirs := $(filter-out libgcc,$(all-subdirs))
+endif
all-subdirs := $(filter-out $(sysdep-inhibit-subdirs),$(all-subdirs))
# The mach and hurd subdirectories have many generated header files which
--- libc/Makerules.libgcc Mon Mar 19 10:36:14 2001
+++ libc/Makerules Sat Mar 24 20:59:23 2001
@@ -493,6 +493,10 @@ LDLIBS-c.so += $(gnulib)
LDFLAGS-c.so += -e __libc_main
# Force the backward compatibility EH functions to be linked.
LDFLAGS-c.so += -u __register_frame
+# Add a shared libgcc filter if it exists.
+ifeq ($(build-shared-libgcc),yes)
+LDFLAGS-c.so += -Wl,-f,libgcc_s.so$(libgcc_s.so-version)
+endif
# Pre-link the objects of libc_pic.a so that we can locally resolve
# COMMON symbols before we link against ld.so. This is because ld.so
# contains some of libc_pic.a already, which will prevent the COMMONs
More information about the Libc-alpha
mailing list