@@ -7,8 +7,8 @@ that are not reflected on the command line (such as their default include
7
7
paths, or compiler version macros).
8
8
9
9
If we believe (or already know!) that these behaviors will impact the
10
- divergence calculation for a code base, we can use a configuration file to
11
- instruct CBI to append additional options when emulating certain compilers.
10
+ CBI's analysis of a code base, we can use a configuration file to append
11
+ additional options when emulating certain compilers.
12
12
13
13
.. attention ::
14
14
@@ -76,12 +76,12 @@ but there is not enough information to decide what the value of
76
76
:code: `__GNUC__ ` should be.
77
77
78
78
79
- Defining Behaviors
80
- ------------------
79
+ Defining Implicit Options
80
+ -------------------------
81
81
82
- `` codebasin `` searches for a file called ``.cbi/config ``, and uses the
83
- information found in that file to determine implicit compiler behavior . Each
84
- compiler definition is a TOML `table `_, of the form shown below:
82
+ CBI searches for a file called ``.cbi/config ``, and uses the information found
83
+ in that file to determine implicit compiler options . Each compiler definition
84
+ is a TOML `table `_, of the form shown below:
85
85
86
86
.. _`table` : https://toml.io/en/v1.0.0#table
87
87
@@ -124,3 +124,50 @@ becomes:
124
124
Coverage (%): 100.00
125
125
Avg. Coverage (%): 70.37
126
126
Total SLOC: 27
127
+
128
+
129
+ Parsing Compiler Options
130
+ ------------------------
131
+
132
+ In more complex cases, emulating a compiler's implicit behavior requires CBI to
133
+ parse the command-line arguments passed to the compiler. Such emulation
134
+ requires CBI to understand which options are important and how they impact
135
+ compilation.
136
+
137
+ CBI ships with a number of compiler definitions included (see `here `_), and the
138
+ same syntax can be used to define custom compiler behaviors within the
139
+ ``.cbi/config `` file.
140
+
141
+ .. _`here` : https://github.com/intel/code-base-investigator/tree/main/codebasin/compilers
142
+
143
+ For example, the TOML file below defines behavior for the ``gcc `` and ``g++ `` compilers:
144
+
145
+ .. code-block :: toml
146
+
147
+ [compiler.gcc]
148
+ # This example does not define any implicit options.
149
+
150
+ # g++ inherits all options of gcc.
151
+ [compiler."g++"]
152
+ alias_of = "gcc"
153
+
154
+ # The -fopenmp flag enables a dedicated OpenMP compiler "mode".
155
+ [[compiler.gcc.parser]]
156
+ flags = ["-fopenmp"]
157
+ action = "append_const"
158
+ dest = "modes"
159
+ const = "openmp"
160
+
161
+ # In OpenMP mode, the _OPENMP macro is defined.
162
+ [[compiler.gcc.modes]]
163
+ name = "openmp"
164
+ defines = ["_OPENMP"]
165
+
166
+ This functionality is intended for expert users. In most cases, we expect that
167
+ defining implicit options or relying on CBI's built-in compiler emulation
168
+ support will be sufficient.
169
+
170
+ .. attention ::
171
+
172
+ If you encounter a common case where a custom compiler definition is
173
+ required, please `open an issue `_.
0 commit comments