This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/21936] gcc build hangs with glibc 2.26 (conftest about static binaries dlopening themselves)
- From: "felix-glibc at fefe dot de" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 10 Aug 2017 12:44:53 +0000
- Subject: [Bug libc/21936] gcc build hangs with glibc 2.26 (conftest about static binaries dlopening themselves)
- Auto-submitted: auto-generated
- References: <bug-21936-131@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=21936
--- Comment #2 from Felix von Leitner <felix-glibc at fefe dot de> ---
My understanding is that this is a fairly well-known problem. I found various
bug reports about it, that's why I did not report it earlier.
See for example
http://www.eglibc.org/archives/issues/msg00086.html
https://sourceware.org/bugzilla/show_bug.cgi?id=11694
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=584607
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=591544
Here is what happens when I try to compile gcc from svn:
Revision: 250991
configure --prefix=/opt/gcc --sysconfdir=/etc --enable-__cxa_atexit
--libdir=/opt/gcc/lib64 --disable-bootstrap --enable-lto --enable-languages=c
--enable-plugin --with-multilib-list=m32,m64,mx32
Here is the last lines of display output:
checking command to parse /tmp/gcc-build/./gcc/nm output from
/tmp/gcc-build/./gcc/xgcc -B/tmp/gcc-build/./gcc/
-B/opt/gcc/x86_64-pc-linux-gnu/bin/ -B/opt/gcc/x86_64-pc-linux-gnu/lib/
-isystem /opt/gcc/x86_64-pc-linux-gnu/include -isystem
/opt/gcc/x86_64-pc-linux-gnu/sys-include -m32 object... ok
checking for dlfcn.h... yes
checking for objdir... .libs
checking if /tmp/gcc-build/./gcc/xgcc -B/tmp/gcc-build/./gcc/
-B/opt/gcc/x86_64-pc-linux-gnu/bin/ -B/opt/gcc/x86_64-pc-linux-gnu/lib/
-isystem /opt/gcc/x86_64-pc-linux-gnu/include -isystem
/opt/gcc/x86_64-pc-linux-gnu/sys-include -m32 supports -fno-rtti
-fno-exceptions... no
checking for /tmp/gcc-build/./gcc/xgcc -B/tmp/gcc-build/./gcc/
-B/opt/gcc/x86_64-pc-linux-gnu/bin/ -B/opt/gcc/x86_64-pc-linux-gnu/lib/
-isystem /opt/gcc/x86_64-pc-linux-gnu/include -isystem
/opt/gcc/x86_64-pc-linux-gnu/sys-include -m32 option to produce PIC... -fPIC
-DPIC
checking if /tmp/gcc-build/./gcc/xgcc -B/tmp/gcc-build/./gcc/
-B/opt/gcc/x86_64-pc-linux-gnu/bin/ -B/opt/gcc/x86_64-pc-linux-gnu/lib/
-isystem /opt/gcc/x86_64-pc-linux-gnu/include -isystem
/opt/gcc/x86_64-pc-linux-gnu/sys-include -m32 PIC flag -fPIC -DPIC works...
yes
checking if /tmp/gcc-build/./gcc/xgcc -B/tmp/gcc-build/./gcc/
-B/opt/gcc/x86_64-pc-linux-gnu/bin/ -B/opt/gcc/x86_64-pc-linux-gnu/lib/
-isystem /opt/gcc/x86_64-pc-linux-gnu/include -isystem
/opt/gcc/x86_64-pc-linux-gnu/sys-include -m32 static flag -static works... yes
checking if /tmp/gcc-build/./gcc/xgcc -B/tmp/gcc-build/./gcc/
-B/opt/gcc/x86_64-pc-linux-gnu/bin/ -B/opt/gcc/x86_64-pc-linux-gnu/lib/
-isystem /opt/gcc/x86_64-pc-linux-gnu/include -isystem
/opt/gcc/x86_64-pc-linux-gnu/sys-include -m32 supports -c -o file.o... yes
checking if /tmp/gcc-build/./gcc/xgcc -B/tmp/gcc-build/./gcc/
-B/opt/gcc/x86_64-pc-linux-gnu/bin/ -B/opt/gcc/x86_64-pc-linux-gnu/lib/
-isystem /opt/gcc/x86_64-pc-linux-gnu/include -isystem
/opt/gcc/x86_64-pc-linux-gnu/sys-include -m32 supports -c -o file.o...
(cached) yes
checking whether the /tmp/gcc-build/./gcc/xgcc -B/tmp/gcc-build/./gcc/
-B/opt/gcc/x86_64-pc-linux-gnu/bin/ -B/opt/gcc/x86_64-pc-linux-gnu/lib/
-isystem /opt/gcc/x86_64-pc-linux-gnu/include -isystem
/opt/gcc/x86_64-pc-linux-gnu/sys-include -m32 linker
(/tmp/gcc-build/./gcc/collect-ld -m elf_x86_64 -m elf_i386) supports shared
libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for shl_load... no
checking for shl_load in -ldld... no
checking for dlopen... no
checking for dlopen in -ldl... yes
checking whether a program can dlopen itself... yes
checking whether a statically linked program can dlopen itself...
Here is the conftest.c:
#line 11343 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
#include <dlfcn.h>
#endif
#include <stdio.h>
#ifdef RTLD_GLOBAL
# define LT_DLGLOBAL RTLD_GLOBAL
#else
# ifdef DL_GLOBAL
# define LT_DLGLOBAL DL_GLOBAL
# else
# define LT_DLGLOBAL 0
# endif
#endif
/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
find out it does not work in some platform. */
#ifndef LT_DLLAZY_OR_NOW
# ifdef RTLD_LAZY
# define LT_DLLAZY_OR_NOW RTLD_LAZY
# else
# ifdef DL_LAZY
# define LT_DLLAZY_OR_NOW DL_LAZY
# else
# ifdef RTLD_NOW
# define LT_DLLAZY_OR_NOW RTLD_NOW
# else
# ifdef DL_NOW
# define LT_DLLAZY_OR_NOW DL_NOW
# else
# define LT_DLLAZY_OR_NOW 0
# endif
# endif
# endif
# endif
#endif
/* When -fvisbility=hidden is used, assume the code has been annotated
correspondingly for the symbols needed. */
#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) ||
(__GNUC__ > 3))
void fnord () __attribute__((visibility("default")));
#endif
void fnord () { int i=42; }
int main ()
{
void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
int status = 0;
if (self)
{
if (dlsym (self,"fnord")) status = 1;
else
{
if (dlsym( self,"_fnord")) status = 2;
else puts (dlerror ());
}
/* dlclose (self); */
}
else
puts (dlerror ());
return status;
}
It is compiled like this:
/tmp/gcc-build/./gcc/xgcc -B/tmp/gcc-build/./gcc/
-B/opt/gcc/x86_64-pc-linux-gnu/bin/ -B/opt/gcc/x86_64-pc-linux-gnu/lib/
-isystem /opt/gcc/x86_64-pc-linux-gnu/include -isystem
/opt/gcc/x86_64-pc-linux-gnu/sys-include -m32 -o conftest -g -pipe -O2
-DHAVE_DLFCN_H -Wl,--export-dynamic -static conftest.c -ldl
My first idea was that this was probably because of some files under /opt/gcc
that should not have been there, but it also fails with the regular system gcc
7.1:
% gcc -m32 -static -o conftest conftest.i -ldl
/tmp/ccvEWcVy.o: In function `main':
conftest.c:(.text+0x2c): warning: Using 'dlopen' in statically linked
applications requires at runtime the shared libraries from the glibc version
used for linking
% ./conftest
[hangs]
Bizarre. I'll attach the conftest.i, but I don't think it will help much.
--
You are receiving this mail because:
You are on the CC list for the bug.