public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/108331] [13 Regression] ABI break of std::__c_file and std::fstream for win32 thread model of GCC for windows
Date: Sat, 07 Jan 2023 22:31:59 +0000	[thread overview]
Message-ID: <bug-108331-4-TuU7AJoQhy@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108331-4@http.gcc.gnu.org/bugzilla/>

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu.org
   Last reconfirmed|                            |2023-01-07
     Ever confirmed|0                           |1
            Summary|ABI break of std::__c_file  |[13 Regression] ABI break
                   |and std::fstream for win32  |of std::__c_file and
                   |thread model of GCC for     |std::fstream for win32
                   |windows                     |thread model of GCC for
                   |                            |windows
   Target Milestone|---                         |13.0
           Keywords|                            |ABI
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to cqwrteur from comment #0)
> I do not understand why you need a mutex for std::fstream.

It is there for historical reasons, it's completely unused.

> Now win32, posix
> and mcf thread model they cause abi issues for this due to that lock. Can we
> unify the abi for windows here?

No. The thread model is already ABI-changing, there is no way to make
std::mutex ABI compatible when it has a wildly different implementation.

But the std::basic_filebuf::_M_lock member does indeed change layout for the
win32 thread model between GCC 12 and GCC 13. We can't make the ABI consistent
between different thread models, but we do want it to be consistent for a
single thread model.

Since that mutex is unused anyway, we should just define it consistently with
GCC 12 for the win32 thread model, i.e. as a struct like:

typedef struct {
  long counter;
  void *sema;
} __gthread_mutex_t;

Eric, can we add a new macro to gthr-win32.h that says "this is the win32
thread model" which libstdc++ can then use like so:

--- a/libstdc++-v3/config/io/c_io_stdio.h
+++ b/libstdc++-v3/config/io/c_io_stdio.h
@@ -39,7 +39,17 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION

+#ifdef __GTHREAD_WIN32
+  // The layout of __gthread_mutex_t changed in GCC 13, but libstdc++ doesn't
+  // actually use the basic_filebuf::_M_lock member, so define it consistently
+  // with the old __gthread_mutex_t to avoid an unnecessary layout change:
+  struct __c_lock {
+    long counter;
+    void *sema;
+  };
+#else
   typedef __gthread_mutex_t __c_lock;
+#endif

   // for basic_file.h
   typedef FILE __c_file;

  reply	other threads:[~2023-01-07 22:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-07 21:19 [Bug libstdc++/108331] New: " unlvsur at live dot com
2023-01-07 22:31 ` redi at gcc dot gnu.org [this message]
2023-01-07 22:33 ` [Bug libstdc++/108331] [13 Regression] " redi at gcc dot gnu.org
2023-01-07 23:43 ` ebotcazou at gcc dot gnu.org
2023-01-09 11:36 ` redi at gcc dot gnu.org
2023-01-09 11:42 ` ebotcazou at gcc dot gnu.org
2023-01-10  8:08 ` rguenth at gcc dot gnu.org
2023-01-10 11:44 ` redi at gcc dot gnu.org
2023-01-13 13:42 ` cvs-commit at gcc dot gnu.org
2023-01-13 13:45 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108331-4-TuU7AJoQhy@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).