Target control of Fortran options
Paul Koning
paulkoning@comcast.net
Thu Oct 4 14:04:00 GMT 2018
> On Oct 4, 2018, at 4:06 AM, Richard Biener <richard.guenther@gmail.com> wrote:
>
> On Wed, Oct 3, 2018 at 11:04 PM Paul Koning <paulkoning@comcast.net> wrote:
>>
>> In the C and C++ parts of GCC, the target has some ways to adjust the compiler options depending on target settings. I'm looking for a way to do that with gfortran.
>>
>> The specific issue is in pdp11, which has an option to specify that "float" is 8 bytes (same as "double") rather than 4 bytes. And the 8 byte choice is the default.
>>
>> As a result, if I invoke gfortran for that target, I get an ICE because real*4 can't be found. If I say -fdefault-real-8 it works.
>>
>> So what I'm hoping to do is to have the target switch processing code (for the TARGET_HANDLE_OPTION hook) react to the -mfloat32 and -mfloat64 switches by passing appropriate -fdefault-real-* switches to Fortran. Is that possible?
>
> I think Fortran has to do it the same way the C family does.
> float/double get assigned
> by looking at FLOAT_TYPE_SIZE / [LONG_]DOUBLE_TYPE_SIZE. Iff that's not good
> for the Fortran FE we'd have to define additional target hooks the FE can use.
It appears that Fortran has a different approach. Fortran has syntax like "REAL*8" to request a float of a specific size. And what gfortran does is assume that "REAL" without a size specifier means "REAL*n" for a well known fixed n. Without switches, n is 4, which is indeed the common answer. But in my case, there isn't any 4-byte float type unless you say -mfloat32.
Maybe the answer is "that's a wrong thing to do". If so, I suppose I could change it -- it was done before I got involved and I don't know for what reason.
paul
More information about the Fortran
mailing list