diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-10 19:27:02 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-10 19:27:02 +0900 |
commit | c4a2ca9b936391fb930ecbb3d5c5d34e371e45fb (patch) | |
tree | f7bbf2b44d3dc178bcbaefdc56254e2220237737 /clang/lib/Driver/Driver.cpp | |
parent | 5633a2072696b20c554ff5568c5a1d25aa7e8db3 (diff) | |
parent | 0350c1eba1c1a6b73a8d9c271a7f3c8b33202579 (diff) | |
download | llvm-users/chapuni/cov/merge/forfile-base.zip llvm-users/chapuni/cov/merge/forfile-base.tar.gz llvm-users/chapuni/cov/merge/forfile-base.tar.bz2 |
Merge branch 'users/chapuni/cov/merge/region_segment' into users/chapuni/cov/merge/forfile-baseusers/chapuni/cov/merge/forfile-base
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 36d6c93..528b7d1 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1063,6 +1063,34 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, // } +bool Driver::loadZOSCustomizationFile(llvm::cl::ExpansionContext &ExpCtx) { + if (IsCLMode() || IsDXCMode() || IsFlangMode()) + return false; + + SmallString<128> CustomizationFile; + StringRef PathLIBEnv = StringRef(getenv("CLANG_CONFIG_PATH")).trim(); + // If the env var is a directory then append "/clang.cfg" and treat + // that as the config file. Otherwise treat the env var as the + // config file. + if (!PathLIBEnv.empty()) { + llvm::sys::path::append(CustomizationFile, PathLIBEnv); + if (llvm::sys::fs::is_directory(PathLIBEnv)) + llvm::sys::path::append(CustomizationFile, "/clang.cfg"); + if (llvm::sys::fs::is_regular_file(CustomizationFile)) + return readConfigFile(CustomizationFile, ExpCtx); + Diag(diag::err_drv_config_file_not_found) << CustomizationFile; + return true; + } + + SmallString<128> BaseDir(llvm::sys::path::parent_path(Dir)); + llvm::sys::path::append(CustomizationFile, BaseDir + "/etc/clang.cfg"); + if (llvm::sys::fs::is_regular_file(CustomizationFile)) + return readConfigFile(CustomizationFile, ExpCtx); + + // If no customization file, just return + return false; +} + static void appendOneArg(InputArgList &Args, const Arg *Opt) { // The args for config files or /clang: flags belong to different InputArgList // objects than Args. This copies an Arg from one of those other InputArgLists @@ -1284,11 +1312,18 @@ bool Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) { } // Otherwise, use the real triple as used by the driver. + llvm::Triple RealTriple = + computeTargetTriple(*this, TargetTriple, *CLOptions); if (Triple.str().empty()) { - Triple = computeTargetTriple(*this, TargetTriple, *CLOptions); + Triple = RealTriple; assert(!Triple.str().empty()); } + // On z/OS, start by loading the customization file before loading + // the usual default config file(s). + if (RealTriple.isOSzOS() && loadZOSCustomizationFile(ExpCtx)) + return true; + // Search for config files in the following order: // 1. <triple>-<mode>.cfg using real driver mode // (e.g. i386-pc-linux-gnu-clang++.cfg). @@ -6686,6 +6721,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique<toolchains::BareMetal>(*this, Target, Args); else if (Target.isOSBinFormatELF()) TC = std::make_unique<toolchains::Generic_ELF>(*this, Target, Args); + else if (Target.isAppleMachO()) + TC = std::make_unique<toolchains::AppleMachO>(*this, Target, Args); else if (Target.isOSBinFormatMachO()) TC = std::make_unique<toolchains::MachO>(*this, Target, Args); else |