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
|
.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.if !\nF .nr F 0
.if \nF>0 \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "GDC 1"
.TH GDC 1 "2025-07-11" "gcc-12.5.0" "GNU"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
gdc \- A GCC\-based compiler for the D language
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
gdc [\fB\-c\fR|\fB\-S\fR] [\fB\-g\fR] [\fB\-pg\fR]
[\fB\-O\fR\fIlevel\fR] [\fB\-W\fR\fIwarn\fR...]
[\fB\-I\fR\fIdir\fR...] [\fB\-L\fR\fIdir\fR...]
[\fB\-f\fR\fIoption\fR...] [\fB\-m\fR\fImachine-option\fR...]
[\fB\-o\fR \fIoutfile\fR] [@\fIfile\fR] \fIinfile\fR...
.PP
Only the most useful options are listed here; see below for the
remainder.
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
The \fBgdc\fR command is the \s-1GNU\s0 compiler for the D language and
supports many of the same options as \fBgcc\fR.
This manual only documents the options specific to \fBgdc\fR.
.SH "OPTIONS"
.IX Header "OPTIONS"
.SS "Input and Output files"
.IX Subsection "Input and Output files"
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:
.IP "\fIfile\fR\fB.d\fR" 4
.IX Item "file.d"
D source files.
.IP "\fIfile\fR\fB.dd\fR" 4
.IX Item "file.dd"
Ddoc source files.
.IP "\fIfile\fR\fB.di\fR" 4
.IX Item "file.di"
D interface files.
.PP
You can specify more than one input file on the \fBgdc\fR command line,
each being compiled separately in the compilation process. If you specify a
\&\f(CW\*(C`\-o \f(CIfile\f(CW\*(C'\fR option, all the input files are compiled together,
producing a single output file, named \fIfile\fR. This is allowed even
when using \f(CW\*(C`\-S\*(C'\fR or \f(CW\*(C`\-c\*(C'\fR.
.PP
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 \fBgdc\fR from a D source file by using the \f(CW\*(C`\-H\*(C'\fR option.
When the compiler resolves an import declaration, it searches for matching
\&\fI.di\fR files first, then for \fI.d\fR.
.PP
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 \s-1HTML\s0 generation. If a \fI.d\fR
source file starts with the string \f(CW\*(C`Ddoc\*(C'\fR then it is treated as general
purpose documentation, not as a D source file.
.SS "Runtime Options"
.IX Subsection "Runtime Options"
These options affect the runtime behavior of programs compiled with
\&\fBgdc\fR.
.IP "\fB\-fall\-instantiations\fR" 4
.IX 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 \f(CW\*(C`_\|_traits(compiles, ...)\*(C'\fR, or
that come from an imported module not being compiled.
.IP "\fB\-fno\-assert\fR" 4
.IX Item "-fno-assert"
Turn off code generation for \f(CW\*(C`assert\*(C'\fR contracts.
.IP "\fB\-fno\-bounds\-check\fR" 4
.IX 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 \f(CW\*(C`RangeError\*(C'\fR.
.IP "\fB\-fbounds\-check=\fR\fIvalue\fR" 4
.IX Item "-fbounds-check=value"
An alternative to \fB\-fbounds\-check\fR that allows more control
as to where bounds checking is turned on or off. The following values
are supported:
.RS 4
.IP "\fBon\fR" 4
.IX Item "on"
Turns on array bounds checking for all functions.
.IP "\fBsafeonly\fR" 4
.IX Item "safeonly"
Turns on array bounds checking only for \f(CW@safe\fR functions.
.IP "\fBoff\fR" 4
.IX Item "off"
Turns off array bounds checking completely.
.RE
.RS 4
.RE
.IP "\fB\-fno\-builtin\fR" 4
.IX Item "-fno-builtin"
Don't recognize built-in functions unless they begin with the prefix
\&\fB_\|_builtin_\fR. By default, the compiler will recognize when a
function in the \f(CW\*(C`core.stdc\*(C'\fR package is a built-in function.
.IP "\fB\-fcheckaction=\fR\fIvalue\fR" 4
.IX Item "-fcheckaction=value"
This option controls what code is generated on an assertion, bounds check, or
final switch failure. The following values are supported:
.RS 4
.IP "\fBcontext\fR" 4
.IX Item "context"
Throw an \f(CW\*(C`AssertError\*(C'\fR with extra context information.
.IP "\fBhalt\fR" 4
.IX Item "halt"
Halt the program execution.
.IP "\fBthrow\fR" 4
.IX Item "throw"
Throw an \f(CW\*(C`AssertError\*(C'\fR (the default).
.RE
.RS 4
.RE
.IP "\fB\-fdebug\fR" 4
.IX Item "-fdebug"
.PD 0
.IP "\fB\-fdebug=\fR\fIvalue\fR" 4
.IX Item "-fdebug=value"
.PD
Turn on compilation of conditional \f(CW\*(C`debug\*(C'\fR code into the program.
The \fB\-fdebug\fR option itself sets the debug level to \f(CW1\fR,
while \fB\-fdebug=\fR enables \f(CW\*(C`debug\*(C'\fR code that are identified
by any of the following values:
.RS 4
.IP "\fBlevel\fR" 4
.IX Item "level"
Sets the debug level to \fIlevel\fR, any \f(CW\*(C`debug\*(C'\fR code <= \fIlevel\fR
is compiled into the program.
.IP "\fBident\fR" 4
.IX Item "ident"
Turns on compilation of any \f(CW\*(C`debug\*(C'\fR code identified by \fIident\fR.
.RE
.RS 4
.RE
.IP "\fB\-fno\-druntime\fR" 4
.IX Item "-fno-druntime"
Implements <\fBhttps://dlang.org/spec/betterc.html\fR>. Assumes that
compilation targets an environment without a D runtime library.
.Sp
This is equivalent to compiling with the following options:
.Sp
.Vb 1
\& gdc \-nophoboslib \-fno\-exceptions \-fno\-moduleinfo \-fno\-rtti
.Ve
.IP "\fB\-fextern\-std=\fR\fIstandard\fR" 4
.IX Item "-fextern-std=standard"
Sets the \*(C+ name mangling compatibility to the version identified by
\&\fIstandard\fR. The following values are supported:
.RS 4
.IP "\fBc++98\fR" 4
.IX Item "c++98"
.PD 0
.IP "\fBc++03\fR" 4
.IX Item "c++03"
.PD
Sets \f(CW\*(C`_\|_traits(getTargetInfo, "cppStd")\*(C'\fR to \f(CW199711\fR.
.IP "\fBc++11\fR" 4
.IX Item "c++11"
Sets \f(CW\*(C`_\|_traits(getTargetInfo, "cppStd")\*(C'\fR to \f(CW201103\fR.
.IP "\fBc++14\fR" 4
.IX Item "c++14"
Sets \f(CW\*(C`_\|_traits(getTargetInfo, "cppStd")\*(C'\fR to \f(CW201402\fR.
.IP "\fBc++17\fR" 4
.IX Item "c++17"
Sets \f(CW\*(C`_\|_traits(getTargetInfo, "cppStd")\*(C'\fR to \f(CW201703\fR.
This is the default.
.IP "\fBc++20\fR" 4
.IX Item "c++20"
Sets \f(CW\*(C`_\|_traits(getTargetInfo, "cppStd")\*(C'\fR to \f(CW202002\fR.
.RE
.RS 4
.RE
.IP "\fB\-fno\-invariants\fR" 4
.IX Item "-fno-invariants"
Turns off code generation for class \f(CW\*(C`invariant\*(C'\fR contracts.
.IP "\fB\-fmain\fR" 4
.IX Item "-fmain"
Generates a default \f(CW\*(C`main()\*(C'\fR 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 \f(CW\*(C`main\*(C'\fR is already defined in user code.
.IP "\fB\-fno\-moduleinfo\fR" 4
.IX Item "-fno-moduleinfo"
Turns off generation of the \f(CW\*(C`ModuleInfo\*(C'\fR 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 (\f(CW\*(C`static this\*(C'\fR and
\&\f(CW\*(C`static ~this\*(C'\fR), \f(CW\*(C`unittest\*(C'\fR code, and \f(CW\*(C`DSO\*(C'\fR registry
functions for dynamically linked code.
.IP "\fB\-fonly=\fR\fIfilename\fR" 4
.IX Item "-fonly=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 \fIfilename\fR.
.IP "\fB\-fno\-postconditions\fR" 4
.IX Item "-fno-postconditions"
Turns off code generation for postcondition \f(CW\*(C`out\*(C'\fR contracts.
.IP "\fB\-fno\-preconditions\fR" 4
.IX Item "-fno-preconditions"
Turns off code generation for precondition \f(CW\*(C`in\*(C'\fR contracts.
.IP "\fB\-fpreview=\fR\fIid\fR" 4
.IX Item "-fpreview=id"
Turns on an upcoming D language change identified by \fIid\fR. The following
values are supported:
.RS 4
.IP "\fBall\fR" 4
.IX Item "all"
Turns on all upcoming D language features.
.IP "\fBdip1000\fR" 4
.IX Item "dip1000"
Implements <\fBhttps://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1000.md\fR>
(Scoped pointers).
.IP "\fBdip1008\fR" 4
.IX Item "dip1008"
Implements <\fBhttps://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1008.md\fR>
(Allow exceptions in \f(CW@nogc\fR code).
.IP "\fBdip1021\fR" 4
.IX Item "dip1021"
Implements <\fBhttps://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1021.md\fR>
(Mutable function arguments).
.IP "\fBdip25\fR" 4
.IX Item "dip25"
Implements <\fBhttps://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP25.md\fR>
(Sealed references).
.IP "\fBdtorfields\fR" 4
.IX Item "dtorfields"
Turns on generation for destructing fields of partially constructed objects.
.IP "\fBfieldwise\fR" 4
.IX Item "fieldwise"
Turns on generation of struct equality to use field-wise comparisons.
.IP "\fBfixaliasthis\fR" 4
.IX Item "fixaliasthis"
Implements new lookup rules that check the current scope for \f(CW\*(C`alias this\*(C'\fR
before searching in upper scopes.
.IP "\fBin\fR" 4
.IX Item "in"
Implements \f(CW\*(C`in\*(C'\fR parameters to mean \f(CW\*(C`scope const [ref]\*(C'\fR and accepts
rvalues.
.IP "\fBinclusiveincontracts\fR" 4
.IX Item "inclusiveincontracts"
Implements \f(CW\*(C`in\*(C'\fR contracts of overridden methods to be a superset of parent
contract.
.IP "\fBintpromote\fR" 4
.IX Item "intpromote"
Implements C\-style integral promotion for unary \f(CW\*(C`+\*(C'\fR, \f(CW\*(C`\-\*(C'\fR and \f(CW\*(C`~\*(C'\fR
expressions.
.IP "\fBnosharedaccess\fR" 4
.IX Item "nosharedaccess"
Turns off and disallows all access to shared memory objects.
.IP "\fBrvaluerefparam\fR" 4
.IX Item "rvaluerefparam"
Implements rvalue arguments to \f(CW\*(C`ref\*(C'\fR parameters.
.IP "\fBshortenedmethods\fR" 4
.IX Item "shortenedmethods"
Implements use of \f(CW\*(C`=>\*(C'\fR for methods and top-level functions in addition to
lambdas.
.RE
.RS 4
.RE
.IP "\fB\-frelease\fR" 4
.IX 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 \f(CW@system\fR and \f(CW@trusted\fR functions, and assertion
failures are undefined behavior.
.Sp
This is equivalent to compiling with the following options:
.Sp
.Vb 2
\& gdc \-fno\-assert \-fbounds\-check=safe \-fno\-invariants \e
\& \-fno\-postconditions \-fno\-preconditions \-fno\-switch\-errors
.Ve
.IP "\fB\-frevert=\fR" 4
.IX Item "-frevert="
Turns off a D language feature identified by \fIid\fR. The following values
are supported:
.RS 4
.IP "\fBall\fR" 4
.IX Item "all"
Turns off all revertable D language features.
.IP "\fBdip25\fR" 4
.IX Item "dip25"
Reverts <\fBhttps://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP25.md\fR>
(Sealed references).
.IP "\fBdtorfields\fR" 4
.IX Item "dtorfields"
Turns off generation for destructing fields of partially constructed objects.
.IP "\fBmarkdown\fR" 4
.IX Item "markdown"
Turns off Markdown replacements in Ddoc comments.
.RE
.RS 4
.RE
.IP "\fB\-fno\-rtti\fR" 4
.IX 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.
.IP "\fB\-fno\-switch\-errors\fR" 4
.IX Item "-fno-switch-errors"
This option controls what code is generated when no case is matched
in a \f(CW\*(C`final switch\*(C'\fR statement. The default run time behavior
is to throw a \f(CW\*(C`SwitchError\*(C'\fR. Turning off \fB\-fswitch\-errors\fR
means that instead the execution of the program is immediately halted.
.IP "\fB\-funittest\fR" 4
.IX Item "-funittest"
Turns on compilation of \f(CW\*(C`unittest\*(C'\fR code, and turns on the
\&\f(CW\*(C`version(unittest)\*(C'\fR identifier. This implies \fB\-fassert\fR.
.IP "\fB\-fversion=\fR\fIvalue\fR" 4
.IX Item "-fversion=value"
Turns on compilation of conditional \f(CW\*(C`version\*(C'\fR code into the program
identified by any of the following values:
.RS 4
.IP "\fBlevel\fR" 4
.IX Item "level"
Sets the version level to \fIlevel\fR, any \f(CW\*(C`version\*(C'\fR code >= \fIlevel\fR
is compiled into the program.
.IP "\fBident\fR" 4
.IX Item "ident"
Turns on compilation of \f(CW\*(C`version\*(C'\fR code identified by \fIident\fR.
.RE
.RS 4
.RE
.IP "\fB\-fno\-weak\-templates\fR" 4
.IX 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 \s-1COMDAT\s0 or become private.
.SS "Options for Directory Search"
.IX Subsection "Options for Directory Search"
These options specify directories to search for files, libraries, and
other parts of the compiler:
.IP "\fB\-I\fR\fIdir\fR" 4
.IX Item "-Idir"
Specify a directory to use when searching for imported modules at
compile time. Multiple \fB\-I\fR options can be used, and the
paths are searched in the same order.
.IP "\fB\-J\fR\fIdir\fR" 4
.IX Item "-Jdir"
Specify a directory to use when searching for files in string imports
at compile time. This switch is required in order to use
\&\f(CW\*(C`import(file)\*(C'\fR expressions. Multiple \fB\-J\fR options can be
used, and the paths are searched in the same order.
.IP "\fB\-L\fR\fIdir\fR" 4
.IX Item "-Ldir"
When linking, specify a library search directory, as with \fBgcc\fR.
.IP "\fB\-B\fR\fIdir\fR" 4
.IX Item "-Bdir"
This option specifies where to find the executables, libraries,
source files, and data files of the compiler itself, as with \fBgcc\fR.
.IP "\fB\-fmodule\-file=\fR\fImodule\fR\fB=\fR\fIspec\fR" 4
.IX Item "-fmodule-file=module=spec"
This option manipulates file paths of imported modules, such that if an
imported module matches all or the leftmost part of \fImodule\fR, the file
path in \fIspec\fR 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:
.Sp
.Vb 1
\& gdc test.d \-fmodule\-file=A.B=foo.d \-fmodule\-file=C=bar
.Ve
.Sp
This will tell the compiler to search in all import paths for the source
file \fIfoo.d\fR when importing \fIA.B\fR, and the directory \fIbar/\fR
when importing \fIC\fR, as annotated in the following D code:
.Sp
.Vb 4
\& 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
.Ve
.IP "\fB\-imultilib\fR \fIdir\fR" 4
.IX Item "-imultilib dir"
Use \fIdir\fR as a subdirectory of the gcc directory containing
target-specific D sources and interfaces.
.IP "\fB\-iprefix\fR \fIprefix\fR" 4
.IX Item "-iprefix prefix"
Specify \fIprefix\fR as the prefix for the gcc directory containing
target-specific D sources and interfaces. If the \fIprefix\fR represents
a directory, you should include the final \f(CW\*(Aq/\*(Aq\fR.
.IP "\fB\-nostdinc\fR" 4
.IX Item "-nostdinc"
Do not search the standard system directories for D source and interface
files. Only the directories that have been specified with \fB\-I\fR options
(and the directory of the current file, if appropriate) are searched.
.SS "Code Generation"
.IX Subsection "Code Generation"
In addition to the many \fBgcc\fR options controlling code generation,
\&\fBgdc\fR has several options specific to itself.
.IP "\fB\-H\fR" 4
.IX 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 \fI.di\fR suffix.
.IP "\fB\-Hd\fR \fIdir\fR" 4
.IX Item "-Hd dir"
Same as \fB\-H\fR, but writes interface files to directory \fIdir\fR.
This option can be used with \fB\-Hf\fR \fIfile\fR to independently set the
output file and directory path.
.IP "\fB\-Hf\fR \fIfile\fR" 4
.IX Item "-Hf file"
Same as \fB\-H\fR but writes interface files to \fIfile\fR. This option can
be used with \fB\-Hd\fR \fIdir\fR to independently set the output file and
directory path.
.IP "\fB\-M\fR" 4
.IX Item "-M"
Output the module dependencies of all source files being compiled in a
format suitable for \fBmake\fR. The compiler outputs one
\&\fBmake\fR rule containing the object file name for that source file,
a colon, and the names of all imported files.
.IP "\fB\-MM\fR" 4
.IX Item "-MM"
Like \fB\-M\fR but does not mention imported modules from the D standard
library package directories.
.IP "\fB\-MF\fR \fIfile\fR" 4
.IX Item "-MF file"
When used with \fB\-M\fR or \fB\-MM\fR, specifies a \fIfile\fR to write
the dependencies to. When used with the driver options \fB\-MD\fR or
\&\fB\-MMD\fR, \fB\-MF\fR overrides the default dependency output file.
.IP "\fB\-MG\fR" 4
.IX Item "-MG"
This option is for compatibility with \fBgcc\fR, and is ignored by the
compiler.
.IP "\fB\-MP\fR" 4
.IX Item "-MP"
Outputs a phony target for each dependency other than the modules being
compiled, causing each to depend on nothing.
.IP "\fB\-MT\fR \fItarget\fR" 4
.IX Item "-MT target"
Change the \fItarget\fR 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 \fB\-MT\fR, or use
multiple \fB\-MT\fR options.
.IP "\fB\-MQ\fR \fItarget\fR" 4
.IX Item "-MQ target"
Same as \fB\-MT\fR, but it quotes any characters which are special to
\&\fBmake\fR.
.IP "\fB\-MD\fR" 4
.IX Item "-MD"
This option is equivalent to \fB\-M \-MF\fR \fIfile\fR. The driver
determines \fIfile\fR by removing any directory components and suffix
from the input file, and then adding a \fI.deps\fR suffix.
.IP "\fB\-MMD\fR" 4
.IX Item "-MMD"
Like \fB\-MD\fR but does not mention imported modules from the D standard
library package directories.
.IP "\fB\-X\fR" 4
.IX Item "-X"
Output information describing the contents of all source files being
compiled in \s-1JSON\s0 format to a file. The driver determines \fIfile\fR by
removing any directory components and suffix from the input file, and then
adding a \fI.json\fR suffix.
.IP "\fB\-Xf\fR \fIfile\fR" 4
.IX Item "-Xf file"
Same as \fB\-X\fR, but writes all \s-1JSON\s0 contents to the specified
\&\fIfile\fR.
.IP "\fB\-fdoc\fR" 4
.IX Item "-fdoc"
Generates \f(CW\*(C`Ddoc\*(C'\fR documentation and writes it to a file. The compiler
determines \fIfile\fR by removing any directory components and suffix
from the input file, and then adding a \fI.html\fR suffix.
.IP "\fB\-fdoc\-dir=\fR\fIdir\fR" 4
.IX Item "-fdoc-dir=dir"
Same as \fB\-fdoc\fR, but writes documentation to directory \fIdir\fR.
This option can be used with \fB\-fdoc\-file=\fR\fIfile\fR to
independently set the output file and directory path.
.IP "\fB\-fdoc\-file=\fR\fIfile\fR" 4
.IX Item "-fdoc-file=file"
Same as \fB\-fdoc\fR, but writes documentation to \fIfile\fR. This
option can be used with \fB\-fdoc\-dir=\fR\fIdir\fR to independently
set the output file and directory path.
.IP "\fB\-fdoc\-inc=\fR\fIfile\fR" 4
.IX Item "-fdoc-inc=file"
Specify \fIfile\fR as a \fIDdoc\fR macro file to be read. Multiple
\&\fB\-fdoc\-inc\fR options can be used, and files are read and processed
in the same order.
.IP "\fB\-fdump\-c++\-spec=\fR\fIfile\fR" 4
.IX Item "-fdump-c++-spec=file"
For D source files, generate corresponding \*(C+ declarations in \fIfile\fR.
.IP "\fB\-fdump\-c++\-spec\-verbose\fR" 4
.IX Item "-fdump-c++-spec-verbose"
In conjunction with \fB\-fdump\-c++\-spec=\fR above, add comments for ignored
declarations in the generated \*(C+ header.
.IP "\fB\-fsave\-mixins=\fR\fIfile\fR" 4
.IX Item "-fsave-mixins=file"
Generates code expanded from D \f(CW\*(C`mixin\*(C'\fR statements and writes the
processed sources to \fIfile\fR. This is useful to debug errors in compilation
and provides source for debuggers to show when requested.
.SS "Warnings"
.IX Subsection "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 \fB\-Werror\fR is
specified, they do not prevent compilation of the program.
.IP "\fB\-Wall\fR" 4
.IX 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.
.IP "\fB\-Walloca\fR" 4
.IX Item "-Walloca"
This option warns on all uses of \*(L"alloca\*(R" in the source.
.IP "\fB\-Walloca\-larger\-than=\fR\fIn\fR" 4
.IX Item "-Walloca-larger-than=n"
Warn on unbounded uses of alloca, and on bounded uses of alloca
whose bound can be larger than \fIn\fR bytes.
\&\fB\-Wno\-alloca\-larger\-than\fR disables
\&\fB\-Walloca\-larger\-than\fR warning and is equivalent to
\&\fB\-Walloca\-larger\-than=\fR\fI\s-1SIZE_MAX\s0\fR or larger.
.IP "\fB\-Wcast\-result\fR" 4
.IX 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.
.IP "\fB\-Wno\-deprecated\fR" 4
.IX Item "-Wno-deprecated"
Do not warn about usage of deprecated features and symbols with
\&\f(CW\*(C`deprecated\*(C'\fR attributes.
.IP "\fB\-Werror\fR" 4
.IX Item "-Werror"
Turns all warnings into errors.
.IP "\fB\-Wspeculative\fR" 4
.IX Item "-Wspeculative"
List all error messages from speculative compiles, such as
\&\f(CW\*(C`_\|_traits(compiles, ...)\*(C'\fR. This option does not report
messages as warnings, and these messages therefore never become
errors when the \fB\-Werror\fR option is also used.
.IP "\fB\-Wtemplates\fR" 4
.IX Item "-Wtemplates"
Warn when a template instantiation is encountered. Some coding
rules disallow templates, and this may be used to enforce that rule.
.IP "\fB\-Wunknown\-pragmas\fR" 4
.IX Item "-Wunknown-pragmas"
Warn when a \f(CW\*(C`pragma()\*(C'\fR is encountered that is not understood by
\&\fBgdc\fR. This differs from \fB\-fignore\-unknown\-pragmas\fR
where a pragma that is part of the D language, but not implemented by
the compiler, won't get reported.
.IP "\fB\-Wno\-varargs\fR" 4
.IX Item "-Wno-varargs"
Do not warn upon questionable usage of the macros used to handle variable
arguments like \f(CW\*(C`va_start\*(C'\fR.
.IP "\fB\-fignore\-unknown\-pragmas\fR" 4
.IX Item "-fignore-unknown-pragmas"
Turns off errors for unsupported pragmas.
.IP "\fB\-fmax\-errors=\fR\fIn\fR" 4
.IX Item "-fmax-errors=n"
Limits the maximum number of error messages to \fIn\fR, at which point
\&\fBgdc\fR bails out rather than attempting to continue processing the
source code. If \fIn\fR is 0 (the default), there is no limit on the
number of error messages produced.
.IP "\fB\-fsyntax\-only\fR" 4
.IX Item "-fsyntax-only"
Check the code for syntax errors, but do not actually compile it. This
can be used in conjunction with \fB\-fdoc\fR or \fB\-H\fR to generate
files for each module present on the command-line, but no other output
file.
.IP "\fB\-ftransition=\fR\fIid\fR" 4
.IX Item "-ftransition=id"
Report additional information about D language changes identified by
\&\fIid\fR. The following values are supported:
.RS 4
.IP "\fBall\fR" 4
.IX Item "all"
List information on all D language transitions.
.IP "\fBcomplex\fR" 4
.IX Item "complex"
List all usages of complex or imaginary types.
.IP "\fBfield\fR" 4
.IX Item "field"
List all non-mutable fields which occupy an object instance.
.IP "\fBin\fR" 4
.IX Item "in"
List all usages of \f(CW\*(C`in\*(C'\fR on parameter.
.IP "\fBnogc\fR" 4
.IX Item "nogc"
List all hidden \s-1GC\s0 allocations.
.IP "\fBtemplates\fR" 4
.IX Item "templates"
List statistics on template instantiations.
.IP "\fBtls\fR" 4
.IX Item "tls"
List all variables going into thread local storage.
.IP "\fBvmarkdown\fR" 4
.IX Item "vmarkdown"
List instances of Markdown replacements in Ddoc.
.RE
.RS 4
.RE
.SS "Options for Linking"
.IX Subsection "Options for Linking"
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.
.IP "\fB\-defaultlib=\fR\fIlibname\fR" 4
.IX Item "-defaultlib=libname"
Specify the library to use instead of libphobos when linking. Options
specifying the linkage of libphobos, such as \fB\-static\-libphobos\fR
or \fB\-shared\-libphobos\fR, are ignored.
.IP "\fB\-debuglib=\fR\fIlibname\fR" 4
.IX Item "-debuglib=libname"
Specify the debug library to use instead of libphobos when linking.
This option has no effect unless the \fB\-g\fR option was also given
on the command line. Options specifying the linkage of libphobos, such
as \fB\-static\-libphobos\fR or \fB\-shared\-libphobos\fR, are ignored.
.IP "\fB\-nophoboslib\fR" 4
.IX Item "-nophoboslib"
Do not use the Phobos or D runtime library when linking. Options specifying
the linkage of libphobos, such as \fB\-static\-libphobos\fR or
\&\fB\-shared\-libphobos\fR, are ignored. The standard system libraries are
used normally, unless \fB\-nostdlib\fR or \fB\-nodefaultlibs\fR is used.
.IP "\fB\-shared\-libphobos\fR" 4
.IX Item "-shared-libphobos"
On systems that provide \fIlibgphobos\fR and \fIlibgdruntime\fR 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.
.IP "\fB\-static\-libphobos\fR" 4
.IX Item "-static-libphobos"
On systems that provide \fIlibgphobos\fR and \fIlibgdruntime\fR 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.
.SS "Developer Options"
.IX Subsection "Developer Options"
This section describes command-line options that are primarily of
interest to developers or language tooling.
.IP "\fB\-fdump\-d\-original\fR" 4
.IX Item "-fdump-d-original"
Output the internal front-end \s-1AST\s0 after the \f(CW\*(C`semantic3\*(C'\fR stage.
This option is only useful for debugging the \s-1GNU D\s0 compiler itself.
.IP "\fB\-v\fR" 4
.IX 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 \f(CW\*(C`parse\*(C'\fR, \f(CW\*(C`semantic\*(C'\fR, \f(CW\*(C`semantic2\*(C'\fR, and
\&\f(CW\*(C`semantic3\*(C'\fR stages; all \f(CW\*(C`import\*(C'\fR modules and their file paths;
and all \f(CW\*(C`function\*(C'\fR bodies that are being compiled.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fIgpl\fR\|(7), \fIgfdl\fR\|(7), \fIfsf\-funding\fR\|(7), \fIgcc\fR\|(1)
and the Info entries for \fIgdc\fR and \fIgcc\fR.
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
Copyright (c) 2006\-2022 Free Software Foundation, Inc.
.PP
Permission is granted to copy, distribute and/or modify this document
under the terms of the \s-1GNU\s0 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
man page \fIgfdl\fR\|(7).
|