From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1873) id F35E83858C39; Thu, 30 Sep 2021 16:41:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F35E83858C39 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain Buclaw To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3985] libphobos: Define main function as extern(C) when compiling without D runtime (PR102476) X-Act-Checkin: gcc X-Git-Author: Iain Buclaw X-Git-Refname: refs/heads/master X-Git-Oldrev: ef37ddf477ac4b21ec4d1be9260cfd3b431fd4a9 X-Git-Newrev: d46a29d919058fb383d19fe35c234fab58286f71 Message-Id: <20210930164115.F35E83858C39@sourceware.org> Date: Thu, 30 Sep 2021 16:41:15 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Sep 2021 16:41:16 -0000 https://gcc.gnu.org/g:d46a29d919058fb383d19fe35c234fab58286f71 commit r12-3985-gd46a29d919058fb383d19fe35c234fab58286f71 Author: Iain Buclaw 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; + } }