<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 7 November 2016 at 16:34, Martin J. O'Riordan <span dir="ltr"><<a href="mailto:martin.oriordan@movidius.com" target="_blank">martin.oriordan@movidius.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div link="blue" vlink="purple" lang="EN-IE"><div class="m_8943505568373755001WordSection1"><span class=""><p class="MsoNormal">@Martin: Have you tried to run `clang -v ...` to show the actual processing, and assuming it gives a sensible output, try to re-run the failing step (which I think is `cc1 ... filename.i`) with `-x cl`, and see if that resolves it?<u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:#002060"><u></u> <u></u></span></p></span><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:#002060">This is interesting.  So I used ‘</span><span style="font-family:"Courier New";color:black">-v</span><span style="font-family:"Book Antiqua",serif;color:#002060">’ and I see ‘</span><span style="font-family:"Courier New";color:black">-x cpp-output</span><span style="font-family:"Book Antiqua",serif;color:#002060">’ in the command-line - didn’t even know that value existed! - and if I replace it with ‘</span><span style="font-family:"Courier New";color:black">-x cl</span><span style="font-family:"Book Antiqua",serif;color:#002060">’ is works perfectly, so your hunch is spot-on.  But is also means that the ‘</span><span style="font-family:"Courier New";color:black">-x cpp-output</span><span style="font-family:"Book Antiqua",serif;color:#002060">’ option is determining source language based on the extension (‘</span><span style="font-family:"Courier New";color:black">.i</span><span style="font-family:"Book Antiqua",serif;color:#002060">’ or ‘</span><span style="font-family:"Courier New";color:black">.ii</span><span style="font-family:"Book Antiqua",serif;color:#002060">’).<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:#002060"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:#002060">            MartinO</span></p></div></div></blockquote><br>Good to know that at least SOMETIMES my "gut feel" points in the right general direction. <br><div><br></div><div>I'm not sure what the best solution for actually solving the next step - communicating the actual language. Using `.icl` or some such would work, but my personal feeling is that this is a slipperly slope that just gets worse and worse the more languages and flavours of languages that you want to support... the #pragma solution may work, but it kind of requires the preprocessor to add stuff to the output - I'm sure it does already, but I'm not sure it's the right place either.<br><br></div><div>In short, I'm sure it can be resolved, I'm not sure what is the RIGHT WAY, and I also don't know where in the code this should be done (for any of the suggested solutions), or who would be the right person to discuss this. Maybe Joerg has some ideas?<br></div><div><br>--<br></div><div>Mats<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div link="blue" vlink="purple" lang="EN-IE"><div class="m_8943505568373755001WordSection1"><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:#002060"><u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:#002060"><u></u> <u></u></span></p><p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US"> <a href="mailto:mats.o.petersson@googlemail.com" target="_blank">mats.o.petersson@googlemail.<wbr>com</a> [mailto:<a href="mailto:mats.o.petersson@googlemail.com" target="_blank">mats.o.petersson@<wbr>googlemail.com</a>] <b>On Behalf Of </b>mats petersson<br><b>Sent:</b> 07 November 2016 15:30<br><b>To:</b> Martin J. O'Riordan <<a href="mailto:Martin.ORiordan@movidius.com" target="_blank">Martin.ORiordan@movidius.com</a>><br><b>Cc:</b> Joerg Sonnenberger <<a href="mailto:joerg@bec.de" target="_blank">joerg@bec.de</a>>; cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>><span class=""><br><b>Subject:</b> Re: [cfe-dev] Odd behaviour with '-save-temps' and OpenCL files<u></u><u></u></span></span></p><p class="MsoNormal"><u></u> <u></u></p><div><div><div><p class="MsoNormal" style="margin-bottom:12.0pt">Assuming `#pragma clang language OpenCL` works, that seems like a neat thing that can be inserted as a "pre-include header" (as a constant string in the compiler). However, I'm not sure that clang does this in conjunction with the preprocessor as it is now - or that there is a simple way to achieve it - in which case, the other solution is to add some code to "remember" the language picked from the extension, and passing that to the parser step (cc1?) after preprocessing. <u></u><u></u></p></div></div><div><p class="MsoNormal"><br>--<u></u><u></u></p></div><p class="MsoNormal">Mats<u></u><u></u></p></div><div><div class="h5"><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">On 7 November 2016 at 12:57, Martin J. O'Riordan <<a href="mailto:martin.oriordan@movidius.com" target="_blank">martin.oriordan@movidius.com</a>> wrote:<u></u><u></u></p><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm"><div><div><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black">When the source is a C file, the pre-processed file has the extension ‘</span><span style="font-family:"Courier New";color:black">.i</span><span style="font-family:"Book Antiqua",serif;color:black">’, and when it is a C++ file the pre-processed file has the extension ‘</span><span style="font-family:"Courier New";color:black">.ii</span><span style="font-family:"Book Antiqua",serif;color:black">’.  Perhaps CL files need a 3<sup>rd</sup> convention for naming the pre-processed file, and eventually something similar if the FORTRAN front-end is available?  I don’t compile CUDA files, and they may have a similar problem.</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black">Even passing ‘</span><span style="font-family:"Courier New";color:black">-x cl -c -save-temps</span><span style="font-family:"Book Antiqua",serif;color:black">’ does not solve it, so the knowledge that it is an OpenCL source appears to be lost.</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black">            MartinO</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black"> </span><u></u><u></u></p><p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US"> cfe-dev [mailto:<a href="mailto:cfe-dev-bounces@lists.llvm.org" target="_blank">cfe-dev-bounces@lists.<wbr>llvm.org</a>] <b>On Behalf Of </b>mats petersson via cfe-dev<br><b>Sent:</b> 07 November 2016 10:56<br><b>To:</b> Joerg Sonnenberger <<a href="mailto:joerg@bec.de" target="_blank">joerg@bec.de</a>>; Clang Dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>><br><b>Subject:</b> Re: [cfe-dev] Odd behaviour with '-save-temps' and OpenCL files</span><u></u><u></u></p><div><div><p class="MsoNormal"> <u></u><u></u></p><div><div><div><p class="MsoNormal" style="margin-bottom:12.0pt">And how does the parser know from the preprocessed output that it is CL rather than C that it's parsing? I suspect it's the ".cl" part of the name of "<a href="http://filename.cl" target="_blank">filename.cl</a>" that determines that it's CL code in the first place, if that gets replaced with "filename.i", the parser will just say "Ah, it's C-code and has already been preprocessed".<u></u><u></u></p></div><p class="MsoNormal" style="margin-bottom:12.0pt">Maybe the parser needs a `-x cl` or similar to ensure that the parser knows it's CL-code?<u></u><u></u></p></div><div><p class="MsoNormal">I know that many of the CL parsing things have `if (langOpts.OpenCL) ...` in the parser and various other places. If we have a multi-pass way of running the compiler, it will potentially lose that information when it gets to the next step, is my thinking. I may of course be wrong, and the problem is with something else.<u></u><u></u></p></div><div><p class="MsoNormal"><br>--<u></u><u></u></p></div><p class="MsoNormal">Mats<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal">On 6 November 2016 at 11:04, Joerg Sonnenberger via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt"><p class="MsoNormal">On Sun, Nov 06, 2016 at 10:01:05AM +0000, mats petersson via cfe-dev wrote:<br>> My guess, and it's only a guess, is that -save-temps causes the compiler to<br>> run each step on those files, by executing independent processes, rather<br>> than the usual "run all steps in parallel" - in my understanding, Clang<br>> doesn't actually work in the "old style cc way" and running several<br>> processes with files produced between each step.<br><br>Yes and no. -svae-temps will run the parser on the preprocessed output,<br>so all macro-expansion knowledge is missing. That changes the impact of<br>a number of warnings like redundant braces. Pragmas are still preserved<br>in the code though. It would be a bug in the OpenCL integration if the<br>pragmas are no longer processed OR if pragmas are silently attached to<br>macros by position.<br><br>Joerg<u></u><u></u></p><div><div><p class="MsoNormal">______________________________<wbr>_________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><u></u><u></u></p></div></div></blockquote></div><p class="MsoNormal"> <u></u><u></u></p></div></div></div></div></div></blockquote></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></div></blockquote></div><br></div></div>