public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Schwinge <thomas@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Cc: Jonathan Wakely <jwakely@redhat.com>, <libstdc++@gcc.gnu.org>,
	"Tom de Vries" <tdevries@suse.de>
Subject: nvptx: Use the usual '#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)' (was: libstdc++ "freestanding" ('--disable-hosted-libstdcxx') with '-fno-rtti', '-fno-exceptions': 'libstdc++-v3/libsupc++/tinfo.cc')
Date: Mon, 6 Nov 2023 15:57:52 +0100	[thread overview]
Message-ID: <87jzqvudxr.fsf@euler.schwinge.homeip.net> (raw)
In-Reply-To: <CACb0b4nE4UnAXTaGMci_zFD75o-8x9YNve6iY_yQVD-=T=idwQ@mail.gmail.com>

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

Hi!

On 2022-07-14T19:39:40+0100, Jonathan Wakely <jwakely@redhat.com> wrote:
> On Thu, 14 Jul 2022 at 19:14, Thomas Schwinge <thomas@codesourcery.com> wrote:
>> I'm looking into building GCN, nvptx offloading libstdc++ [...]

>> While there is some experimental/incomplete/not-to-be-relied-on support
>> for PTX symbol aliases, we're currently generally running into
>> "error: alias definitions not supported in this configuration"

>>     [...]/libstdc++-v3/libsupc++/tinfo.cc:55:1: error: alias definitions not supported in this configuration
>>        55 | std::type_info::__equal (const std::type_info& arg) const _GLIBCXX_NOEXCEPT
>>           | ^~~
>>     make[4]: *** [Makefile:777: tinfo.lo] Error 1
>>
>> That's 'libstdc++-v3/libsupc++/tinfo.cc':
>>
>>      1 // Methods for type_info for -*- C++ -*- Run Time Type Identification.
>>     [...]
>>     39 // We can't rely on common symbols being shared between shared objects.
>>     40 bool std::type_info::
>>     41 operator== (const std::type_info& arg) const _GLIBCXX_NOEXCEPT
>>     42 {
>>     43 #if __GXX_MERGED_TYPEINFO_NAMES
>>     44   return name () == arg.name ();
>>     45 #else
>>     46   /* The name() method will strip any leading '*' prefix. Therefore
>>     47      take care to look at __name rather than name() when looking for
>>     48      the "pointer" prefix.  */
>>     49   return (&arg == this)
>>     50     || (__name[0] != '*' && (__builtin_strcmp (name (), arg.name ()) == 0));
>>     51 #endif
>>     52 }
>>     53
>>     54 bool
>>     55 std::type_info::__equal (const std::type_info& arg) const _GLIBCXX_NOEXCEPT
>>     56 __attribute__((alias("_ZNKSt9type_infoeqERKS_")));
>>     57 #endif
>>     [...]
>>
>> ..., so there's a manual alias from the line 55 function to the line 41
>> function (if I got that right).
>
> That's only there for backwards compatibility on ARM EABI and other
> targets that don't define __GXX_TYPEINFO_EQUALITY_INLINE==1.
>
> My suggestion would be to define that macro for the target.

Thanks, that did put me on the right track -- we shall define it this
way; indirectly.

Pushed to master branch commit 9837f62f066db532c9db6df38ccf2653d0c3a960
"nvptx: Use the usual '#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)'",
see attached.


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-nvptx-Use-the-usual-define-MAKE_DECL_ONE_ONLY-DECL-D.patch --]
[-- Type: text/x-diff, Size: 2765 bytes --]

From 9837f62f066db532c9db6df38ccf2653d0c3a960 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Thu, 14 Jul 2022 23:22:35 +0200
Subject: [PATCH] nvptx: Use the usual '#define MAKE_DECL_ONE_ONLY(DECL)
 (DECL_WEAK (DECL) = 1)'

With this 'MAKE_DECL_ONE_ONLY' definition, we get 'SUPPORTS_ONE_ONLY', and thus
'__GXX_WEAK__', and thus '__GXX_TYPEINFO_EQUALITY_INLINE'.  This unblocks build
of 'libstdc++-v3/libsupc++/tinfo.cc', which otherwise depends on symbol alias
support, which GCC/nvptx doesn't generally provide.  Also, this gets us a
number of FAIL -> PASS progressions in the test suite.

Given that GCC/nvptx support for weak symbols isn't complete, we also get a few
more of the already-known
'error: PTX does not support weak declarations (only weak definitions)':

    [-PASS:-]{+FAIL:+} g++.old-deja/g++.other/crash11.C  -std=c++14 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.old-deja/g++.other/crash11.C  -std=c++17 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.old-deja/g++.other/crash11.C  -std=c++20 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.old-deja/g++.other/crash11.C  -std=c++98 (test for excess errors)

    [-PASS:-]{+FAIL:+} g++.old-deja/g++.pt/crash29.C  -std=c++14 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.old-deja/g++.pt/crash29.C  -std=c++17 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.old-deja/g++.pt/crash29.C  -std=c++20 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.old-deja/g++.pt/crash29.C  -std=c++98 (test for excess errors)

    [-PASS:-]{+FAIL:+} 23_containers/map/56613.cc  -std=gnu++17 (test for excess errors)

... as well as one more of the already-known
'sorry, unimplemented: target cannot support nonlocal goto':

    PASS: g++.dg/tree-ssa/pr22488.C  -std=gnu++14 (test for excess errors)
    PASS: g++.dg/tree-ssa/pr22488.C  -std=gnu++17 (test for excess errors)
    PASS: g++.dg/tree-ssa/pr22488.C  -std=gnu++20 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/tree-ssa/pr22488.C  -std=gnu++98 (test for excess errors)

We shall look into these, later.

	gcc/
	* config/nvptx/nvptx.h (MAKE_DECL_ONE_ONLY): Define.
---
 gcc/config/nvptx/nvptx.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
index 129427e5654..407fd70f06a 100644
--- a/gcc/config/nvptx/nvptx.h
+++ b/gcc/config/nvptx/nvptx.h
@@ -319,6 +319,9 @@ struct GTY(()) machine_function
 
 #define SUPPORTS_WEAK 1
 
+#define MAKE_DECL_ONE_ONLY(DECL) \
+  (DECL_WEAK (DECL) = 1)
+
 /* The documentation states that ASM_OUTPUT_DEF_FROM_DECLS is used in
    preference to ASM_OUTPUT_DEF if the tree nodes are available.  However, we
    need the tree nodes to emit the prototype, so at this point it's not clear
-- 
2.34.1


      reply	other threads:[~2023-11-06 14:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-14 16:42 libstdc++ "freestanding" ('--disable-hosted-libstdcxx') with '-fno-rtti', '-fno-exceptions': 'libstdc++-v3/libsupc++/tinfo.cc' Thomas Schwinge
2022-07-14 18:39 ` Jonathan Wakely
2023-11-06 14:57   ` Thomas Schwinge [this message]

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=87jzqvudxr.fsf@euler.schwinge.homeip.net \
    --to=thomas@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    --cc=tdevries@suse.de \
    /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).