<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt"><div dir="ltr">On Fri, Dec 14, 2012 at 6:55 PM, Justin Bogner <span dir="ltr"><<a href="mailto:mail@justinbogner.com" target="_blank" class="cremed">mail@justinbogner.com</a>></span> wrote:<br>
<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">David Chisnall <<a href="mailto:David.Chisnall@cl.cam.ac.uk" class="cremed">David.Chisnall@cl.cam.ac.uk</a>> writes:<br>

> I'd like to add some logic for selecting the linker at run time.<br>
> Before I start, I was wondering if anyone had any suggestions as to<br>
> the correct UI for this.  As far as I can see, there are two possible<br>
> choices:<br>
><br>
> 1) We have a flag that takes a full path to the linker to use.  This<br>
> is somewhat problematic, because if two linkers require different<br>
> arguments (not much of a problem for us, but imagine on Windows being<br>
> able to switch between the MS and Binutils linkers) then you need to<br>
> know what the linker is, as well as its name.<br>
><br>
> 2) We have a flag like the libc++ / libstdc++ selection flag, which<br>
> takes an argument like bfd, gold, mc, lld and some logic in the driver<br>
> to work out what the paths and names of each of these should be.<br>
><br>
> Is there a more sensible third option?<br>
<br>
</div>The impression I get from the replies thus far is that (1) should be<br>
sufficient given the assumption that different linkers have mostly<br>
compatible command line interfaces. I think there's some merit to the<br>
second approach even with this assumption though.<br>
<br>
In the following the flag to specify the linker is --link-with, for<br>
argument's sake. I'm not particularly attached to that name, but the<br>
name isn't really the point here.<br>
<br>
1. If you say --link-with=/full/path/to/ld, we use that binary.<br></blockquote><div><br></div><div style>IMO, this should be sysroot-relative, not root relative. But I'm interested if others disagree, and why. I can imagine problems with it, but not how realistic such problems would be.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2. If you say --link-with=foo, we first look for the name foo in the way<br>
   it normally looks for ld. Notably, this would mean that if you're<br>
   using a sysroot, we look for $sysroot/usr/bin/foo and friends.<br>
3. If (2) doesn't find anything, we then look for ld.foo, behaving as in<br>
   (2). This handles a fairly common idiom for having multiple<br>
   alternative ld implementations installed.<br></blockquote><div><br></div><div style>This seems excellent.<br></div><div style><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
We then call whatever linker we find with the flags we normally use.<br></blockquote><div><br></div><div style>I don't think we should go this far.</div><div style><br></div><div style>If the user gave us a '--link-with' flag, I think we should honor it or produce an error message explaining that we were unable to honor it.</div>
<div style><br></div><div style><br></div><div style>The final question in my mind is whether "--link-with" is the right name for this flag. I would be interested if anyone has particular shades of paint they prefer for this bikeshed. I would also be interested if someone familiar with the GCC community could see if they want to support this logic as well, and if so coordinate the flag name and semantics with them so we end up with a compatible option in both GCC and Clang.</div>
<div style><br></div><div style>-Chandler</div></div></div></div></div>