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.
This commit is contained in:
Iain Buclaw 2021-09-24 10:59:47 +02:00
parent ef37ddf477
commit d46a29d919
2 changed files with 15 additions and 2 deletions

View File

@ -0,0 +1,3 @@
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102476
// { dg-do link }
// { dg-options "-fmain -fno-druntime" }

View File

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