[PATCH] D34158: to support gcc 4.8 (and newer) compatibility on Linux, preinclude <stdc-predef.h>

Melanie Blower via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 5 14:09:01 PDT 2017


mibintc added a comment.

Jonas asked about adding a new test to ensure that "-include stdc-predef.h" does not get added if the file doesn't exist.

I added a reply to that but I can't see where it went. So I'm writing the reply again.

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.

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_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_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.

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.


https://reviews.llvm.org/D34158





More information about the cfe-commits mailing list