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

            Bug ID: 88623
           Summary: libgcc build uses CXX_FOR_BUILD but files have .c
                    extension
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andrew at ishiboo dot com
  Target Milestone: ---

Currently, gcc/Makefile.in specifies:

COMPILER_FOR_BUILD = $(CXX_FOR_BUILD)

indicating that the source files in the directory should be compiled with the
C++ compiler, but the source files still retain the .c suffix.

Building in this manner encodes some GCC-specific behavior into the build
process. For example, IBM's XL C++ compiler will not behave the same as GCC
when a file with a .c suffix is passed to the C++ compiler. There exists a
command-line option, `-+` to force treating input as C++ even if the filename
extension is .c, but this appears to have other side effects when it comes to
built-in macros such as __STDC__.

This caused an issue due to include/getopt.h only checking for __STDC__. I was
able to work around it by changing this line:

  #if defined (__STDC__) && __STDC__

to:

  #if (defined (__STDC__) && __STDC__) || defined(__cplusplus)

To ensure maximum compatibility bootstrapping with non-GCC compilers, the
libgcc source code file suffixes should change to reflect whether they are C or
C++ and the correct CC_FOR_BUILD / CXX_FOR_BUILD should be used to compile
them.

Reply via email to