]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/d/doc/invoking-gdc/code-generation.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / d / doc / invoking-gdc / code-generation.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. index:: options, code generation
7
8 .. _code-generation:
9
10 Code Generation
11 ***************
12
13 In addition to the many :command:`gcc` options controlling code generation,
14 :command:`gdc` has several options specific to itself.
15
16 .. option:: -H
17
18 .. index:: -H
19
20 Generates D interface files for all modules being compiled. The compiler
21 determines the output file based on the name of the input file, removes
22 any directory components and suffix, and applies the :samp:`.di` suffix.
23
24 .. option:: -Hd dir
25
26 .. index:: -Hd
27
28 Same as :option:`-H`, but writes interface files to directory :samp:`{dir}`.
29 This option can be used with :option:`-Hf file` to independently set the
30 output file and directory path.
31
32 .. option:: -Hf file
33
34 .. index:: -Hf
35
36 Same as :option:`-H` but writes interface files to :samp:`{file}`. This option can
37 be used with :option:`-Hd dir` to independently set the output file and
38 directory path.
39
40 .. option:: -M
41
42 .. index:: -M
43
44 Output the module dependencies of all source files being compiled in a
45 format suitable for :command:`make`. The compiler outputs one
46 :command:`make` rule containing the object file name for that source file,
47 a colon, and the names of all imported files.
48
49 .. option:: -MM
50
51 .. index:: -MM
52
53 Like :option:`-M` but does not mention imported modules from the D standard
54 library package directories.
55
56 .. option:: -MF file
57
58 .. index:: -MF
59
60 When used with :option:`-M` or :option:`-MM`, specifies a :samp:`{file}` to write
61 the dependencies to. When used with the driver options :option:`-MD` or
62 :option:`-MMD`, :option:`-MF` overrides the default dependency output file.
63
64 .. option:: -MG
65
66 .. index:: -MG
67
68 This option is for compatibility with :command:`gcc`, and is ignored by the
69 compiler.
70
71 .. option:: -MP
72
73 .. index:: -MP
74
75 Outputs a phony target for each dependency other than the modules being
76 compiled, causing each to depend on nothing.
77
78 .. option:: -MT target
79
80 .. index:: -MT
81
82 Change the :samp:`{target}` of the rule emitted by dependency generation
83 to be exactly the string you specify. If you want multiple targets,
84 you can specify them as a single argument to :option:`-MT`, or use
85 multiple :option:`-MT` options.
86
87 .. option:: -MQ target
88
89 .. index:: -MQ
90
91 Same as :option:`-MT`, but it quotes any characters which are special to
92 :command:`make`.
93
94 .. option:: -MD
95
96 .. index:: -MD
97
98 This option is equivalent to :option:`-M -MF file`. The driver
99 determines :samp:`{file}` by removing any directory components and suffix
100 from the input file, and then adding a :samp:`.deps` suffix.
101
102 .. option:: -MMD
103
104 .. index:: -MMD
105
106 Like :option:`-MD` but does not mention imported modules from the D standard
107 library package directories.
108
109 .. option:: -X
110
111 .. index:: -X
112
113 Output information describing the contents of all source files being
114 compiled in JSON format to a file. The driver determines :samp:`{file}` by
115 removing any directory components and suffix from the input file, and then
116 adding a :samp:`.json` suffix.
117
118 .. option:: -Xf file
119
120 .. index:: -Xf
121
122 Same as :option:`-X`, but writes all JSON contents to the specified
123 :samp:`{file}`.
124
125 .. option:: -fdoc
126
127 .. index:: -fdoc
128
129 Generates ``Ddoc`` documentation and writes it to a file. The compiler
130 determines :samp:`{file}` by removing any directory components and suffix
131 from the input file, and then adding a :samp:`.html` suffix.
132
133 .. option:: -fdoc-dir=dir
134
135 .. index:: -fdoc-dir
136
137 Same as :option:`-fdoc`, but writes documentation to directory :samp:`{dir}`.
138 This option can be used with :option:`-fdoc-file=file` to
139 independently set the output file and directory path.
140
141 .. option:: -fdoc-file=file
142
143 .. index:: -fdoc-file
144
145 Same as :option:`-fdoc`, but writes documentation to :samp:`{file}`. This
146 option can be used with :option:`-fdoc-dir=dir` to independently
147 set the output file and directory path.
148
149 .. option:: -fdoc-inc=file
150
151 .. index:: -fdoc-inc
152
153 Specify :samp:`{file}` as a :samp:`{Ddoc}` macro file to be read. Multiple
154 :option:`-fdoc-inc` options can be used, and files are read and processed
155 in the same order.
156
157 .. option:: -fdump-c++-spec={file}
158
159 For D source files, generate corresponding C++ declarations in :samp:`{file}`.
160
161 .. option:: -fdump-c++-spec-verbose
162
163 In conjunction with :option:`-fdump-c++-spec=` above, add comments for ignored
164 declarations in the generated C++ header.
165
166 .. option:: -fsave-mixins={file}
167
168 Generates code expanded from D ``mixin`` statements and writes the
169 processed sources to :samp:`{file}`. This is useful to debug errors in compilation
170 and provides source for debuggers to show when requested.