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

            Bug ID: 125710
           Summary: _GLIBCXX_FILESYSTEM_IS_WINDOWS when using wineg++ in
                    POSIX (-mcygwin) mode
           Product: gcc
           Version: 13.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: puetzk at puetzk dot org
  Target Milestone: ---

When compiling winelib code with wineg++ in its default (non-PE) mode, it will
#define _WIN32 (because <windows.h> and windows API is available) - but it's
still building an ELF .dll.so or .exe.so file, and it's using the standard
POSIX  libc/libstdc++/etc.

This causes ODR issues with a couple of headers, like <bits/fs_path.h>,  and
<parallel/compatibility.h>, that make use of #if defined(_WIN32) and adapt
accordingly. This leads to ODR problems (espescially with
std::filesystem::path) since the libstdc++ headers see _WIN32, but the
libstdc++ binaries are ordinary and did not.

Most of these are already written as `#if !defined(_WIN32) ||
defined(__CYGWIN__)`, but it's not really *quite* appropriate for winegcc to
#define __CYGWIN__, since it's not quite that either (even if winegcc does call
this -mcygwin mode). wine shares a lot of its own headers with mingw and
cygwin, and those sometimes use `defined(__MINGW32__)` `defined(__CYGWIN__)`,
etc to cover differences between the 3.

But wineg++ would definitely be more useful if this could be fixed.
I could either see a simple and pragmatic choice of extending the existing
pattern to `#if !defined(_WIN32) || defined(__CYGWIN__) || (defined(__WINE__)
&& !defined(__MSVCRT__))` 

Or a more purist approach could be that things with ODR implications (like
`_GLIBCXX_FILESYSTEM_IS_WINDOWS` should not be set dynamically during
preprocessing of the headers, but should instead have been prerecorded into
bits/c++config.h during libstdc++ configure && make, so that they reflect the
ABI of the shared library that was built.

I originally hit this problem on a target using ubuntu 24.04 (gcc 13.3.0) but
the code on trunk has the same patterns.

Reply via email to