From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3200 invoked by alias); 4 Mar 2011 17:31:55 -0000 Received: (qmail 3121 invoked by uid 22791); 4 Mar 2011 17:31:48 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-qw0-f41.google.com (HELO mail-qw0-f41.google.com) (209.85.216.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 04 Mar 2011 17:31:42 +0000 Received: by qwd7 with SMTP id 7so2348413qwd.0 for ; Fri, 04 Mar 2011 09:31:40 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.101.40 with SMTP id a40mr781004qco.82.1299259900772; Fri, 04 Mar 2011 09:31:40 -0800 (PST) Received: by 10.229.89.197 with HTTP; Fri, 4 Mar 2011 09:31:39 -0800 (PST) In-Reply-To: References: Date: Fri, 04 Mar 2011 17:31:00 -0000 Message-ID: Subject: Re: Support for automatic linking via pragma From: Kai Tietz To: "H.J. Lu" Cc: Ian Lance Taylor , Olaf van der Spek , binutils@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-03/txt/msg00065.txt.bz2 2011/3/4 H.J. Lu : > On Fri, Mar 4, 2011 at 8:52 AM, Ian Lance Taylor wrote: >> "H.J. Lu" writes: >> >>> On Fri, Mar 4, 2011 at 8:29 AM, Olaf van der Spek wrote: >>>> On Mon, Feb 28, 2011 at 7:17 PM, Olaf van der Spek wrote: >>>>> Hi, >>>>> >>>>> I've submitted a feature request for automatic linking via pragma: >>>>> http://sourceware.org/bugzilla/show_bug.cgi?id=3D12485 >>>>> What do others think about the idea? >>>> >>>> Somebody? >>>> >>>> Let me quote the request: >>>> MSVC supports the following pragma, which can be used to automatically= link a >>>> library when a header file is included. This is used by for example Bo= ost. >>>> >>>> It makes linking with the right lib a lot simpler. No more fiddling >>>> with autoconf to detect the right lib name. >>>> >>> >>> Not necessarily. =A0Unlike DSO, object files don't have ABI/API >>> information. You may not link foo.o compiled with glibc 2.5/libbar >>> 1.3 against glibc 2.13/libbar 1.9 >> >> I don't see how that is relevant to what Olaf is talking about. >> >> What Olaf is saying is that he wants to be able to have a .h file >> automatically a -l option to the link command line. > > Don't you need to store such information in object files? > >> What you are saying is that if that you have a .o file, you have to link >> against the -l which corresponds to the .h file which was used when the >> .o file was compiled. =A0That is of course a real problem, but it's a >> problem that exists whether or not we implement the MSVC pragma. >> > > There is no such problem for DSO since we can encode ABI/API > info in DSO. > > -- > H.J. > Hello, my 1 cent for this feature. I did some research for this feature a while ago. Actual it is still on my todo-list for some time, but the details of it scared me to do it actually. The additional link-information is (for PE-COFF) in directive-section (like additional aliasing, export-information, entry, and co). For ELF the .comment section should be the equivalent, isn't it? I didn't found time to work on that in more detail for PE-COFF and indeed is for it the dependency-tree for objects/libraries the challenging part. As for doing this on each used object base, means we have on link-time a changing import dependency tree, as each object actual used could generate new one. This easily can lead to cycles and is IMHO too costy. So my research had shown that it would be more efficent (and not that complex), to pre-scan those directives before the actual link-phase and build up the object/library link dependency-tree once. The gcc pragma implementation would be straight-forward and obvious. Kai