<div dir="ltr"><div><div><div><div>By my understanding, the proposal is that the user input looks something like:<br><br></div>#pragma linker_directive("lib", "m")<br><br></div>which is passed essentially as is to the linker, i.e. the directive payload is a pair of strings, the first being "lib", the second "m". It is then up to the linker to decide if it supports "lib" directives, and translate that into the corresponding command, or do something else if it doesn't support it, e.g. emit an error or ignore it. Neither the backend nor the frontend need to do any conversion, and it makes it much clearer that these aren't like any other command-line option (due to the limited set that can be passed through, and the possible differences in behaviour, such as order on the command-line).<br><br></div>As an aside, this approach would aid portability to linkers that aren't command-line compatible with one another. If, for example, the switch is "-lib" on linker A, and "-l" on linker B, the user doesn't have to have different source code for each different linker their object is to be consumed by, nor does the compiler have to know about the different possible linkers.<br><br></div>James<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 9 January 2018 at 05:15, Saleem Abdulrasool <span dir="ltr"><<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
<br>
> On Jan 7, 2018, at 5:02 PM, Cary Coutant <<a href="mailto:ccoutant@gmail.com">ccoutant@gmail.com</a>> wrote:<br>
><br>
>> I think we all agree that blindly allowing the linker to honor the options<br>
>> would be scary. I agree that we should whitelist the options, and am of the<br>
>> opinion that we should force validation on the linker side (use of any<br>
>> option which the linker doesn't support in this form can be fatal).<br>
>> Starting small is the best way, with `-l` and `-L` as a starting point. I<br>
>> want to retain the ability to add additional options which may not be<br>
>> available in all linkers. However, whitelisting obviously requires working<br>
>> with the linker as would adding such options, so that could be handled at<br>
>> that time.<br>
><br>
> This is actually why I'd prefer a new "language" over just<br>
> whitelisting options. With "lib", "file", and "path", as I suggested,<br>
> there's no question whether an option like "-no-pie" is supported, and<br>
> no temptation to even try. The new language should be tailored for<br>
> process-to-process communication, rather than user-to-shell<br>
> communication.<br>
<br>
</span>I suppose I am slightly confused about what you are proposing here now. From the user side, it would be something to that effect. Im suggesting that we take lib and transform it to a different representation in the frontend. Taking an explicit example:<br>
<br>
The user input<br>
`#pragma comment(lib, “m”)`<br>
<br>
would get transformed to `-lm` in the object file encoding. However, this would still not permit you from injecting any arbitrary options, but the backend doesn’t change for any new option, only the frontend and the linker.<br>
<div class="HOEnZb"><div class="h5"><br>
>> I’m thinking about future enhancements. MachO does actually provide<br>
>> something like `-L` -`l` in a single go via `-framework`. But, no such<br>
>> option exists for ELF since it doesn’t have the concept of framework bundles<br>
>> (but the layout itself is interesting), and I just want to try to keep the<br>
>> door open for such features.<br>
><br>
> This is why I also included "path" in my suggestion. I imagine<br>
> something very much like -framework, where include files and library<br>
> search paths are handled together.<br>
><br>
> -cary<br>
<br>
</div></div></blockquote></div><br></div>