D Front End for GCC - Release 0.24

Last update: August 22, 2007

Supported Systems

Similar versions of the above systems should work and other Unix platforms may work.  Although the compiler will probably work on most architectures, the D runtime library will still need to be updated to support them.

Requirements

The MacOS X universal binary package requires XCode 2.4.1 or the equivalent version of cctools.

Downloads

Links

Contact

David Friedman
e-mail: dvdfrdmn <at> users.sf.net

Status

Known Issues

Known Differences from DMD

Inline Assembler Notes

Usage

Invoking gdc and gdmd

The compiler driver is named 'gdc' and accepts the standard GCC options.  There is also a script named 'gdmd' which has the same interface as the Digital Mars dmd.

The mapping from DMD options to GCC is as follows:
-c
-c
-D
-fdoc
-Dd<docdir>
-fdoc-dir=<docdir>
-Df<filename>
-fdoc-file=<filename>
-d -fdeprecated
-debug[=<arg>]
-fdebug[=<arg>]
-g
-g
-inline
-finline-functions
-I<path>
-I <path>
-J<path>
-J<path>
-L<arg>
-Wl,<arg>
-O
-O3 without inlining (may not be equivalent)
-o-
-fsyntax-only
-od<dir>
no equivalent; use the wrapper script
-of<file> -o <file>
-op<dir>
no equivalent; use the wrapper script
-profile
(see the GCC manual for profiling options)
-quiet
no equivalent
-release
-frelease
-run
no equivalent; use the wrapper script
-unittest
-funittest
-version=<arg>
-fversion=<arg>
-w
-Wall
<.ddoc file>
-fdoc-inc=<.ddoc file>

Other options:
-f[no-]bounds-check
Controls array bounds checking
-femit-templates[=normal|private|all|none|auto]
-f[no-]emit-templates
Controls whether or not template code is emitted.

"normal" -- Emit templates, expecting multiple copies to be merged by the linker.
"private" -- Emit templates, but make them private to the translation unit.  The executable will have multiple copies of code and data.
"all" -- Emit all template instances with public visibility.  Do this even if they would not normally be emitted.
"none" -- Do not emit templates at all.
"auto" -- For targets that support templates, the "full" mode is used.  Otherwise, the "private" mode is used.

"none" and -fno-emit-templates are synonyms.
"auto" and -femit-templates are synonyms.
-fall-sources
For each source file on the command line, semantically process each file preceding it.  Use this if compilation errors occur due to complicated circular module references.  This will slow compilation noticeably.
-fdump-source
Dump decoded UTF-8 text and source from HTML to <source>.utf-8 and <source>.d.utf-8.

Extensions

Extended Assembler
GDC implements a GCC extension that allows inline assembler with D expression operands.  It is available on nearly all targets, not just i386.  The syntax differs from the C language extension in the follow ways. Unlike i386 inline assembler statements, extended assembler statements do not prevent a function from being inlined.

See the GCC manual for more information about this extension.

Example:

uint invert(uint v)
{
    uint result;
    version(X86)
       asm{ "notl %[iov]" : [iov] "=r" result : "0" v; }
    else version(PPC)
       asm{ "nor %[oresult],%[iv],%[iv]" : [oresult] "=r" result : [iv] "r" v; }
    return result;
}
Declaration and Type Attributes
(This extension is a work in progress.)

GDC implements the GCC __attribute__ extension with two pragmas:

pragma(GNU_attribute, name1(arg1, arg2, ...), ...) declarations...

pragma(GNU_set_attribute, symbol, name1(arg1, arg2...), ...);

If an attribute has no arguments, the argument list may be omitted.

The first form applies to declarations directly contained in the pragma.  The second form affects the given symbol.  See the GCC manual for a list of attributes that can be set.  Not all attributes are supported yet by GDC.  Also, the interaction between these extended attributes and D languge attributes (alignment, for example) is not well defined.

Changes

0.24: 0.23: 0.22: 0.21: 0.20: 0.19: 0.18:
0.17:
0.16:

0.15:
    Updated to DMD 0.128

0.14:

0.13:
0.12.1:
0.12: