1a5aeba73SMichael Platings======== 2a5aeba73SMichael PlatingsMultilib 3a5aeba73SMichael Platings======== 4a5aeba73SMichael Platings 5a5aeba73SMichael PlatingsIntroduction 6a5aeba73SMichael Platings============ 7a5aeba73SMichael Platings 8a5aeba73SMichael PlatingsThis document describes how multilib is implemented in Clang. 9a5aeba73SMichael Platings 10a5aeba73SMichael PlatingsWhat is multilib and why might you care? 11a5aeba73SMichael PlatingsIf you're :doc:`cross compiling<CrossCompilation>` then you can't use native 12a5aeba73SMichael Platingssystem headers and libraries. To address this, you can use a combination of 13a5aeba73SMichael Platings``--sysroot``, ``-isystem`` and ``-L`` options to point Clang at suitable 14a5aeba73SMichael Platingsdirectories for your target. 15a5aeba73SMichael PlatingsHowever, when there are many possible directories to choose from, it's not 16a5aeba73SMichael Platingsnecessarily obvious which one to pick. 17a5aeba73SMichael PlatingsMultilib allows a toolchain designer to imbue the toolchain with the ability to 18a5aeba73SMichael Platingspick a suitable directory automatically, based on the options the user provides 19a5aeba73SMichael Platingsto Clang. For example, if the user specifies 20a5aeba73SMichael Platings``--target=arm-none-eabi -mcpu=cortex-m4`` the toolchain can choose a directory 21a5aeba73SMichael Platingscontaining headers and libraries suitable for Armv7E-M, because it knows that's 22a5aeba73SMichael Platingsa suitable architecture for Arm Cortex-M4. 23a5aeba73SMichael PlatingsMultilib can also choose between libraries for the same architecture based on 24a5aeba73SMichael Platingsother options. For example if the user specifies ``-fno-exceptions`` then a 25a5aeba73SMichael Platingstoolchain could select libraries built without exception support, thereby 26a5aeba73SMichael Platingsreducing the size of the resulting binary. 27a5aeba73SMichael Platings 28a5aeba73SMichael PlatingsDesign 29a5aeba73SMichael Platings====== 30a5aeba73SMichael Platings 31a5aeba73SMichael PlatingsClang supports GCC's ``-print-multi-lib`` and ``-print-multi-directory`` 32a5aeba73SMichael Platingsoptions. These are described in 33a5aeba73SMichael Platings`GCC Developer Options <https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Developer-Options.html>`_. 34a5aeba73SMichael Platings 35a5aeba73SMichael PlatingsThere are two ways to configure multilib in Clang: hard-coded or via a 36a5aeba73SMichael Platingsconfiguration file. 37a5aeba73SMichael Platings 38a5aeba73SMichael PlatingsHard-coded Multilib 39a5aeba73SMichael Platings=================== 40a5aeba73SMichael Platings 41a5aeba73SMichael PlatingsThe available libraries can be hard-coded in Clang. Typically this is done 42a5aeba73SMichael Platingsusing the ``MultilibBuilder`` interface in 43a5aeba73SMichael Platings``clang/include/clang/Driver/MultilibBuilder.h``. 44a5aeba73SMichael PlatingsThere are many examples of this in ``lib/Driver/ToolChains/Gnu.cpp``. 45a5aeba73SMichael PlatingsThe remainder of this document will not focus on this type of multilib. 46a5aeba73SMichael Platings 47a5aeba73SMichael PlatingsEXPERIMENTAL Multilib via configuration file 48a5aeba73SMichael Platings============================================ 49a5aeba73SMichael Platings 50a5aeba73SMichael PlatingsSome Clang toolchains support loading multilib configuration from a 51a5aeba73SMichael Platings``multilib.yaml`` configuration file. 52a5aeba73SMichael Platings 53a5aeba73SMichael PlatingsA ``multilib.yaml`` configuration file specifies which multilib variants are 54a5aeba73SMichael Platingsavailable, their relative location, what compilation options were used to build 55a5aeba73SMichael Platingsthem, and the criteria by which they are selected. 56a5aeba73SMichael Platings 57a5aeba73SMichael PlatingsMultilib processing 58a5aeba73SMichael Platings=================== 59a5aeba73SMichael Platings 60a5aeba73SMichael PlatingsClang goes through the following steps to use multilib from a configuration 61a5aeba73SMichael Platingsfile: 62bf449be9SSimon Pilgrim 63a5aeba73SMichael Platings#. Normalize command line options. Clang can accept the same 64a5aeba73SMichael Platings information via different options - for example, 65a5aeba73SMichael Platings ``--target=arm-none-eabi -march=armv7-m`` and 66a5aeba73SMichael Platings ``--target=armv7m-none-eabi`` are equivalent. 67a5aeba73SMichael Platings Clang normalizes the command line before passing them to the multilib system. 68a5aeba73SMichael Platings To see what flags are emitted for a given set of command line options, use 69a5aeba73SMichael Platings the ``-print-multi-flags-experimental`` command line option 70a5aeba73SMichael Platings along with the rest of the options you want to use. 71a5aeba73SMichael Platings#. Load ``multilib.yaml`` from sysroot. 72a5aeba73SMichael Platings#. Generate additional flags. ``multilib.yaml`` contains a ``Mappings`` section, 73a5aeba73SMichael Platings which specifies how to generate additional flags based on the flags derived 74a5aeba73SMichael Platings from command line options. Flags are matched using regular expressions. 75a5aeba73SMichael Platings These regular expressions shall use the POSIX extended regular expression 76a5aeba73SMichael Platings syntax. 77a5aeba73SMichael Platings#. Match flags against multilib variants. If the generated flags are a superset 78a5aeba73SMichael Platings of the flags specified for a multilib variant then the variant is considered 79a5aeba73SMichael Platings a match. 80a5aeba73SMichael Platings If more than one variant matches then a toolchain may opt to either use only 81a5aeba73SMichael Platings the *last* matching multilib variant, or may use all matching variants, 827e20e13dSSimon Pilgrim thereby :ref:`layering<multilib-layering>` them. 83a5aeba73SMichael Platings#. Generate ``-isystem`` and ``-L`` options. Iterate in reverse order over 84a5aeba73SMichael Platings the matching multilib variants, and generate ``-isystem`` and ``-L`` 85a5aeba73SMichael Platings options based on the multilib variant's directory. 86a5aeba73SMichael Platings 877e20e13dSSimon Pilgrim.. _multilib-layering: 887e20e13dSSimon Pilgrim 89a5aeba73SMichael PlatingsMultilib layering 90a5aeba73SMichael Platings================= 91a5aeba73SMichael Platings 92a5aeba73SMichael PlatingsWhen Clang selects multilib variants, it may find that more than one variant 93a5aeba73SMichael Platingsmatches. 94a5aeba73SMichael Platings 95a5aeba73SMichael PlatingsIt is up to the ToolChain subclass to decide what to do in this case. 96a5aeba73SMichael PlatingsThere are two options permitted: 97bf449be9SSimon Pilgrim 98a5aeba73SMichael Platings#. Use only the *last* matching multilib variant. This option exists primarily 99a5aeba73SMichael Platings for compatibility with the previous multilib design. 100a5aeba73SMichael Platings#. Use all matching variants, thereby layering them. 101a5aeba73SMichael Platings 102a5aeba73SMichael PlatingsThis decision is hard-coded per ToolChain subclass. The latter option is 103a5aeba73SMichael Platingspreferred for ToolChain subclasses without backwards compatibility 104a5aeba73SMichael Platingsrequirements. 105a5aeba73SMichael Platings 106a5aeba73SMichael PlatingsIf the latter option is chosen then ``-isystem`` and ``-L`` options will be 107a5aeba73SMichael Platingsgenerated for each matching multilib variant, in reverse order. 108a5aeba73SMichael Platings 109a5aeba73SMichael PlatingsThis means that the compiler or linker will find files in the last matching 110a5aeba73SMichael Platingsmultilib variant that has the given file. 111a5aeba73SMichael PlatingsThis behaviour permits multilib variants with only a partial set of files. 112a5aeba73SMichael PlatingsThis means a toolchain can be distributed with one base multilib variant 113a5aeba73SMichael Platingscontaining all system headers and includes, and more specialised multilib 114a5aeba73SMichael Platingsvariants containing only files that are different to those in the base variant. 115a5aeba73SMichael Platings 116a5aeba73SMichael PlatingsFor example, a multilib variant could be compiled with ``-fno-exceptions``. 117a5aeba73SMichael PlatingsThis option doesn't affect the content of header files, nor does it affect the 118a5aeba73SMichael PlatingsC libraries. Therefore if multilib layering is supported by the ToolChain 119a5aeba73SMichael Platingssubclass and a suitable base multilib variant is present then the 120a5aeba73SMichael Platings``-fno-exceptions`` multilib variant need only contain C++ libraries. 121a5aeba73SMichael Platings 122a5aeba73SMichael PlatingsIt is the responsibility of layered multilib authors to ensure that headers and 123a5aeba73SMichael Platingslibraries in each layer are complete enough to mask any incompatibilities. 124a5aeba73SMichael Platings 125*226a9d73SVictor CamposMultilib custom flags 126*226a9d73SVictor Campos===================== 127*226a9d73SVictor Campos 128*226a9d73SVictor CamposIntroduction 129*226a9d73SVictor Campos------------ 130*226a9d73SVictor Campos 131*226a9d73SVictor CamposThe multilib mechanism supports library variants that correspond to target, 132*226a9d73SVictor Camposcode generation or language command-line flags. Examples include ``--target``, 133*226a9d73SVictor Campos``-mcpu``, ``-mfpu``, ``-mbranch-protection``, ``-fno-rtti``. However, some library 134*226a9d73SVictor Camposvariants are particular to features that do not correspond to any command-line 135*226a9d73SVictor Camposoption. Multithreading and semihosting, for instance, have no associated 136*226a9d73SVictor Camposcompiler option. 137*226a9d73SVictor Campos 138*226a9d73SVictor CamposIn order to support the selection of variants for which no compiler option 139*226a9d73SVictor Camposexists, the multilib specification includes the concept of *custom flags*. 140*226a9d73SVictor CamposThese flags have no impact on code generation and are only used in the multilib 141*226a9d73SVictor Camposprocessing. 142*226a9d73SVictor Campos 143*226a9d73SVictor CamposMultilib custom flags follow this format in the driver invocation: 144*226a9d73SVictor Campos 145*226a9d73SVictor Campos:: 146*226a9d73SVictor Campos 147*226a9d73SVictor Campos -fmultilib-flag=<value> 148*226a9d73SVictor Campos 149*226a9d73SVictor CamposThey are fed into the multilib system alongside the remaining flags. 150*226a9d73SVictor Campos 151*226a9d73SVictor CamposCustom flag declarations 152*226a9d73SVictor Campos------------------------ 153*226a9d73SVictor Campos 154*226a9d73SVictor CamposCustom flags can be declared in the YAML file under the *Flags* section. 155*226a9d73SVictor Campos 156*226a9d73SVictor Campos.. code-block:: yaml 157*226a9d73SVictor Campos 158*226a9d73SVictor Campos Flags: 159*226a9d73SVictor Campos - Name: multithreaded 160*226a9d73SVictor Campos Values: 161*226a9d73SVictor Campos - Name: no-multithreaded 162*226a9d73SVictor Campos MacroDefines: [__SINGLE_THREAD__] 163*226a9d73SVictor Campos - Name: multithreaded 164*226a9d73SVictor Campos Default: no-multithreaded 165*226a9d73SVictor Campos 166*226a9d73SVictor Campos* Name: the name to categorize a flag. 167*226a9d73SVictor Campos* Values: a list of flag Values (defined below). 168*226a9d73SVictor Campos* Default: it specifies the name of the value this flag should take if not 169*226a9d73SVictor Campos specified in the command-line invocation. It must be one value from the Values 170*226a9d73SVictor Campos field. 171*226a9d73SVictor Campos 172*226a9d73SVictor CamposEach flag *Value* is defined as: 173*226a9d73SVictor Campos 174*226a9d73SVictor Campos* Name: name of the value. This is the string to be used in 175*226a9d73SVictor Campos ``-fmultilib-flag=<string>``. 176*226a9d73SVictor Campos* MacroDefines: a list of strings to be used as macro definitions. Each string 177*226a9d73SVictor Campos is fed into the driver as ``-D<string>``. 178*226a9d73SVictor Campos 179*226a9d73SVictor CamposThe namespace of flag values is common across all flags. This means that flag 180*226a9d73SVictor Camposvalue names must be unique. 181*226a9d73SVictor Campos 182*226a9d73SVictor CamposUsage of custom flags in the *Variants* specifications 183*226a9d73SVictor Campos------------------------------------------------------ 184*226a9d73SVictor Campos 185*226a9d73SVictor CamposLibrary variants should list their requirement on one or more custom flags like 186*226a9d73SVictor Camposthey do for any other flag. Each requirement must be listed as 187*226a9d73SVictor Campos``-fmultilib-flag=<value>``. 188*226a9d73SVictor Campos 189*226a9d73SVictor CamposA variant that does not specify a requirement on one particular flag can be 190*226a9d73SVictor Camposmatched against any value of that flag. 191*226a9d73SVictor Campos 192a5aeba73SMichael PlatingsStability 193a5aeba73SMichael Platings========= 194a5aeba73SMichael Platings 195a5aeba73SMichael PlatingsMultilib via configuration file shall be considered an experimental feature 196a5aeba73SMichael Platingsuntil LLVM 18, at which point ``-print-multi-flags-experimental`` 197a5aeba73SMichael Platingsshould be renamed to ``-print-multi-flags``. 198a5aeba73SMichael PlatingsA toolchain can opt in to using this feature by including a ``multilib.yaml`` 199a5aeba73SMichael Platingsfile in its distribution, once support for it is added in relevant ToolChain 200a5aeba73SMichael Platingssubclasses. 201a5aeba73SMichael PlatingsOnce stability is reached, flags emitted by ``-print-multi-flags`` 202a5aeba73SMichael Platingsshould not be removed or changed, although new flags may be added. 203a5aeba73SMichael Platings 204a5aeba73SMichael PlatingsRestrictions 205a5aeba73SMichael Platings============ 206a5aeba73SMichael Platings 207a5aeba73SMichael PlatingsDespite the name, multilib is used to locate both ``include`` and ``lib`` 208a5aeba73SMichael Platingsdirectories. Therefore it is important that consistent options are passed to 209a5aeba73SMichael Platingsthe Clang driver when both compiling and linking. Otherwise inconsistent 210a5aeba73SMichael Platings``include`` and ``lib`` directories may be used, and the results will be 211a5aeba73SMichael Platingsundefined. 212a5aeba73SMichael Platings 213a5aeba73SMichael PlatingsEXPERIMENTAL multilib.yaml 214a5aeba73SMichael Platings========================== 215a5aeba73SMichael Platings 216a5aeba73SMichael PlatingsThe below example serves as a small of a possible multilib, and documents 217a5aeba73SMichael Platingsthe available options. 218a5aeba73SMichael Platings 219a5aeba73SMichael PlatingsFor a more comprehensive example see 220a5aeba73SMichael Platings``clang/test/Driver/baremetal-multilib.yaml`` in the ``llvm-project`` sources. 221a5aeba73SMichael Platings 222a5aeba73SMichael Platings.. code-block:: yaml 22300b1dd82SSimon Pilgrim 224a5aeba73SMichael Platings # multilib.yaml 225a5aeba73SMichael Platings 226a5aeba73SMichael Platings # This format is experimental and is likely to change! 227a5aeba73SMichael Platings 228a5aeba73SMichael Platings # Syntax is YAML 1.2 229a5aeba73SMichael Platings 230a5aeba73SMichael Platings # This required field defines the version of the multilib.yaml format. 231a5aeba73SMichael Platings # Clang will emit an error if this number is greater than its current multilib 232a5aeba73SMichael Platings # version or if its major version differs, but will accept lesser minor 233a5aeba73SMichael Platings # versions. 234a5aeba73SMichael Platings MultilibVersion: 1.0 235a5aeba73SMichael Platings 236a5aeba73SMichael Platings # The rest of this file is in two parts: 237a5aeba73SMichael Platings # 1. A list of multilib variants. 238a5aeba73SMichael Platings # 2. A list of regular expressions that may match flags generated from 239a5aeba73SMichael Platings # command line options, and further flags that shall be added if the 240a5aeba73SMichael Platings # regular expression matches. 241a5aeba73SMichael Platings # It is acceptable for the file to contain properties not documented here, 242a5aeba73SMichael Platings # and these will be ignored by Clang. 243a5aeba73SMichael Platings 244a5aeba73SMichael Platings # List of multilib variants. Required. 245a5aeba73SMichael Platings # The ordering of items in the variants list is important if more than one 246a5aeba73SMichael Platings # variant can match the same set of flags. See the docs on multilib layering 247a5aeba73SMichael Platings # for more info. 248a5aeba73SMichael Platings Variants: 249a5aeba73SMichael Platings 250a5aeba73SMichael Platings # Example of a multilib variant targeting Arm v6-M. 251a5aeba73SMichael Platings # Dir is the relative location of the directory containing the headers 252a5aeba73SMichael Platings # and/or libraries. 253a5aeba73SMichael Platings # Exactly how Dir is used is left up to the ToolChain subclass to define, but 254a5aeba73SMichael Platings # typically it will be joined to the sysroot. 255a5aeba73SMichael Platings - Dir: thumb/v6-m 256a5aeba73SMichael Platings # List of one or more normalized command line options, as generated by Clang 257a5aeba73SMichael Platings # from the command line options or from Mappings below. 2584b75fcf0SYunQiang Su # Here, if the flags are a superset of {target=thumbv6m-unknown-none-eabi} 259a5aeba73SMichael Platings # then this multilib variant will be considered a match. 2604b75fcf0SYunQiang Su Flags: [--target=thumbv6m-unknown-none-eabi] 261a5aeba73SMichael Platings 262a5aeba73SMichael Platings # Similarly, a multilib variant targeting Arm v7-M with an FPU (floating 263a5aeba73SMichael Platings # point unit). 264a5aeba73SMichael Platings - Dir: thumb/v7-m 265a5aeba73SMichael Platings # Here, the flags generated by Clang must be a superset of 266a5aeba73SMichael Platings # {--target=thumbv7m-none-eabi, -mfpu=fpv4-sp-d16} for this multilib variant 267a5aeba73SMichael Platings # to be a match. 268a5aeba73SMichael Platings Flags: [--target=thumbv7m-none-eabi, -mfpu=fpv4-sp-d16] 269a5aeba73SMichael Platings 27026bf0b4aSSimon Tatham # If there is no multilib available for a particular set of flags, and the 27126bf0b4aSSimon Tatham # other multilibs are not adequate fallbacks, then you can define a variant 272e0df221dSSimon Tatham # record with an Error key in place of the Dir key. 273e0df221dSSimon Tatham - Error: this multilib collection has no hard-float ABI support 27426bf0b4aSSimon Tatham Flags: [--target=thumbv7m-none-eabi, -mfloat-abi=hard] 27526bf0b4aSSimon Tatham 276a5aeba73SMichael Platings 277a5aeba73SMichael Platings # The second section of the file is a list of regular expressions that are 278a5aeba73SMichael Platings # used to map from flags generated from command line options to custom flags. 279a5aeba73SMichael Platings # This is optional. 280a5aeba73SMichael Platings # Each regular expression must match a whole flag string. 281a5aeba73SMichael Platings # Flags in the "Flags" list will be added if any flag generated from command 282a5aeba73SMichael Platings # line options matches the regular expression. 283a5aeba73SMichael Platings Mappings: 284a5aeba73SMichael Platings 285a5aeba73SMichael Platings # Set a "--target=thumbv7m-none-eabi" flag if the regular expression matches 286a5aeba73SMichael Platings # any of the flags generated from the command line options. 287a5aeba73SMichael Platings # Match is a POSIX extended regular expression string. 288a5aeba73SMichael Platings - Match: --target=thumbv([7-9]|[1-9][0-9]+).* 289a5aeba73SMichael Platings # Flags is a list of one or more strings. 290a5aeba73SMichael Platings Flags: [--target=thumbv7m-none-eabi] 291a5aeba73SMichael Platings 292*226a9d73SVictor Campos # Custom flag declarations. Each item is a different declaration. 293*226a9d73SVictor Campos Flags: 294*226a9d73SVictor Campos # Name of the flag 295*226a9d73SVictor Campos - Name: multithreaded 296*226a9d73SVictor Campos # List of custom flag values 297*226a9d73SVictor Campos Values: 298*226a9d73SVictor Campos # Name of the custom flag value. To be used in -fmultilib-flag=<string>. 299*226a9d73SVictor Campos - Name: no-multithreaded 300*226a9d73SVictor Campos # Macro definitions. Useful for defining extra macros for building the 301*226a9d73SVictor Campos # associated library variant(s). 302*226a9d73SVictor Campos MacroDefines: [__SINGLE_THREAD__] 303*226a9d73SVictor Campos - Name: multithreaded 304*226a9d73SVictor Campos # Default flag value. If no value for this flag declaration is used in the 305*226a9d73SVictor Campos # command-line, the multilib system will use this one. Must be equal to one 306*226a9d73SVictor Campos # of the flag value names from this flag declaration. 307*226a9d73SVictor Campos Default: no-multithreaded 308*226a9d73SVictor Campos 309a5aeba73SMichael PlatingsDesign principles 310a5aeba73SMichael Platings================= 311a5aeba73SMichael Platings 312a5aeba73SMichael PlatingsStable interface 313a5aeba73SMichael Platings---------------- 314a5aeba73SMichael Platings 315a5aeba73SMichael Platings``multilib.yaml`` and ``-print-multi-flags-experimental`` are new 316a5aeba73SMichael Platingsinterfaces to Clang. In order for them to be usable over time and across LLVM 317a5aeba73SMichael Platingsversions their interfaces should be stable. 318a5aeba73SMichael PlatingsThe new multilib system will be considered experimental in LLVM 17, but in 319a5aeba73SMichael PlatingsLLVM 18 it will be stable. In particular this is important to which multilib 320a5aeba73SMichael Platingsselection flags Clang generates from command line options. Once a flag is 321a5aeba73SMichael Platingsgenerated by a released version of Clang it may be used in ``multilib.yaml`` 322a5aeba73SMichael Platingsfiles that exist independently of the LLVM release cycle, and therefore 323a5aeba73SMichael Platingsceasing to generate the flag would be a breaking change and should be 324a5aeba73SMichael Platingsavoided. 325a5aeba73SMichael Platings 326a5aeba73SMichael PlatingsHowever, an exception is the normalization of ``-march``. 327a5aeba73SMichael Platings``-march`` for Arm architectures contains a list of enabled and disabled 328a5aeba73SMichael Platingsextensions and this list is likely to grow. Therefore ``-march`` flags are 329a5aeba73SMichael Platingsunstable. 330a5aeba73SMichael Platings 331a5aeba73SMichael PlatingsIncomplete interface 332a5aeba73SMichael Platings-------------------- 333a5aeba73SMichael Platings 334a5aeba73SMichael PlatingsThe new multilib system does multilib selection based on only a limited set of 335a5aeba73SMichael Platingscommand line options, and limits which flags can be used for multilib 336a5aeba73SMichael Platingsselection. This is in order to avoid committing to too large an interface. 337a5aeba73SMichael PlatingsLater LLVM versions can add support for multilib selection from more command 338a5aeba73SMichael Platingsline options as needed. 339a5aeba73SMichael Platings 340a5aeba73SMichael PlatingsExtensible 341a5aeba73SMichael Platings---------- 342a5aeba73SMichael Platings 343a5aeba73SMichael PlatingsIt is likely that the configuration format will need to evolve in future to 344a5aeba73SMichael Platingsadapt to new requirements. 345a5aeba73SMichael PlatingsUsing a format like YAML that supports key-value pairs helps here as it's 346a5aeba73SMichael Platingstrivial to add new keys alongside existing ones. 347a5aeba73SMichael Platings 348a5aeba73SMichael PlatingsBackwards compatibility 349a5aeba73SMichael Platings----------------------- 350a5aeba73SMichael Platings 351a5aeba73SMichael PlatingsNew versions of Clang should be able to use configuration written for earlier 352a5aeba73SMichael PlatingsClang versions. 353a5aeba73SMichael PlatingsTo avoid behaving in a way that may be subtly incorrect, Clang should be able 354a5aeba73SMichael Platingsto detect if the configuration is too new and emit an error. 355a5aeba73SMichael Platings 356a5aeba73SMichael PlatingsForwards compatibility 357a5aeba73SMichael Platings---------------------- 358a5aeba73SMichael Platings 359a5aeba73SMichael PlatingsAs an author of a multilib configuration, it should be possible to design the 360a5aeba73SMichael Platingsconfiguration in such a way that it is likely to work well with future Clang 361a5aeba73SMichael Platingsversions. For example, if a future version of Clang is likely to add support 362a5aeba73SMichael Platingsfor newer versions of an architecture and the architecture is known to be 363a5aeba73SMichael Platingsdesigned for backwards compatibility then it should be possible to express 364a5aeba73SMichael Platingscompatibility for such architecture versions in the multilib configuration. 365a5aeba73SMichael Platings 366a5aeba73SMichael PlatingsNot GNU spec files 367a5aeba73SMichael Platings------------------ 368a5aeba73SMichael Platings 369a5aeba73SMichael PlatingsThe GNU spec files standard is large and complex and there's little desire to 370a5aeba73SMichael Platingsimport that complexity to LLVM. It's also heavily oriented towards processing 371a5aeba73SMichael Platingscommand line argument strings which is hard to do correctly, hence the large 372a5aeba73SMichael Platingsamount of logic dedicated to that task in the Clang driver. While compatibility 373a5aeba73SMichael Platingswith GNU would bring benefits, the cost in this case is deemed too high. 374a5aeba73SMichael Platings 375a5aeba73SMichael PlatingsAvoid re-inventing feature detection in the configuration 376a5aeba73SMichael Platings--------------------------------------------------------- 377a5aeba73SMichael Platings 378a5aeba73SMichael PlatingsA large amount of logic in the Clang driver is dedicated to inferring which 379a5aeba73SMichael Platingsarchitectural features are available based on the given command line options. 380a5aeba73SMichael PlatingsIt is neither desirable nor practical to repeat such logic in each multilib 381a5aeba73SMichael Platingsconfiguration. Instead the configuration should be able to benefit from the 382a5aeba73SMichael Platingsheavy lifting Clang already does to detect features. 383a5aeba73SMichael Platings 384a5aeba73SMichael PlatingsLow maintenance 385a5aeba73SMichael Platings--------------- 386a5aeba73SMichael Platings 387a5aeba73SMichael PlatingsMultilib is a relatively small feature in the scheme of things so supporting it 388a5aeba73SMichael Platingsshould accordingly take little time. Where possible this should be achieved by 389a5aeba73SMichael Platingsimplementing it in terms of existing features in the LLVM codebase. 390a5aeba73SMichael Platings 391a5aeba73SMichael PlatingsMinimal additional API surface 392a5aeba73SMichael Platings------------------------------ 393a5aeba73SMichael Platings 394a5aeba73SMichael PlatingsThe greater the API surface, the greater the difficulty of keeping it stable. 395a5aeba73SMichael PlatingsWhere possible the additional API surface should be kept small by defining it 396a5aeba73SMichael Platingsin relation to existing APIs. An example of this is keeping a simple 397a5aeba73SMichael Platingsrelationship between flag names and command line options where possible. 398a5aeba73SMichael PlatingsSince the command line options are part of a stable API they are unlikely 399a5aeba73SMichael Platingsto change, and therefore the flag names get the same stability. 400a5aeba73SMichael Platings 401a5aeba73SMichael PlatingsLow compile-time overhead 402a5aeba73SMichael Platings------------------------- 403a5aeba73SMichael Platings 404a5aeba73SMichael PlatingsIf the process of selecting multilib directories must be done on every 405a5aeba73SMichael Platingsinvocation of the Clang driver then it must have a negligible impact on 406a5aeba73SMichael Platingsoverall compile time. 407