public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3985] libphobos: Define main function as extern(C) when compiling without D runtime (PR102476)
@ 2021-09-30 16:41 Iain Buclaw
  0 siblings, 0 replies; only message in thread
From: Iain Buclaw @ 2021-09-30 16:41 UTC (permalink / raw)
  To: gcc-cvs

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;
+    }
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-30 16:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 16:41 [gcc r12-3985] libphobos: Define main function as extern(C) when compiling without D runtime (PR102476) Iain Buclaw

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).