public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed][_GLIBCXX_INLINE_VERSION] Fix constract violation
@ 2023-10-29 21:11 François Dumont
  2023-10-30 13:45 ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: François Dumont @ 2023-10-29 21:11 UTC (permalink / raw)
  To: libstdc++; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

This fixes handle_contract_violation under versioned namespace mode.

Tested under Linux x64 and confirmed to also fix Darwin build.

libstdc++: [_GLIBCXX_INLINE_VERSION] Provide handle_contract_violation 
symbol

libstdc++-v3/ChangeLog:

         * src/experimental/contract.cc
         [_GLIBCXX_INLINE_VERSION](handle_contract_violation): Provide 
symbol
         without version namespace decoration for gcc.

François

[-- Attachment #2: version_ns_contract.diff --]
[-- Type: text/x-patch, Size: 687 bytes --]

diff --git a/libstdc++-v3/src/experimental/contract.cc b/libstdc++-v3/src/experimental/contract.cc
index 504a6c041f1..d550b49c4eb 100644
--- a/libstdc++-v3/src/experimental/contract.cc
+++ b/libstdc++-v3/src/experimental/contract.cc
@@ -67,3 +67,11 @@ handle_contract_violation (const std::experimental::contract_violation &violatio
   std::cerr << std::endl;
 #endif
 }
+
+#if _GLIBCXX_INLINE_VERSION
+// Provide symbol without version namespace decoration for gcc.
+extern "C" __attribute__ ((weak)) void
+_Z25handle_contract_violationRKNSt12experimental18contract_violationE
+(const std::experimental::contract_violation &violation)
+{ handle_contract_violation(violation); }
+#endif

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [committed][_GLIBCXX_INLINE_VERSION] Fix constract violation
  2023-10-29 21:11 [committed][_GLIBCXX_INLINE_VERSION] Fix constract violation François Dumont
@ 2023-10-30 13:45 ` Jonathan Wakely
  2023-10-30 18:31   ` François Dumont
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2023-10-30 13:45 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++, gcc-patches

On Sun, 29 Oct 2023 at 21:11, François Dumont <frs.dumont@gmail.com> wrote:
>
> This fixes handle_contract_violation under versioned namespace mode.
>
> Tested under Linux x64 and confirmed to also fix Darwin build.
>
> libstdc++: [_GLIBCXX_INLINE_VERSION] Provide handle_contract_violation
> symbol
>
> libstdc++-v3/ChangeLog:
>
>          * src/experimental/contract.cc
>          [_GLIBCXX_INLINE_VERSION](handle_contract_violation): Provide
> symbol
>          without version namespace decoration for gcc.

>+#if _GLIBCXX_INLINE_VERSION
>+// Provide symbol without version namespace decoration for gcc.

For the comment in the code, I think this would be better:

// The compiler expects the contract_violation class to be in an unversioned
// namespace, so provide a forwarding function with the expected symbol name.

Do we want the forwarding function to be a weak symbol? The main
handler function is weak because we want users to be able to override
it with their own handler. But for this new forwarding function, they
can't even declare it (because it has a reserved name that doesn't
demangle to a valid type for the versioned namespace build).


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [committed][_GLIBCXX_INLINE_VERSION] Fix constract violation
  2023-10-30 13:45 ` Jonathan Wakely
@ 2023-10-30 18:31   ` François Dumont
  2023-10-30 19:14     ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: François Dumont @ 2023-10-30 18:31 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches


On 30/10/2023 14:45, Jonathan Wakely wrote:
> On Sun, 29 Oct 2023 at 21:11, François Dumont <frs.dumont@gmail.com> wrote:
>> This fixes handle_contract_violation under versioned namespace mode.
>>
>> Tested under Linux x64 and confirmed to also fix Darwin build.
>>
>> libstdc++: [_GLIBCXX_INLINE_VERSION] Provide handle_contract_violation
>> symbol
>>
>> libstdc++-v3/ChangeLog:
>>
>>           * src/experimental/contract.cc
>>           [_GLIBCXX_INLINE_VERSION](handle_contract_violation): Provide
>> symbol
>>           without version namespace decoration for gcc.
>> +#if _GLIBCXX_INLINE_VERSION
>> +// Provide symbol without version namespace decoration for gcc.
> For the comment in the code, I think this would be better:
>
> // The compiler expects the contract_violation class to be in an unversioned
> // namespace, so provide a forwarding function with the expected symbol name.
Sure, I'll update it.
> Do we want the forwarding function to be a weak symbol? The main
> handler function is weak because we want users to be able to override
> it with their own handler. But for this new forwarding function, they
> can't even declare it (because it has a reserved name that doesn't
> demangle to a valid type for the versioned namespace build).
>
Good point, I see no reason neither so I'll remove it.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [committed][_GLIBCXX_INLINE_VERSION] Fix constract violation
  2023-10-30 18:31   ` François Dumont
@ 2023-10-30 19:14     ` Jonathan Wakely
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2023-10-30 19:14 UTC (permalink / raw)
  To: François Dumont; +Cc: Jonathan Wakely, libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1571 bytes --]

On Mon, 30 Oct 2023, 18:31 François Dumont, <frs.dumont@gmail.com> wrote:

>
> On 30/10/2023 14:45, Jonathan Wakely wrote:
> > On Sun, 29 Oct 2023 at 21:11, François Dumont <frs.dumont@gmail.com>
> wrote:
> >> This fixes handle_contract_violation under versioned namespace mode.
> >>
> >> Tested under Linux x64 and confirmed to also fix Darwin build.
> >>
> >> libstdc++: [_GLIBCXX_INLINE_VERSION] Provide handle_contract_violation
> >> symbol
> >>
> >> libstdc++-v3/ChangeLog:
> >>
> >>           * src/experimental/contract.cc
> >>           [_GLIBCXX_INLINE_VERSION](handle_contract_violation): Provide
> >> symbol
> >>           without version namespace decoration for gcc.
> >> +#if _GLIBCXX_INLINE_VERSION
> >> +// Provide symbol without version namespace decoration for gcc.
> > For the comment in the code, I think this would be better:
> >
> > // The compiler expects the contract_violation class to be in an
> unversioned
> > // namespace, so provide a forwarding function with the expected symbol
> name.
> Sure, I'll update it.
> > Do we want the forwarding function to be a weak symbol? The main
> > handler function is weak because we want users to be able to override
> > it with their own handler. But for this new forwarding function, they
> > can't even declare it (because it has a reserved name that doesn't
> > demangle to a valid type for the versioned namespace build).
> >
> Good point, I see no reason neither so I'll remove it.
>

Thanks, looks good for trunk (and gcc-13 maybe?) with that change.

>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-30 19:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-29 21:11 [committed][_GLIBCXX_INLINE_VERSION] Fix constract violation François Dumont
2023-10-30 13:45 ` Jonathan Wakely
2023-10-30 18:31   ` François Dumont
2023-10-30 19:14     ` Jonathan Wakely

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).