<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 15, 2017, at 12:11 PM, Peeter Joot via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">I think that I've probably declared my option inappropriately. It was:<br class=""></div><div class=""><br class=""></div><div class="">// Options.td</div><div class=""><span class="s1">def fmyopt_EQ : Joined<["-"], "fmyopt=">, Group<f_clang>, Flags<[CC1Option]>,</span><br class=""></div><p class="p1"><span class="s1"><span class="Apple-converted-space"> </span>HelpText<"...">;</span><br class=""></p><div class="">I think that the choice of whether or not to propagate it to the linker comes from here:<br class=""></div><div class=""><br class=""></div><p class="p1"><span class="s1">static</span><span class="s2"> </span><span class="s1">bool</span><span class="s2"> </span><span class="s3">forwardToGCC</span><span class="s2">(</span><span class="s1">const</span><span class="s2"> Option &O) {</span><br class=""></p><p class="p2"><span class="s4"><span class="Apple-converted-space"> </span></span><span class="s2">// Don't forward inputs from the original command line.<span class="Apple-converted-space"> </span>They are added from</span><br class=""></p><p class="p2"><span class="s4"><span class="Apple-converted-space"> </span></span><span class="s2">// InputInfoList.</span><br class=""></p><p class="p1"><span class="s2"><span class="Apple-converted-space"> </span></span><span class="s5">return</span><span class="s2"> O.</span><span class="s3">getKind</span><span class="s2">() != Option::InputClass &&</span><br class=""></p><p class="p1"><span class="s2"><span class="Apple-converted-space"> </span>!O.</span><span class="s3">hasFlag</span><span class="s2">(options::DriverOption) && !O.</span><span class="s3">hasFlag</span><span class="s2">(options::LinkerInput);</span><br class=""></p><p class="p1"><span class="s2">}</span><br class=""></p><div class=""><br class=""></div><div class=""><span class="s2">i.e. the LinkerInput flag. Perhaps this is implied by CC1Option in my Options.td line?</span><br class=""></div></div></blockquote><div><br class=""></div><div><br class=""></div><div>I’m not sure, there is a ! in front the the LinkerInput test, so it’ll return true if it is *not* a LinkerInput.</div><div><br class=""></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div class=""><span class="s2">I tried changing to</span><br class=""></div><div class=""><br class=""></div><div class=""><span class="s1">def fmyopt_EQ : Joined<["-"], "fmyopt=">, Group<f_clang>, Flags<[DriverOption]>,</span><br class=""></div><p class="p1"><span class="s1"><span class="Apple-converted-space"> </span>HelpText<"...”>;</span><br class=""></p></div></blockquote><div><br class=""></div><div>Maybe:</div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><span class="s1">def fmyopt_EQ : Joined<["-"], "fmyopt=">, Group<f_clang>, Flags<[DriverOption, CC1Option]>,</span><br class=""></div></blockquote><div class=""><div class=""><span class="s1"><br class=""></span></div></div><div class=""><span class="s1">?</span></div><div class=""><span class="s1"><br class=""></span></div><div class=""><span class="s1">— </span></div><div class=""><span class="s1">Mehdi</span></div><div class=""><span class="s1"><br class=""></span></div></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="">but now my option is no longer recognized in the compilation phase.</div><div class=""><br class=""></div><div class="">Hmm, wondering if I should have put this in CC1Options.td instead, which I just spotted?</div><div class=""><br class=""></div><div class=" protonmail_signature_block"><div class="protonmail_signature_block-user "><div class="">--<br class=""></div><div class="">Peeter<br class=""></div></div><div class="protonmail_signature_block-proton protonmail_signature_block-empty"><br class=""></div></div><div class=""><br class=""></div><blockquote class="protonmail_quote" type="cite"><div class="">-------- Original Message --------<br class=""></div><div class="">Subject: RE: [cfe-dev] how to avoid passing new clang front end option to the linker?<br class=""></div><div class="">Local Time: March 15, 2017 2:25 PM<br class=""></div><div class="">UTC Time: March 15, 2017 6:25 PM<br class=""></div><div class="">From: <a href="mailto:paul.robinson@sony.com" class="">paul.robinson@sony.com</a><br class=""></div><div class="">To: Peeter Joot <<a href="mailto:peeterjoot@protonmail.com" class="">peeterjoot@protonmail.com</a>><br class=""></div><div class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a> <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class=""></div><div class=""><br class=""></div><div class=""> <br class=""></div><div class="WordSection1"><p class="MsoNormal"><span style="color:rgb(31, 73, 125)" class="colour"><span style="font-family:Calibri, sans-serif" class="font"><span style="font-size:11pt" class="size">The linker command line would be constructed in the driver (clang/lib/Driver/…) and exactly where the code is depends on your triple. You could grep for 'Linker::ConstructJob'
and see what looks most likely, or try stepping through the driver in a debugger to see which one is invoked. I am a little surprised that arbitrary –f options would be passed through in the link phase.</span></span></span><br class=""></p><p class="MsoNormal"><a name="_MailEndCompose" class=""><span style="color:rgb(31, 73, 125)" class="colour"><span style="font-family:Calibri, sans-serif" class="font"><span style="font-size:11pt" class="size">HTH,</span></span></span></a><br class=""></p><p class="MsoNormal"><span style="color:rgb(31, 73, 125)" class="colour"><span style="font-family:Calibri, sans-serif" class="font"><span style="font-size:11pt" class="size">--paulr</span></span></span><br class=""></p><p class="MsoNormal"><span style="color:rgb(31, 73, 125)" class="colour"><span style="font-family:Calibri, sans-serif" class="font"><span style="font-size:11pt" class="size"> </span></span></span><br class=""></p><div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt" class=""><div class=""><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in" class=""><p class="MsoNormal"><b class=""><span style="font-family:Tahoma, sans-serif" class="font"><span style="font-size:10pt" class="size">From:</span></span></b><span style="font-family:Tahoma, sans-serif" class="font"><span style="font-size:10pt" class="size"> cfe-dev [<a href="mailto:cfe-dev-bounces@lists.llvm.org" class="">mailto:cfe-dev-bounces@lists.llvm.org</a>] <b class="">On Behalf Of </b>Peeter Joot via cfe-dev<br class=""> <b class="">Sent:</b> Wednesday, March 15, 2017 8:10 AM<br class=""> <b class="">To:</b> <a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class=""> <b class="">Subject:</b> [cfe-dev] how to avoid passing new clang front end option to the linker?</span></span></p></div></div><p class="MsoNormal"> <br class=""></p><div class=""><p class="MsoNormal">I'm attempting to implement a new clang front end option for my project (<span class="s1">-fmyopt=blah)</span>, and have made the changes required that I can access and act on it in my Target class when compiling. When linking, it causes
a bit of trouble, as clang passes it on to gcc in the link phase:<br class=""></p></div><p class="p1"><span class="apple-converted-space"> </span><span class="s1">"/usr/lib64/ccache/gcc" -g -D QSIZE -fpic -MD -fmyopt=blah -v -m64 -o tryit /run/user/1002/tryit-46641b.o</span><br class=""></p><p class="p1">which gcc objects to. <br class=""></p><div class=""><p class="MsoNormal"> <br class=""></p></div><div class=""><p class="MsoNormal">What part of the code is the link command line constructed in, and what is the mechanism used to select which options get passed to other stages (or an example of that)?<br class=""></p></div><div class=""><p class="MsoNormal"> <br class=""></p></div><div class=""><div class=""><div class=""><p class="MsoNormal">--<br class=""></p></div><div class=""><p class="MsoNormal">Peeter<br class=""></p></div></div><div class=""><p class="MsoNormal"> <br class=""></p></div></div><div class=""><p class="MsoNormal"> <br class=""></p></div></div></div></blockquote><div class=""><br class=""></div>_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></div></blockquote></div><br class=""></body></html>