[PATCH] [mc-coff] Forward Linker Option flags into the .drectve section

Dario_Domizioli at sn.scee.net Dario_Domizioli at sn.scee.net
Fri Apr 26 10:04:55 PDT 2013


Hi Reid.

It seems to me that this patch, combined with your clang one, assumes a 
Windows linker.
(sorry I'm replying to this patch and then referencing the previous one, 
but I can't reply to both email threads at the same time)

Your approach is to store the full "/DEPLIBS:<libname>" string directly in 
the llvm metadata, and I see the string is created in the 
Sema::ActOnPragmaMSComment function which is target-independent; however, 
that string only makes sense to the Windows linker, I think.
It is conceivable that people will want to extend support for "#pragma 
comment lib" for other targets (for example ELF) and other linkers; in 
fact that is also a feature request from our customers. Since the pragma 
is a frontend feature, it is exposed to all users and it could be useful 
to people in general.

In fact, the discussion of Daniel's RFC at some point mentions either 
implementing a neutral representation in the metadata (such as a "named 
libraries" flag in addition to the "linker options" one) or having a 
target-specific hook to set the linker options accordingly. Daniel votes 
for the target-specific hook.
See http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-January/058246.html 

Cheers,

Dario Domizioli
SN Systems Ltd.
http://www.snsys.com


llvm-commits-bounces at cs.uiuc.edu wrote on 25/04/2013 17:45:29:

> From: Reid Kleckner <rnk at google.com>
> To: Rafael EspĂ­ndola <rafael.espindola at gmail.com>
> Cc: llvm-commits <llvm-commits at cs.uiuc.edu>, reviews+D724+public
> +b77dd6ec4ad8cdcc at llvm-reviews.chandlerc.com
> Date: 25/04/2013 17:47
> Subject: Re: [PATCH] [mc-coff] Forward Linker Option flags into the 
> .drectve section
> Sent by: llvm-commits-bounces at cs.uiuc.edu
> 
> Phab is down so here's the patch.
> 
> On Thu, Apr 25, 2013 at 12:43 PM, Reid Kleckner <rnk at google.com> wrote:
> > On Wed, Apr 24, 2013 at 6:58 PM, Rafael EspĂ­ndola
> > <rafael.espindola at gmail.com> wrote:
> >>> +
> >>> +  // Emit the linker options if present.
> >>> +  if (LinkerOptions) {
> >>
> >> Please use an early return
> >>
> >> if (!LinkerOptions)
> >>  return;
> >
> > Sure.
> >
> >>> +    const MCSection *Sec = getDrectveSection();
> >>> +    Streamer.SwitchSection(Sec);
> >>> +    for (unsigned i = 0, e = LinkerOptions->getNumOperands(); i
> != e; ++i) {
> >>> +      MDNode *MDOptions = 
cast<MDNode>(LinkerOptions->getOperand(i));
> >>> +      for (unsigned ii = 0, ie = MDOptions->getNumOperands(); 
> ii != ie; ++ii) {
> >>> +        MDString *MDOption = 
cast<MDString>(MDOptions->getOperand(ii));
> >>> +        Streamer.EmitBytes(" ");
> >>> +        Streamer.EmitBytes(MDOption->getString());
> >>>
> >>
> >> Is the format documented somewhere we could link to?
> >
> > The .drectve section format, or the module flags metadata format?
> >
> > The .drectve section, which we already use for dllexported symbols, is
> > part of the PE-COFF spec:
> > """
> > A .drectve section consists of a string of text that can be 
> encoded as ANSI or
> > UTF8. If the UTF8 byte order marker (BOM, a three-byte prefix that
> consists of
> > 0xEF, 0xBB, and 0xBF) is not present, the directive string is
> > interpreted as ANSI.
> > The directive string is a series of linker options that are separated
> > by spaces. Each
> > option contains a hyphen, the option name, and any appropriate 
attribute. If
> > an option contains spaces, the option must be enclosed in quotes. 
> The .drectve
> > section must not have relocations or line numbers.
> > """
> >
> > One thing that's a little vague is how quotes and backslashes should
> > be escaped.  I'd guess it's the same escaping algorithm used for
> > CreateProcess, since these are flags.
> >
> > Worth linking the doc here, or is the spec kind of an implicit 
reference?
> >
> > So far as I know, the metadata flags are only documented by
> > implementation and mailing list discussion.  See Daniel's RFC about
> > auto-linking:
> > http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-January/058204.html
> >
> > Is it common to link the mailing list from the source code?
> >
> >>  Index: test/MC/COFF/linker-options.ll
> >>> ===================================================================
> >>> --- /dev/null
> >>> +++ test/MC/COFF/linker-options.ll
> >>> @@ -0,0 +1,28 @@
> >>> +; RUN: llc -O0 -mtriple=i386-pc-win32 -filetype=obj -o - %s | 
> llvm-readobj -s -sd | FileCheck %s
> >>> +
> >>
> >> Please test the output of the assembly file. No need to use 
-filetype=obj.
> >
> > Sounds good.  For some reason I thought that wouldn't work with COFF,
> > but it works fine.
> [attachment "coff-auto-link.diff" deleted by Dario Domizioli/SN R&D/
> BS/UK/SCEE] _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


**********************************************************************
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. 
If you have received this email in error please notify postmaster at scee.net
This footnote also confirms that this email message has been checked for 
all known viruses.
Sony Computer Entertainment Europe Limited
Registered Office: 10 Great Marlborough Street, London W1F 7LP, United 
Kingdom
Registered in England: 3277793
**********************************************************************

P Please consider the environment before printing this e-mail




More information about the llvm-commits mailing list