This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: gcc 3.1 20020118 miscompiled ld.so on Linux/mips
On Sun, Jan 20, 2002 at 05:14:22PM -0800, H . J . Lu wrote:
> On Sun, Jan 20, 2002 at 09:55:38PM +0100, Jakub Jelinek wrote:
> > On Sun, Jan 20, 2002 at 12:45:37PM -0800, H . J . Lu wrote:
> > > On Sun, Jan 20, 2002 at 11:39:45AM -0800, H . J . Lu wrote:
> > > > When I used gcc 3.1 20020118 to compile the current glibc from trunk
> > > > on Linux/mips, I got
> > > >
> > > > # /export/build/gnu/glibc-3.1/build-mipsel-linux/elf/ld.so.1
> > > > zsh: 30232 segmentation fault (core dumped) /export/build/gnu/glibc-3.1/build-mipsel-linux/elf/ld.so.1
> > > >
> > > > gcc 2.96 is ok. I am looking into it now.
> > > >
> > >
> > > It looks like we need to add -finline-limit=xxxx at least for mips. We
> > > have to inline all functions in rtld.c if they are marked as inline
> > > since we can't do relocation during ld.so bootstrap.
> >
> > The same is true for ia32, alpha or ia64 and I believe other arches too.
> > I just always build glibc with -finline-limit=2000 these days and it works.
> > Unless somebody is working on improving the tree inliner heuristics for 3.1,
> > I believe it should e.g. double the limit for functions with explicit inline
> > keyword as opposed to -O3 inlining and double even that for inline nested
> > functions.
>
> Before gcc 3.1 is fixed, in the meantime, we should add
>
> -finline-limit=xxxx
>
> if gcc supports it when building glibc. I will write a patch next
> week.
>
Here is the patch.
H.J.
----
2002-01-20 H.J. Lu <hjl@gnu.org>
* config.make.in (inline-limit): New.
* configure.in: Check if gcc supports -finline-limit=xxx.
* configure: Rebuild.
* elf/Makefile (CFLAGS-rtld.c): Set to -finline-limit=2000 if
needed.
--- libc/config.make.in.inline Mon Jan 7 11:11:31 2002
+++ libc/config.make.in Sun Jan 20 22:09:51 2002
@@ -50,6 +50,7 @@ old-glibc-headers = @old_glibc_headers@
unwind-find-fde = @libc_cv_gcc_unwind_find_fde@
static-libgcc = @libc_cv_gcc_static_libgcc@
+inline-limit = @libc_cv_gcc_inline_limit@
versioning = @VERSIONING@
oldest-abi = @oldest_abi@
--- libc/configure.in.inline Sat Jan 19 10:36:10 2002
+++ libc/configure.in Sun Jan 20 22:09:09 2002
@@ -696,6 +696,14 @@ AC_MSG_ERROR([
*** and run configure again.])
fi
+AC_CACHE_CHECK(whether GCC supports -finline-limit, libc_cv_gcc_inline_limit, [dnl
+if echo | $CC -v -finline-limit=2000 -S -o /dev/null -x cpp-output - 2>&1 | grep -q 'unrecognized option.*-finline-limit'; then
+ libc_cv_gcc_inline_limit=no
+else
+ libc_cv_gcc_inline_limit=yes
+fi])
+AC_SUBST(libc_cv_gcc_inline_limit)
+
AC_CACHE_CHECK(whether GCC supports -static-libgcc, libc_cv_gcc_static_libgcc, [dnl
if $CC -v -static-libgcc 2>&1 | grep -q 'unrecognized option.*static-libgcc'; then
libc_cv_gcc_static_libgcc=
--- libc/elf/Makefile.inline Sat Jan 19 10:36:09 2002
+++ libc/elf/Makefile Sun Jan 20 22:12:16 2002
@@ -173,6 +173,12 @@ $(objpfx)ld.so: $(objpfx)librtld.os $(ld
# interp.c exists just to get this string into the libraries.
CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"'
+ifeq (yes,$(inline-limit))
+# Functions in rtld.c need to be inlined if they are marked inlined.
+# Some versions of gcc need this flag.
+CFLAGS-rtld.c = -finline-limit=2000
+endif
+
ifneq (ld.so,$(rtld-installed-name))
# Make sure ld.so.1 exists in the build directory so we can link
# against it.