public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: grigory@stl.sarov.ru To: gcc-gnats@gcc.gnu.org Subject: other/7516: Ambiguous driver behaviour with "-shared -static" cmd line options combination Date: Tue, 06 Aug 2002 23:56:00 -0000 [thread overview] Message-ID: <20020807065158.31207.qmail@sources.redhat.com> (raw) >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:
reply other threads:[~2002-08-07 6:56 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020807065158.31207.qmail@sources.redhat.com \ --to=grigory@stl.sarov.ru \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).