summaryrefslogtreecommitdiff
path: root/gcc/d/gdc.texi
blob: 24b6ee00478943fde0849b1b4c8733a4bf54827b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
\input texinfo @c -*-texinfo-*-
@setfilename gdc.info
@settitle The GNU D Compiler

@c Create a separate index for command line options
@defcodeindex op
@c Merge the standard indexes into a single one.
@syncodeindex fn cp
@syncodeindex vr cp
@syncodeindex ky cp
@syncodeindex pg cp
@syncodeindex tp cp

@include gcc-common.texi

@c Copyright years for this manual.
@set copyrights-d 2006-2023

@copying
@c man begin COPYRIGHT
Copyright @copyright{} @value{copyrights-d} Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the
@c man end
section entitled ``GNU Free Documentation License''.
@ignore
@c man begin COPYRIGHT
man page gfdl(7).
@c man end
@end ignore
@end copying

@ifinfo
@format
@dircategory Software development
@direntry
* gdc: (gdc).               A GCC-based compiler for the D language
@end direntry
@end format

@insertcopying
@end ifinfo

@titlepage
@title The GNU D Compiler
@versionsubtitle
@author David Friedman, Iain Buclaw

@page
@vskip 0pt plus 1filll
Published by the Free Software Foundation @*
51 Franklin Street, Fifth Floor@*
Boston, MA 02110-1301, USA@*
@sp 1
@insertcopying
@end titlepage
@contents
@page

@node Top
@top Introduction

This manual describes how to use @command{gdc}, the GNU compiler for
the D programming language.  This manual is specifically about how to
invoke @command{gdc}, as well as its features and incompatibilities.
For more information about the D programming language in general,
including language specifications and standard package documentation,
see @uref{https://dlang.org/}.

@menu
* Invoking gdc::                How to run gdc.
* D Implementation::            User-visible implementation details.
* Copying::                     The GNU General Public License.
* GNU Free Documentation License::
                                How you can share and copy this manual.
* Option Index::                Index of command line options.
* Keyword Index::               Index of concepts.
@end menu

@node Invoking gdc
@chapter Invoking gdc

@c man title gdc A GCC-based compiler for the D language

@ignore
@c man begin SYNOPSIS gdc
gdc [@option{-c}|@option{-S}] [@option{-g}] [@option{-pg}]
    [@option{-O}@var{level}] [@option{-W}@var{warn}@dots{}]
    [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
    [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}]
    [@option{-o} @var{outfile}] [@@@var{file}] @var{infile}@dots{}

Only the most useful options are listed here; see below for the
remainder.
@c man end
@c man begin SEEALSO
gpl(7), gfdl(7), fsf-funding(7), gcc(1)
and the Info entries for @file{gdc} and @file{gcc}.
@c man end
@end ignore

@c man begin DESCRIPTION gdc

The @command{gdc} command is the GNU compiler for the D language and
supports many of the same options as @command{gcc}.  @xref{Option Summary, ,
Option Summary, gcc, Using the GNU Compiler Collection (GCC)}.
This manual only documents the options specific to @command{gdc}.

@c man end

@menu
* Input and Output files::  Controlling the kind of output:
                            an executable, object files, assembler files,
* Runtime Options::         Options controlling runtime behavior
* Directory Options::       Where to find module files
* Code Generation::         Options controlling the output of gdc
* Warnings::                Options controlling warnings specific to gdc
* Linking::                 Options influencing the linking step
* Developer Options::       Options useful for developers of gdc
@end menu

@c man begin OPTIONS

@node Input and Output files
@section Input and Output files
@cindex suffixes for D source
@cindex D source file suffixes

For any given input file, the file name suffix determines what kind of
compilation is done.  The following kinds of input file names are supported:

@table @gcctabopt
@item @var{file}.d
D source files.
@item @var{file}.dd
Ddoc source files.
@item @var{file}.di
D interface files.
@end table

You can specify more than one input file on the @command{gdc} command line,
each being compiled separately in the compilation process.  If you specify a
@code{-o @var{file}} option, all the input files are compiled together,
producing a single output file, named @var{file}.  This is allowed even
when using @code{-S} or @code{-c}.

@cindex D interface files.
A D interface file contains only what an import of the module needs,
rather than the whole implementation of that module.  They can be created
by @command{gdc} from a D source file by using the @code{-H} option.
When the compiler resolves an import declaration, it searches for matching
@file{.di} files first, then for @file{.d}.

@cindex Ddoc source files.
A Ddoc source file contains code in the D macro processor language.  It is
primarily designed for use in producing user documentation from embedded
comments, with a slight affinity towards HTML generation.  If a @file{.d}
source file starts with the string @code{Ddoc} then it is treated as general
purpose documentation, not as a D source file.

@node Runtime Options
@section Runtime Options
@cindex options, runtime

These options affect the runtime behavior of programs compiled with
@command{gdc}.

@table @gcctabopt

@opindex fall-instantiations
@opindex fno-all-instantiations
@item -fall-instantiations
Generate code for all template instantiations.  The default template emission
strategy is to not generate code for declarations that were either
instantiated speculatively, such as from @code{__traits(compiles, ...)}, or
that come from an imported module not being compiled.

@opindex fassert
@opindex fno-assert
@item -fno-assert
Turn off code generation for @code{assert} contracts.

@opindex fbounds-check
@opindex fno-bounds-check
@item -fno-bounds-check
Turns off array bounds checking for all functions, which can improve
performance for code that uses arrays extensively.  Note that this
can result in unpredictable behavior if the code in question actually
does violate array bounds constraints.  It is safe to use this option
if you are sure that your code never throws a @code{RangeError}.

@opindex fbounds-check=
@item -fbounds-check=@var{value}
An alternative to @option{-fbounds-check} that allows more control
as to where bounds checking is turned on or off.  The following values
are supported:

@table @samp
@item on
Turns on array bounds checking for all functions.
@item safeonly
Turns on array bounds checking only for @code{@@safe} functions.
@item off
Turns off array bounds checking completely.
@end table

@opindex fbuiltin
@opindex fno-builtin
@item -fno-builtin
Don't recognize built-in functions unless they begin with the prefix
@samp{__builtin_}.  By default, the compiler will recognize when a
function in the @code{core.stdc} package is a built-in function.

@opindex fcheckaction
@item -fcheckaction=@var{value}
This option controls what code is generated on an assertion, bounds check, or
final switch failure.  The following values are supported:

@table @samp
@item context
Throw an @code{AssertError} with extra context information.
@item halt
Halt the program execution.
@item throw
Throw an @code{AssertError} (the default).
@end table

@opindex fdebug
@opindex fno-debug
@item -fdebug
@item -fdebug=@var{value}
Turn on compilation of conditional @code{debug} code into the program.
The @option{-fdebug} option itself sets the debug level to @code{1},
while @option{-fdebug=} enables @code{debug} code that are identified
by any of the following values:

@table @samp
@item ident
Turns on compilation of any @code{debug} code identified by @var{ident}.
@end table

@opindex fdruntime
@opindex fno-druntime
@item -fno-druntime
Implements @uref{https://dlang.org/spec/betterc.html}.  Assumes that
compilation targets an environment without a D runtime library.

This is equivalent to compiling with the following options:

@example
gdc -nophoboslib -fno-exceptions -fno-moduleinfo -fno-rtti
@end example

@opindex fextern-std
@item -fextern-std=@var{standard}
Sets the C++ name mangling compatibility to the version identified by
@var{standard}.  The following values are supported:

@table @samp
@item c++98
@item c++03
Sets @code{__traits(getTargetInfo, "cppStd")} to @code{199711}.
@item c++11
Sets @code{__traits(getTargetInfo, "cppStd")} to @code{201103}.
@item c++14
Sets @code{__traits(getTargetInfo, "cppStd")} to @code{201402}.
@item c++17
Sets @code{__traits(getTargetInfo, "cppStd")} to @code{201703}.
This is the default.
@item c++20
Sets @code{__traits(getTargetInfo, "cppStd")} to @code{202002}.
@end table

@opindex finvariants
@opindex fno-invariants
@item -fno-invariants
Turns off code generation for class @code{invariant} contracts.

@opindex fmain
@item -fmain
Generates a default @code{main()} function when compiling.  This is useful when
unittesting a library, as it enables running the unittests in a library without
having to manually define an entry-point function.  This option does nothing
when @code{main} is already defined in user code.

@opindex fmoduleinfo
@opindex fno-moduleinfo
@item -fno-moduleinfo
Turns off generation of the @code{ModuleInfo} and related functions
that would become unreferenced without it, which may allow linking
to programs not written in D.  Functions that are not be generated
include module constructors and destructors (@code{static this} and
@code{static ~this}), @code{unittest} code, and @code{DSO} registry
functions for dynamically linked code.

@opindex fonly
@item -fonly=@var{filename}
Tells the compiler to parse and run semantic analysis on all modules
on the command line, but only generate code for the module specified
by @var{filename}.

@opindex fpostconditions
@opindex fno-postconditions
@item -fno-postconditions
Turns off code generation for postcondition @code{out} contracts.

@opindex fpreconditions
@opindex fno-preconditions
@item -fno-preconditions
Turns off code generation for precondition @code{in} contracts.

@opindex fpreview
@item -fpreview=@var{id}
Turns on an upcoming D language change identified by @var{id}.  The following
values are supported:

@table @samp
@item all
Turns on all upcoming D language features.
@item bitfields
Implements bit-fields in D.
@item dip1000
Implements @uref{https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1000.md}
(Scoped pointers).
@item dip1008
Implements @uref{https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1008.md}
(Allow exceptions in @code{@@nogc} code).
@item dip1021
Implements @uref{https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1021.md}
(Mutable function arguments).
@item dip25
Implements @uref{https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP25.md}
(Sealed references).
@item dtorfields
Turns on generation for destructing fields of partially constructed objects.
@item fieldwise
Turns on generation of struct equality to use field-wise comparisons.
@item fixaliasthis
Implements new lookup rules that check the current scope for @code{alias this}
before searching in upper scopes.
@item fiximmutableconv
Disallows unsound immutable conversions that were formerly incorrectly
permitted.
@item in
Implements @code{in} parameters to mean @code{scope const [ref]} and accepts
rvalues.
@item inclusiveincontracts
Implements @code{in} contracts of overridden methods to be a superset of parent
contract.
@item nosharedaccess
Turns off and disallows all access to shared memory objects.
@item rvaluerefparam
Implements rvalue arguments to @code{ref} parameters.
@item systemvariables
Disables access to variables marked @code{@@system} from @code{@@safe} code.
@end table

@opindex frelease
@opindex fno-release
@item -frelease
Turns on compiling in release mode, which means not emitting runtime
checks for contracts and asserts.  Array bounds checking is not done
for @code{@@system} and @code{@@trusted} functions, and assertion
failures are undefined behavior.

This is equivalent to compiling with the following options:

@example
gdc -fno-assert -fbounds-check=safe -fno-invariants \
    -fno-postconditions -fno-preconditions -fno-switch-errors
@end example

@opindex frevert
@item -frevert=
Turns off a D language feature identified by @var{id}.  The following values
are supported:

@table @samp
@item all
Turns off all revertable D language features.
@item dip1000
Reverts @uref{https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1000.md}
(Scoped pointers).
@item dip25
Reverts @uref{https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP25.md}
(Sealed references).
@item dtorfields
Turns off generation for destructing fields of partially constructed objects.
@item intpromote
Turns off C-style integral promotion for unary @code{+}, @code{-} and @code{~}
expressions.
@end table

@opindex frtti
@opindex fno-rtti
@item -fno-rtti
Turns off generation of run-time type information for all user defined types.
Any code that uses features of the language that require access to this
information will result in an error.

@opindex fswitch-errors
@opindex fno-switch-errors
@item -fno-switch-errors
This option controls what code is generated when no case is matched
in a @code{final switch} statement.  The default run time behavior
is to throw a @code{SwitchError}.  Turning off @option{-fswitch-errors}
means that instead the execution of the program is immediately halted.

@opindex funittest
@opindex fno-unittest
@item -funittest
Turns on compilation of @code{unittest} code, and turns on the
@code{version(unittest)} identifier.  This implies @option{-fassert}.

@opindex fversion
@item -fversion=@var{value}
Turns on compilation of conditional @code{version} code into the program
identified by any of the following values:

@table @samp
@item ident
Turns on compilation of @code{version} code identified by @var{ident}.
@end table

@opindex fweak-templates
@opindex fno-weak-templates
@item -fno-weak-templates
Turns off emission of declarations that can be defined in multiple objects as
weak symbols.  The default is to emit all public symbols as weak, unless the
target lacks support for weak symbols.  Disabling this option means that common
symbols are instead put in COMDAT or become private.

@end table

@node Directory Options
@section Options for Directory Search
@cindex directory options
@cindex options, directory search
@cindex search path

These options specify directories to search for files, libraries, and
other parts of the compiler:

@table @gcctabopt

@opindex I
@item -I@var{dir}
Specify a directory to use when searching for imported modules at
compile time.  Multiple @option{-I} options can be used, and the
paths are searched in the same order.

@opindex J
@item -J@var{dir}
Specify a directory to use when searching for files in string imports
at compile time.  This switch is required in order to use
@code{import(file)} expressions.  Multiple @option{-J} options can be
used, and the paths are searched in the same order.

@opindex L
@item -L@var{dir}
When linking, specify a library search directory, as with @command{gcc}.

@opindex B
@item -B@var{dir}
This option specifies where to find the executables, libraries,
source files, and data files of the compiler itself, as with @command{gcc}.

@opindex fmodule-file
@item -fmodule-file=@var{module}=@var{spec}
This option manipulates file paths of imported modules, such that if an
imported module matches all or the leftmost part of @var{module}, the file
path in @var{spec} is used as the location to search for D sources.
This is used when the source file path and names are not the same as the
package and module hierarchy.  Consider the following examples:

@example
gdc test.d -fmodule-file=A.B=foo.d -fmodule-file=C=bar
@end example

This will tell the compiler to search in all import paths for the source
file @var{foo.d} when importing @var{A.B}, and the directory @var{bar/}
when importing @var{C}, as annotated in the following D code:

@example
module test;
import A.B;     // Matches A.B, searches for foo.d
import C.D.E;   // Matches C, searches for bar/D/E.d
import A.B.C;   // No match, searches for A/B/C.d
@end example

@opindex imultilib
@item -imultilib @var{dir}
Use @var{dir} as a subdirectory of the gcc directory containing
target-specific D sources and interfaces.

@opindex iprefix
@item -iprefix @var{prefix}
Specify @var{prefix} as the prefix for the gcc directory containing
target-specific D sources and interfaces.  If the @var{prefix} represents
a directory, you should include the final @code{'/'}.

@opindex nostdinc
@item -nostdinc
Do not search the standard system directories for D source and interface
files.  Only the directories that have been specified with @option{-I} options
(and the directory of the current file, if appropriate) are searched.

@end table

@node Code Generation
@section Code Generation
@cindex options, code generation

In addition to the many @command{gcc} options controlling code generation,
@command{gdc} has several options specific to itself.

@table @gcctabopt

@opindex H
@item -H
Generates D interface files for all modules being compiled.  The compiler
determines the output file based on the name of the input file, removes
any directory components and suffix, and applies the @file{.di} suffix.

@opindex Hd
@item -Hd @var{dir}
Same as @option{-H}, but writes interface files to directory @var{dir}.
This option can be used with @option{-Hf @var{file}} to independently set the
output file and directory path.

@opindex Hf
@item -Hf @var{file}
Same as @option{-H} but writes interface files to @var{file}.  This option can
be used with @option{-Hd @var{dir}} to independently set the output file and
directory path.

@opindex M
@item -M
Output the module dependencies of all source files being compiled in a
format suitable for @command{make}.  The compiler outputs one
@command{make} rule containing the object file name for that source file,
a colon, and the names of all imported files.

@opindex MM
@item -MM
Like @option{-M} but does not mention imported modules from the D standard
library package directories.

@opindex MF
@item -MF @var{file}
When used with @option{-M} or @option{-MM}, specifies a @var{file} to write
the dependencies to.  When used with the driver options @option{-MD} or
@option{-MMD}, @option{-MF} overrides the default dependency output file.

@opindex MG
@item -MG
This option is for compatibility with @command{gcc}, and is ignored by the
compiler.

@opindex MP
@item -MP
Outputs a phony target for each dependency other than the modules being
compiled, causing each to depend on nothing.

@opindex MT
@item -MT @var{target}
Change the @var{target} of the rule emitted by dependency generation
to be exactly the string you specify.  If you want multiple targets,
you can specify them as a single argument to @option{-MT}, or use
multiple @option{-MT} options.

@opindex MQ
@item -MQ @var{target}
Same as @option{-MT}, but it quotes any characters which are special to
@command{make}.

@opindex MD
@item -MD
This option is equivalent to @option{-M -MF @var{file}}.  The driver
determines @var{file} by removing any directory components and suffix
from the input file, and then adding a @file{.deps} suffix.

@opindex MMD
@item -MMD
Like @option{-MD} but does not mention imported modules from the D standard
library package directories.

@opindex X
@item -X
Output information describing the contents of all source files being
compiled in JSON format to a file.  The driver determines @var{file} by
removing any directory components and suffix from the input file, and then
adding a @file{.json} suffix.

@opindex Xf
@item -Xf @var{file}
Same as @option{-X}, but writes all JSON contents to the specified
@var{file}.

@opindex fdoc
@item -fdoc
Generates @code{Ddoc} documentation and writes it to a file.  The compiler
determines @var{file} by removing any directory components and suffix
from the input file, and then adding a @file{.html} suffix.

@opindex fdoc-dir
@item -fdoc-dir=@var{dir}
Same as @option{-fdoc}, but writes documentation to directory @var{dir}.
This option can be used with @option{-fdoc-file=@var{file}} to
independently set the output file and directory path.

@opindex fdoc-file
@item -fdoc-file=@var{file}
Same as @option{-fdoc}, but writes documentation to @var{file}.  This
option can be used with @option{-fdoc-dir=@var{dir}} to independently
set the output file and directory path.

@opindex fdoc-inc
@item -fdoc-inc=@var{file}
Specify @var{file} as a @var{Ddoc} macro file to be read.  Multiple
@option{-fdoc-inc} options can be used, and files are read and processed
in the same order.

@item -fdump-c++-spec=@var{file}
For D source files, generate corresponding C++ declarations in @var{file}.

@item -fdump-c++-spec-verbose
In conjunction with @option{-fdump-c++-spec=} above, add comments for ignored
declarations in the generated C++ header.

@opindex fsave-mixins
@item -fsave-mixins=@var{file}
Generates code expanded from D @code{mixin} statements and writes the
processed sources to @var{file}.  This is useful to debug errors in compilation
and provides source for debuggers to show when requested.

@end table

@node Warnings
@section Warnings
@cindex options, warnings
@cindex options, errors
@cindex warnings, suppressing
@cindex messages, error
@cindex messages, warning
@cindex suppressing warnings

Warnings are diagnostic messages that report constructions that
are not inherently erroneous but that are risky or suggest there
is likely to be a bug in the program.  Unless @option{-Werror} is
specified, they do not prevent compilation of the program.

@table @gcctabopt

@opindex Wall
@opindex Wno-all
@item -Wall
Turns on all warnings messages.  Warnings are not a defined part of
the D language, and all constructs for which this may generate a
warning message are valid code.

@opindex Walloca
@item -Walloca
This option warns on all uses of "alloca" in the source.

@opindex Walloca-larger-than
@opindex Wno-alloca-larger-than
@item -Walloca-larger-than=@var{n}
Warn on unbounded uses of alloca, and on bounded uses of alloca
whose bound can be larger than @var{n} bytes.
@option{-Wno-alloca-larger-than} disables
@option{-Walloca-larger-than} warning and is equivalent to
@option{-Walloca-larger-than=@var{SIZE_MAX}} or larger.

@opindex Wno-builtin-declaration-mismatch
@opindex Wbuiltin-declaration-mismatch
@item -Wno-builtin-declaration-mismatch
Warn if a built-in function is declared with an incompatible signature.

@opindex Wcast-result
@opindex Wno-cast-result
@item -Wcast-result
Warn about casts that will produce a null or zero result.  Currently
this is only done for casting between an imaginary and non-imaginary
data type, or casting between a D and C++ class.

@opindex Wdeprecated
@opindex Wno-deprecated
@item -Wno-deprecated
Do not warn about usage of deprecated features and symbols with
@code{deprecated} attributes.

@opindex Werror
@opindex Wno-error
@item -Werror
Turns all warnings into errors.

@opindex Wspeculative
@opindex Wno-speculative
@item -Wspeculative
List all error messages from speculative compiles, such as
@code{__traits(compiles, ...)}.  This option does not report
messages as warnings, and these messages therefore never become
errors when the @option{-Werror} option is also used.

@opindex Wunknown-pragmas
@opindex Wno-unknown-pragmas
@item -Wunknown-pragmas
Warn when a @code{pragma()} is encountered that is not understood by
@command{gdc}.  This differs from @option{-fignore-unknown-pragmas}
where a pragma that is part of the D language, but not implemented by
the compiler, won't get reported.

@opindex Wvarargs
@opindex Wno-varargs
@item -Wno-varargs
Do not warn upon questionable usage of the macros used to handle variable
arguments like @code{va_start}.

@opindex fignore-unknown-pragmas
@opindex fno-ignore-unknown-pragmas
@item -fignore-unknown-pragmas
Turns off errors for unsupported pragmas.

@opindex fmax-errors
@item -fmax-errors=@var{n}
Limits the maximum number of error messages to @var{n}, at which point
@command{gdc} bails out rather than attempting to continue processing the
source code.  If @var{n} is 0 (the default), there is no limit on the
number of error messages produced.

@opindex fsyntax-only
@opindex fno-syntax-only
@item -fsyntax-only
Check the code for syntax errors, but do not actually compile it.  This
can be used in conjunction with @option{-fdoc} or @option{-H} to generate
files for each module present on the command-line, but no other output
file.

@opindex ftransition
@item -ftransition=@var{id}
Report additional information about D language changes identified by
@var{id}.  The following values are supported:

@table @samp
@item all
List information on all D language transitions.
@item complex
List all usages of complex or imaginary types.
@item field
List all non-mutable fields which occupy an object instance.
@item in
List all usages of @code{in} on parameter.
@item nogc
List all hidden GC allocations.
@item templates
List statistics on template instantiations.
@item tls
List all variables going into thread local storage.
@end table

@end table

@node Linking
@section Options for Linking
@cindex options, linking
@cindex linking, static

These options come into play when the compiler links object files into an
executable output file.  They are meaningless if the compiler is not doing
a link step.

@table @gcctabopt

@opindex defaultlib=
@item -defaultlib=@var{libname}
Specify the library to use instead of libphobos when linking.  Options
specifying the linkage of libphobos, such as @option{-static-libphobos}
or @option{-shared-libphobos}, are ignored.

@opindex debuglib=
@item -debuglib=@var{libname}
Specify the debug library to use instead of libphobos when linking.
This option has no effect unless the @option{-g} option was also given
on the command line.  Options specifying the linkage of libphobos, such
as @option{-static-libphobos} or @option{-shared-libphobos}, are ignored.

@opindex nophoboslib
@item -nophoboslib
Do not use the Phobos or D runtime library when linking.  Options specifying
the linkage of libphobos, such as @option{-static-libphobos} or
@option{-shared-libphobos}, are ignored.  The standard system libraries are
used normally, unless @option{-nostdlib} or @option{-nodefaultlibs} is used.

@opindex shared-libphobos
@item -shared-libphobos
On systems that provide @file{libgphobos} and @file{libgdruntime} as a
shared and a static library, this option forces the use of the shared
version.  If no shared version was built when the compiler was configured,
this option has no effect.

@opindex static-libphobos
@item -static-libphobos
On systems that provide @file{libgphobos} and @file{libgdruntime} as a
shared and a static library, this option forces the use of the static
version.  If no static version was built when the compiler was configured,
this option has no effect.

@end table

@node Developer Options
@section Developer Options
@cindex developer options
@cindex debug dump options
@cindex dump options

This section describes command-line options that are primarily of
interest to developers or language tooling.

@table @gcctabopt

@opindex fdump-d-original
@item -fdump-d-original
Output the internal front-end AST after the @code{semantic3} stage.
This option is only useful for debugging the GNU D compiler itself.

@opindex v
@item -v
Dump information about the compiler language processing stages as the source
program is being compiled.  This includes listing all modules that are
processed through the @code{parse}, @code{semantic}, @code{semantic2}, and
@code{semantic3} stages; all @code{import} modules and their file paths;
and all @code{function} bodies that are being compiled.

@end table

@c man end

@include implement-d.texi

@include gpl_v3.texi
@include fdl.texi

@node Option Index
@unnumbered Option Index

@command{gdc}'s command line options are indexed here without any initial
@samp{-} or @samp{--}.  Where an option has both positive and negative forms
(such as @option{-f@var{option}} and @option{-fno-@var{option}}), relevant
entries in the manual are indexed under the most appropriate form; it may
sometimes be useful to look up both forms.

@printindex op

@node Keyword Index
@unnumbered Keyword Index

@printindex cp

@bye