Skip to content

Commit 226a9d7

Browse files
authored
Add documentation for Multilib custom flags (#114998)
This patch is the fourth step to extend the current multilib system to support the selection of library variants which do not correspond to existing command-line options. Proposal can be found in https://discourse.llvm.org/t/rfc-multilib-custom-flags/81058 The multilib mechanism supports libraries that target code generation or language options such as --target, -mcpu, -mfpu, -mbranch-protection. However, some library variants are particular to features that do not correspond to any command-line options. Examples include variants for multithreading and semihosting. This work introduces a way to instruct the multilib system to consider these features in library selection. This particular patch updates the documentation.
1 parent 7e00e3a commit 226a9d7

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

clang/docs/Multilib.rst

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,73 @@ 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+
MacroDefines: [__SINGLE_THREAD__]
163+
- Name: multithreaded
164+
Default: no-multithreaded
165+
166+
* Name: the name to categorize a flag.
167+
* Values: a list of flag Values (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+
Each flag *Value* is defined as:
173+
174+
* Name: name of the value. This is the string to be used in
175+
``-fmultilib-flag=<string>``.
176+
* MacroDefines: a list of strings to be used as macro definitions. Each string
177+
is fed into the driver as ``-D<string>``.
178+
179+
The namespace of flag values is common across all flags. This means that flag
180+
value names must be unique.
181+
182+
Usage of custom flags in the *Variants* specifications
183+
------------------------------------------------------
184+
185+
Library variants should list their requirement on one or more custom flags like
186+
they do for any other flag. Each requirement must be listed as
187+
``-fmultilib-flag=<value>``.
188+
189+
A variant that does not specify a requirement on one particular flag can be
190+
matched against any value of that flag.
191+
125192
Stability
126193
=========
127194

@@ -222,6 +289,23 @@ For a more comprehensive example see
222289
# Flags is a list of one or more strings.
223290
Flags: [--target=thumbv7m-none-eabi]
224291
292+
# Custom flag declarations. Each item is a different declaration.
293+
Flags:
294+
# Name of the flag
295+
- Name: multithreaded
296+
# List of custom flag values
297+
Values:
298+
# Name of the custom flag value. To be used in -fmultilib-flag=<string>.
299+
- Name: no-multithreaded
300+
# Macro definitions. Useful for defining extra macros for building the
301+
# associated library variant(s).
302+
MacroDefines: [__SINGLE_THREAD__]
303+
- Name: multithreaded
304+
# Default flag value. If no value for this flag declaration is used in the
305+
# command-line, the multilib system will use this one. Must be equal to one
306+
# of the flag value names from this flag declaration.
307+
Default: no-multithreaded
308+
225309
Design principles
226310
=================
227311

0 commit comments

Comments
 (0)