[PATCH] D34158: to support gcc 4.8 (and newer) compatibility on Linux, preinclude <stdc-predef.h>
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 5 15:05:36 PDT 2017
On 5 July 2017 at 14:09, Melanie Blower via Phabricator <
reviews at reviews.llvm.org> wrote:
> 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.
>
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.
> 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.
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
#if __has_include(X)
#include X
#endif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170705/d29bcbe3/attachment.html>
More information about the cfe-commits
mailing list