Subject: Re: [PATCH v2 0/3] detect-compiler: clang updates

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Sat, 07 Aug 2021 04:56:04 +0200

On Fri, Aug 06 2021, Jeff King wrote:

> On Sat, Aug 07, 2021 at 04:02:45AM +0200, Ævar Arnfjörð Bjarmason wrote:
>
>> Perhaps I've missed some obvious reason not to do this, but why are we
>> parsing the --version output of two modern compilers, as opposed to just
>> asking them what type/version they are via their usual macro facilities?
>> I.e. something like the below:
>
> That would probably work OK in practice, but it actually seems more
> complex to me (how do other random compilers react to "-E -"?

We only care about gcc and clang in that script, which I think have
supported that form of "-E" on stdin input for any version we're likely
to care about for the purposes of config.mak.dev. It seems unlikely that
we'll care about non-modern compilers in config.mak.dev, so using more
modern features there seems fine (it's all for opting us into even more
modern warning flags and the like...).

> Is it possible for us to get other output from the preprocessor that
> would confuse an eval?).

Probably, I just meant that as a POC. We could pipe it into some
awk/grep/cut/perl or whatever that would be more strict.