From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3089 invoked by alias); 7 Aug 2002 06:56:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 3064 invoked by uid 71); 7 Aug 2002 06:56:01 -0000 Resent-Date: 7 Aug 2002 06:56:01 -0000 Resent-Message-ID: <20020807065601.3062.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, grigory@stl.sarov.ru Received: (qmail 31208 invoked by uid 61); 7 Aug 2002 06:51:58 -0000 Message-Id: <20020807065158.31207.qmail@sources.redhat.com> Date: Tue, 06 Aug 2002 23:56:00 -0000 From: grigory@stl.sarov.ru Reply-To: grigory@stl.sarov.ru To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: other/7516: Ambiguous driver behaviour with "-shared -static" cmd line options combination X-SW-Source: 2002-08/txt/msg00126.txt.bz2 List-Id: >Number: 7516 >Category: other >Synopsis: Ambiguous driver behaviour with "-shared -static" cmd line options combination >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Tue Aug 06 23:56:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Grigory Zagorodnev >Release: 3.1.1 >Organization: >Environment: host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ./configure --enable-threads >Description: 1. Intro -------- GCC manual defines the following cmd line options meaning: "-static On systems that support dynamic linking, this prevents linking with the shared libraries. -shared Produce a shared object..." 2. The issue ------------ So, if we wish to produce a shared object linked against static libraries, we have to specify "-shared -static" driver options. For instance: $ gcc foo.c -shared -o libfo.so -static But if we check the library built we will see that it is linked against some shared libs. $ ldd ./libfoo.so /lib/libNoVersion.so.1 => /lib/libNoVersion.so.1 (0x40003000) libc.so.6 => /lib/i686/libc.so.6 (0x40015000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x2aaaa000) *** This is not what expected! *** 3. Driver work -------------- Let's check what the GCC compiler driver is doing. We use --verbose to see details. $ gcc foo.c -shared -o libfo.so -static --verbose ... /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1.1/collect2 -m elf_i386 -shared -o libfoo.so /usr/lib/crti.o /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1.1/crtbeginT.o -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1.1 -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1.1/../../.. /home/grigory/tmp/cc6Ymc3Z.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1.1/crtendS.o /usr/lib/crtn.o We can see a kind of ambiguity here: (a) linker command line does not contain '-static' option requested, but at the same time, (b) the set of libraries "-lgcc -lgcc_eh -lc -lgcc -lgcc_eh" is specific for static build. I.e. we can see the same set while building executable linked against static libraries. 4. Question ----------- So, what is going on here: - Driver just lost '-static' in the linker command line? - Or this is intentional restriction? >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: