[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs (WIP)
Michał Górny via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 21 04:00:06 PDT 2022
mgorny added a comment.
To explain this better, let's take the following example call:
x86_64-pc-linux-gnu-clang --driver-mode=g++ -target i386
This maps to:
- effective triple: `i386` (from `-target`)
- effective mode: `clang++` (from `--driver-mode`)
- name prefix: `x86_64-pc-linux-gnu`
- "fixed" name prefix: `i386-pc-linux-gnu` (with arch substituted based on effective triple)
- name suffix: `clang`
The algorithm will first try to use the first of the following configuration files:
1. `i386-clang++.cfg` (effective triple + effective mode)
2. `i386-pc-linux-gnu-clang.cfg` ("fixed" prefix + suffix)
3. `x86_64-pc-linux-gnu-clang.cfg` (orig. prefix + suffix)
If neither of these files are found, it will try to load one config file for the target and another for the driver.
For target, it will try:
1. `i386.cfg` (effective triple)
2. `i386-pc-linux-gnu.cfg` ("fixed" prefix)
3. `x86_64-pc-linux-gnu.cfg` (orig. prefix)
For driver, it will try:
1. `clang++.cfg` (effective mode)
2. `clang.cfg` (suffix)
This version doesn't include any further fallback, i.e. assumes we need to cover all triples and driver modes we care about. However, adding one should be trivial.
================
Comment at: clang/lib/Driver/Driver.cpp:1065-1080
+ StringRef EffectiveDriverMode;
+ if (CLOptions)
+ EffectiveDriverMode = CLOptions->getLastArgValue(options::OPT_driver_mode);
+ if (EffectiveDriverMode.empty())
+ EffectiveDriverMode = ClangNameParts.DriverMode;
+
+ llvm::Triple EffectiveTriple =
----------------
This part is mostly proof-of-concept, I need to look into how to do this properly.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134337/new/
https://reviews.llvm.org/D134337
More information about the cfe-commits
mailing list