public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3985] libphobos: Define main function as extern(C) when compiling without D runtime (PR102476) Date: Thu, 30 Sep 2021 16:41:15 +0000 (GMT) [thread overview] Message-ID: <20210930164115.F35E83858C39@sourceware.org> (raw) https://gcc.gnu.org/g:d46a29d919058fb383d19fe35c234fab58286f71 commit r12-3985-gd46a29d919058fb383d19fe35c234fab58286f71 Author: Iain Buclaw <ibuclaw@gdcproject.org> Date: Fri Sep 24 10:59:47 2021 +0200 libphobos: Define main function as extern(C) when compiling without D runtime (PR102476) The default supplied main function as read when compiling with `-fmain' has extern(D) linkage. However this does not work when mixing this option together with `-fno-druntime'. PR d/102476 gcc/testsuite/ChangeLog: * gdc.dg/pr102476.d: New test. libphobos/ChangeLog: * libdruntime/__main.di: Define main function as extern(C) when compiling without D runtime. Diff: --- gcc/testsuite/gdc.dg/pr102476.d | 3 +++ libphobos/libdruntime/__main.di | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gdc.dg/pr102476.d b/gcc/testsuite/gdc.dg/pr102476.d new file mode 100644 index 00000000000..543716eb37d --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr102476.d @@ -0,0 +1,3 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102476 +// { dg-do link } +// { dg-options "-fmain -fno-druntime" } diff --git a/libphobos/libdruntime/__main.di b/libphobos/libdruntime/__main.di index 8062bf4d1e8..ab1264b98f1 100644 --- a/libphobos/libdruntime/__main.di +++ b/libphobos/libdruntime/__main.di @@ -20,7 +20,17 @@ module __main; -int main(char[][]) +version (D_BetterC) { - return 0; + extern (C) int main(int, char**) + { + return 0; + } +} +else +{ + int main(char[][]) + { + return 0; + } }
reply other threads:[~2021-09-30 16:41 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210930164115.F35E83858C39@sourceware.org \ --to=ibuclaw@gcc.gnu.org \ --cc=gcc-cvs@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).