public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "iains at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug modula2/108183] wrong code generated in the modula2 scaffold mechanism
Date: Tue, 20 Dec 2022 09:36:05 +0000	[thread overview]
Message-ID: <bug-108183-4-QGOdIrkPej@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108183-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Gaius Mulley from comment #3)
> The scaffold array (referencing each module ctor) is generated
> gcc/m2/gm2-compiler/M2Quads.mod:2402 and ctors are created in: 
> gcc/m2/gm2-gcc/m2decl.cc

terms was one example (of several cases)

I had already found the code in M2Quads & Scaffold and m2decl.cc.

However, not being familiar with m2 (or the design here) .. that was not
leading me to the right code.

It seems that m2decl_DeclareModuleCtor is only called for the module that *is*
in the current TU (so Hello, in the case of a hello world example).  I've tried
putting breakpoints on m2decl_BuildEndFunctionDeclaration() [which seems to be
called for some of the actors, but I do not (for example) see a call for
_M2_termios_ctor).

In the termios.cc file:

struct _M2_termios_ctor { _M2_termios_ctor (); } _M2_termios_ctor;

the symbol '_M2_termios_ctor' does not seem to refer to a function, but to a
static instance of struct _M2_termios_ctor .. so I'm still confused about what
is supposed to happen.

===

extern "C" void
_M2_termios_init (int, char *[], char *[])
{
}

extern "C" void
_M2_termios_fini (int, char *[], char *[])
{
}

extern "C" void
_M2_termios_dep (void)
{
}

struct _M2_termios_ctor { _M2_termios_ctor (); } _M2_termios_ctor;

_M2_termios_ctor::_M2_termios_ctor (void)
{
//  M2RTS_RegisterModule ("termios", _M2_termios_init, _M2_termios_fini,
//                      _M2_termios_dep);
}

===

        .globl __M2_termios_fini
__M2_termios_fini:
        ret

        .globl __M2_termios_dep
__M2_termios_dep:
        ret

// here are the CTORs...

        .align 1,0x90
        .globl __ZN16_M2_termios_ctorC2Ev
__ZN16_M2_termios_ctorC2Ev:
        ret

        .align 1,0x90
        .globl __ZN16_M2_termios_ctorC1Ev
__ZN16_M2_termios_ctorC1Ev:
        ret:

// and here is the external symbol __M2_termios_ctor
// (ignore the extra leading '_' that's an ABI thing)

        .globl __M2_termios_ctor
        .zerofill __DATA,__common,__M2_termios_ctor,1,0

  parent reply	other threads:[~2022-12-20  9:36 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-19 23:45 [Bug modula2/108183] New: " iains at gcc dot gnu.org
2022-12-19 23:46 ` [Bug modula2/108183] " iains at gcc dot gnu.org
2022-12-19 23:57 ` iains at gcc dot gnu.org
2022-12-20  8:20 ` gaius at gcc dot gnu.org
2022-12-20  8:38 ` gaius at gcc dot gnu.org
2022-12-20  9:36 ` iains at gcc dot gnu.org [this message]
2022-12-20 10:00 ` iains at gcc dot gnu.org
2022-12-20 12:34 ` iains at gcc dot gnu.org
2022-12-20 12:37 ` iains at gcc dot gnu.org
2022-12-20 12:45 ` rguenth at gcc dot gnu.org
2022-12-20 20:21 ` iains at gcc dot gnu.org
2022-12-20 20:42 ` iains at gcc dot gnu.org
2022-12-20 21:24 ` gaius at gcc dot gnu.org
2022-12-21 15:35 ` iains at gcc dot gnu.org
2022-12-21 15:39 ` iains at gcc dot gnu.org
2022-12-24 17:19 ` iains at gcc dot gnu.org
2022-12-28 16:07 ` gaius at gcc dot gnu.org
2022-12-31 12:54 ` iains at gcc dot gnu.org
2022-12-31 12:57 ` iains at gcc dot gnu.org
2023-01-01  9:29 ` cvs-commit at gcc dot gnu.org
2023-01-02 11:21 ` iains at gcc dot gnu.org
2023-01-02 12:20 ` iains at gcc dot gnu.org
2023-01-04 14:55 ` cvs-commit at gcc dot gnu.org
2023-01-04 16:22 ` iains 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-108183-4-QGOdIrkPej@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).