[committed] libphobos: Define main function as extern(C) when compiling without D runtime (PR102476)
Commit Message
Hi,
This patch defines the default supplied main function as read when
compiling with `-fmain' as extern(C) when compiling without D runtime.
The default linkage is extern(D), however this does not work when mixing
`-fmain' together with `-fno-druntime'.
Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32, and
committed to mainline.
Regards
Iain
---
gcc/testsuite/ChangeLog:
PR d/102476
* gdc.dg/pr102476.d: New test.
libphobos/ChangeLog:
PR d/102476
* libdruntime/__main.di: Define main function as extern(C) when
compiling without D runtime.
---
gcc/testsuite/gdc.dg/pr102476.d | 3 +++
libphobos/libdruntime/__main.di | 14 ++++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gdc.dg/pr102476.d
new file mode 100644
@@ -0,0 +1,3 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102476
+// { dg-do link }
+// { dg-options "-fmain -fno-druntime" }
@@ -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;
+ }
}