Skip to content

Commit 1e4516b

Browse files
committed
Add documentation for Multilib custom flags
1 parent 1209946 commit 1e4516b

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

clang/docs/Multilib.rst

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,78 @@ subclass and a suitable base multilib variant is present then the
122122
It is the responsibility of layered multilib authors to ensure that headers and
123123
libraries in each layer are complete enough to mask any incompatibilities.
124124

125+
Multilib custom flags
126+
=====================
127+
128+
Introduction
129+
------------
130+
131+
The multilib mechanism supports library variants that correspond to target,
132+
code generation or language command-line flags. Examples include ``--target``,
133+
``-mcpu``, ``-mfpu``, ``-mbranch-protection``, ``-fno-rtti``. However, some library
134+
variants are particular to features that do not correspond to any command-line
135+
option. Multithreading and semihosting, for instance, have no associated
136+
compiler option.
137+
138+
In order to support the selection of variants for which no compiler option
139+
exists, the multilib specification includes the concept of *custom flags*.
140+
These flags have no impact on code generation and are only used in the multilib
141+
processing.
142+
143+
Multilib custom flags follow this format in the driver invocation:
144+
145+
::
146+
147+
-fmultilib-flag=<value>
148+
149+
They are fed into the multilib system alongside the remaining flags.
150+
151+
Custom flag declarations
152+
------------------------
153+
154+
Custom flags can be declared in the YAML file under the *Flags* section.
155+
156+
.. code-block:: yaml
157+
158+
Flags:
159+
- Name: multithreaded
160+
Values:
161+
- Name: no-multithreaded
162+
DriverArgs: [-D__SINGLE_THREAD__]
163+
- Name: multithreaded
164+
Default: no-multithreaded
165+
166+
* Name: the name to categorize a flag.
167+
* Values: a list of flag *Value*s (defined below).
168+
* Default: it specifies the name of the value this flag should take if not
169+
specified in the command-line invocation. It must be one value from the Values
170+
field.
171+
172+
A Default value is useful to save users from specifying custom flags that have a
173+
most commonly used value.
174+
175+
Each flag *Value* is defined as:
176+
177+
* Name: name of the value. This is the string to be used in
178+
``-fmultilib-flag=<string>``.
179+
* DriverArgs: a list of strings corresponding to the extra driver arguments
180+
used to build a library variant that's in accordance to this specific custom
181+
flag value. These arguments are fed back into the driver if this flag *Value*
182+
is enabled.
183+
184+
The namespace of flag values is common across all flags. This means that flag
185+
value names must be unique.
186+
187+
Usage of custom flags in the *Variants* specifications
188+
------------------------------------------------------
189+
190+
Library variants should list their requirement on one or more custom flags like
191+
they do for any other flag. Each requirement must be listed as
192+
``-fmultilib-flag=<value>``.
193+
194+
A variant that does not specify a requirement on one particular flag can be
195+
matched against any value of that flag.
196+
125197
Stability
126198
=========
127199

@@ -222,6 +294,24 @@ For a more comprehensive example see
222294
# Flags is a list of one or more strings.
223295
Flags: [--target=thumbv7m-none-eabi]
224296
297+
# Custom flag declarations. Each item is a different declaration.
298+
Flags:
299+
# Name of the flag
300+
- Name: multithreaded
301+
# List of custom flag values
302+
Values:
303+
# Name of the custom flag value. To be used in -fmultilib-flag=<string>.
304+
- Name: no-multithreaded
305+
# Extra driver arguments to be printed with -print-multi-lib. Useful for
306+
# specifying extra arguments for building the the associated library
307+
# variant(s).
308+
DriverArgs: [-D__SINGLE_THREAD__]
309+
- Name: multithreaded
310+
# Default flag value. If no value for this flag declaration is used in the
311+
# command-line, the multilib system will use this one. Must be equal to one
312+
# of the flag value names from this flag declaration.
313+
Default: no-multithreaded
314+
225315
Design principles
226316
=================
227317

0 commit comments

Comments
 (0)