Bug 102476 - d: Options -fmain and -fno-druntime do not work together
Summary: d: Options -fmain and -fno-druntime do not work together
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: d (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: ---
Assignee: Iain Buclaw
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-24 09:10 UTC by Iain Buclaw
Modified: 2021-09-30 16:42 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Iain Buclaw 2021-09-24 09:10:16 UTC
The option `-fmain' reads in a __main.di module from D runtime that defines an extern(D) main function.  This causes link-time errors when building without D runtime.
Comment 1 GCC Commits 2021-09-30 16:41:17 UTC
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

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.
Comment 2 Iain Buclaw 2021-09-30 16:42:25 UTC
Fix committed.