On Wed, Jan 16, 2019 at 05:42:06PM +0000, Joseph Myers wrote:
> On Wed, 16 Jan 2019, Joseph Myers wrote:
> 
> > On Wed, 16 Jan 2019, Jakub Jelinek wrote:
> > 
> > > In normal C headers, we can #if __WORDSIZE == 32 or __SIZEOF_LONG__ == 4 
> > > or
> > > defined(__ILP64__) and similar, but in these headers we can't, as no
> > > preprocessing is happening.
> > 
> > (With such preprocessing, the mechanism glibc uses for gnu/stubs.h and 
> > gnu/lib-names.h could be used.)
> 
> And I guess this leads to the question:
> 
> Since the Fortran front end has preprocessing support, could it be made to 
> run the preprocessor on such preincluded headers?  If it could, the driver 
> code could be changed to avoid looking in multilib locations for this 
> header, and that glibc machinery could be used.  (It would be necessary to 
> resolve the FIXME in fortran/cpp.c so that architecture-specific macros 
> get predefined; __x86_64__, __LP64__ and __ILP32__ all need to be properly 
> defined or not defined for this mechanism to work for x86.)

Well, it has, but extremely inefficient one.  Basically, it preprocesses
everything into a temporary file and then parses that temporary file instead
of the original input.
Doing such preprocessing for this tiny header file that is now going to be
included in every fortran compilation would slow it down, require the driver
to tell where to create the temporary file etc.

Perhaps easier would be to add optional if clause to the !GCC$ builtin
with constant expression argument which if present and evaluates to .false.
would tell us to ignore the attribute.  Or, add !GCC$ if/else/end if which
would act like preprocessing conditionals or something similar.
Not really sure one can query in Fortran what the multilib is some way (say
look at size of a pointer etc.).

        Jakub

Reply via email to