This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug driver/84391] New: External specs file misinterpreted, unless read twice


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84391

            Bug ID: 84391
           Summary: External specs file misinterpreted, unless read twice
           Product: gcc
           Version: 6.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: keith.marshall at mailinator dot com
  Target Milestone: ---

I'm experimenting with a customised GCC specs file, to enable selection of
alternative runtime libraries for MinGW.  I started by extracting the default
(built-in) specs:

  $ mingw32-gcc -dumpspecs > lib/gcc/mingw32/6.3.0/specs

This causes mingw32-gcc to read its default specs from this file, ignoring the
built-in specs.  So far, so good; all behaves as expected, (and as documented).
 Adding the '-v' option confirms that the specs are now read from the external
file, and built-in specs are not used.

Next, I defined new specs strings, within my external specs file:

  *msvcrt_id:
  -D__MSVCRT_VERSION__=0x0

  *msvcrt_version:
  ${msvcr*:$(msvcrt_id)%*0} $<msvcr*

and I prepended:

  *cpp:
  %(msvcrt_version) ...original cpp spec-string unchanged...

in place, to the original cpp spec-string, within the same specs file.

The intent is to interpret a custom '-msvcr90' option (say), to set the MinGW
specific '__MSVCRT_VERSION__' feature macro as appropriate for using
MSVCR90.DLL, rather than the MSVCRT.DLL default.  However, if I specify it,
using natural invocation syntax, I see:

  $ mingw32-gcc -E -dM -msvcr90 -xc /dev/null | grep MSVCRT
  mingw32-gcc: error: unrecognized command line option '-msvcr90'

Conversely, if I adopt this alternative (unnatural) invocation syntax:

  $ mingw32-gcc -specs=specs -E -dM -msvcr90 -xc /dev/null | grep MSVCRT
  #define __MSVCRT_VERSION__ 0x0900
  #define __MSVCRT__ 1

I see exactly the effect I am trying to achieve.

If I add the '-v' option to the former (failing) command, I see that my
external specs file is read once, (before any other output is produced); if I
add '-v' to the latter (successful) command, I see that my external specs file
is read twice, (again, before any other output is produced).

FWIW, I also see the expected behaviour if I augment the built-in specs, by
placing my customisations in an alternatively named auxiliary specs file, (say
mingw.specs), and invoke:

  $ mingw32-gcc -specs=mingw.specs -E -dM -msvcr90 -xc /dev/null | grep MSVCRT
  #define __MSVCRT_VERSION__ 0x0900
  #define __MSVCRT__ 1

Unless I'm overlooking something, I guess this is a bug in the way GCC
processes an external specs file explicitly named as 'specs', when reading it
implicitly; it seems that it may be worked around by loading it explicitly,
(although this is certainly much less convenient).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]