Re: [PATCH v2 4/6] compiler-gcc.h: add asm_inline definition
From: Segher Boessenkool
Date: Thu Sep 05 2019 - 10:47:41 EST
On Thu, Sep 05, 2019 at 04:23:11PM +0200, Rasmus Villemoes wrote:
> On 05/09/2019 15.45, Segher Boessenkool wrote:
> > On Thu, Sep 05, 2019 at 01:07:11PM +0200, Rasmus Villemoes wrote:
> >> Perhaps something like below, though that
> >> won't affect the already released gcc 9.1 and 9.2, of course.
> >
> > That is one reason to not want such a predefined macro. Another reason
> > is that you usually need to compile some test programs *anyway*, to see if
> > some bug is present for example, or to see if the exact implementation of
> > the feature is beneficial (or harmful) to your program in some way.
>
> OK, I think I'll just use a version check for now, and then switch to a
> Kconfig test if and when clang grows support.
>
> >> gcc maintainers, WDYT? Can we add a feature test macro for asm inline()?
> >
> > Why would GCC want to have macros for all features it has?
>
> Well, gcc has implemented __has_attribute() which is similar - one could
> detect support by compiling a trivial test program.
It is not a macro, it doesn't spill over the place, and it is for
detecting things that are already fixed strings, much easier to do :-)
> Or the same could be
> said for many of the predefined macros that are conditionally defined,
> e.g. __HAVE_SPECULATION_SAFE_VALUE.
That one happened because of the Great Security Scare of 2017/2018, it's
not a good precedent. And, how it is set is target-specific, it can
depend on CPU model selected, target code generation options, or whatnot.
> But I was just throwing the question into the air, I won't pursue this
> further.
Maybe GCC should have a has_feature thing, it might fit in well there.
As preprocessor macros, not so much, IMO.
Segher