<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 5 July 2017 at 14:09, Melanie Blower via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">mibintc added a comment.<br>
<br>
Jonas asked about adding a new test to ensure that "-include stdc-predef.h" does not get added if the file doesn't exist.<br>
<br>
I added a reply to that but I can't see where it went. So I'm writing the reply again.<br>
<br>
The current version of the patch doesn't check for the existence of stdc-predef.h.  As far as I understand, this is consistent with gcc behavior. It is expected that if you are on a system without stdc-predef.h then you can add -ffreestanding.<br></blockquote><div><br></div><div>That does not seem reasonable. Plenty of libc implementations exist that don't provide this header. GCC might want to strongly express a preference for glibc, but we don't.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In a prior revision of this patch (see Diff 4), I attempted to iterate through the system directories to check for the existence of the file before adding -include with a full path name. However that patch didn't work. I was using this call to iterate through the system includes: getAllArgValues(options::OPT_<wbr>isystem).  However, the directory where stdc-predef.h is located, /usr/include, is added into the search path by using the option -internal-externc-isystem.  getAllArgValues(options::OPT_<wbr>isystem) does not iterate through the include directories which were added via -internal-externc-isystem. [Note: is this a bug?].  There is no enumeration value within options::OPT_? which corresponds to -internal-externc-isystem.<br>
<br>
I could check for the existence of this file: /usr/include/stdc-predef.h; I don't know whether this would be acceptable or if it's correct.</blockquote><div><br></div><div>Trying to fake up headers search from the driver doesn't sound like a good way forward. Perhaps instead you could add a -include-if-exists flag to -cc1 for this purpose, where -include-if-exists X would expand to something like</div><div><br></div><div>#if __has_include(X)</div><div>#include X</div><div>#endif </div></div></div></div>