|
95 | 95 | #include "llvm/TargetParser/Host.h"
|
96 | 96 | #include "llvm/TargetParser/RISCVISAInfo.h"
|
97 | 97 | #include <cstdlib> // ::getenv
|
| 98 | +#include <cstring> |
98 | 99 | #include <map>
|
99 | 100 | #include <memory>
|
100 | 101 | #include <optional>
|
@@ -1222,6 +1223,24 @@ bool Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) {
|
1222 | 1223 | if (ExpCtx.findConfigFile(CfgFileName, CfgFilePath))
|
1223 | 1224 | return readConfigFile(CfgFilePath, ExpCtx);
|
1224 | 1225 |
|
| 1226 | + // On Darwin, try a major-versioned triple then an unversioned triple. |
| 1227 | + auto pos = Triple.find("-apple-darwin"); |
| 1228 | + auto kernelVersionStart = pos + std::strlen("-apple-darwin"); |
| 1229 | + if (pos != Triple.npos && Triple.length() > kernelVersionStart) { |
| 1230 | + // First, find the major-versioned triple (e.g. arm64-apple-darwin24). |
| 1231 | + auto T = Triple.substr(0, Triple.find(".", kernelVersionStart)); |
| 1232 | + CfgFileName = T + ".cfg"; |
| 1233 | + if (ExpCtx.findConfigFile(CfgFileName, CfgFilePath)) |
| 1234 | + return readConfigFile(CfgFilePath, ExpCtx); |
| 1235 | + |
| 1236 | + // If that is not available, try an unversioned triple |
| 1237 | + // (e.g. arm64-apple-darwin). |
| 1238 | + T = Triple.substr(0, kernelVersionStart); |
| 1239 | + CfgFileName = T + ".cfg"; |
| 1240 | + if (ExpCtx.findConfigFile(CfgFileName, CfgFilePath)) |
| 1241 | + return readConfigFile(CfgFilePath, ExpCtx); |
| 1242 | + } |
| 1243 | + |
1225 | 1244 | // If we were unable to find a config file deduced from executable name,
|
1226 | 1245 | // that is not an error.
|
1227 | 1246 | return false;
|
|
0 commit comments