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: Sat, 24 Dec 2022 17:19:16 +0000 [thread overview] Message-ID: <bug-108183-4-N7QqNXfdmf@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 #14 from Iain Sandoe <iains at gcc dot gnu.org> --- coming back to this code: === 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); } ==== I think this is not currently doing what is expected (it's certainly inconsistent with the compiler's PoV .. from my debugging). ---- The declaration in the compiler thinks that _M2_termios_ctor is the symbol for a function. Where (because of the way this shim is written) it's actually the name of a static variable. Which means if it was ever called "boom". However, my current understanding us that M2_link() is just a mechanism to ensure that all the library code is pulled in (so perhaps it would never be called). Actually, that should not be necessary if the decls are correctly marked as "used". Furthermore, the initialisation code for the static instance will be entered automatically into the startup (so it's out of your control). ===== What about, instead: 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) { } extern "C" void _M2_termios_ctor (void) { M2RTS_RegisterModule ("termios", _M2_termios_init, _M2_termios_fini, _M2_termios_dep); } == now the symbol will indeed refer to the CTOR that causes the module to be registered. As it is written that CTOR will not be called unless you do it. IFF you want it to be called "automatically" at program startup .. you can mark it __attribute__((constructor))
next prev parent reply other threads:[~2022-12-24 17:19 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 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 [this message] 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-N7QqNXfdmf@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: linkBe 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).