Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(677)

Side by Side Diff: lib/Driver/Driver.cpp

Issue 1547623002: Clang toolchain driver for PNaCl (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-clang.git@master
Patch Set: Review feedback addressed Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/Basic/Targets.cpp ('k') | lib/Driver/ToolChains.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===--- Driver.cpp - Clang GCC Compatible Driver -------------------------===// 1 //===--- Driver.cpp - Clang GCC Compatible Driver -------------------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 9
10 #include "clang/Driver/Driver.h" 10 #include "clang/Driver/Driver.h"
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 llvm::PrettyStackTraceString CrashInfo("Building compilation actions"); 1154 llvm::PrettyStackTraceString CrashInfo("Building compilation actions");
1155 1155
1156 if (!SuppressMissingInputWarning && Inputs.empty()) { 1156 if (!SuppressMissingInputWarning && Inputs.empty()) {
1157 Diag(clang::diag::err_drv_no_input_files); 1157 Diag(clang::diag::err_drv_no_input_files);
1158 return; 1158 return;
1159 } 1159 }
1160 1160
1161 Arg *FinalPhaseArg; 1161 Arg *FinalPhaseArg;
1162 phases::ID FinalPhase = getFinalPhase(Args, &FinalPhaseArg); 1162 phases::ID FinalPhase = getFinalPhase(Args, &FinalPhaseArg);
1163 1163
1164 if (FinalPhase == phases::Link && Args.hasArg(options::OPT_emit_llvm)) { 1164 if (FinalPhase == phases::Link && Args.hasArg(options::OPT_emit_llvm) &&
1165 !TC.isBitcodeOnlyTarget()) {
1165 Diag(clang::diag::err_drv_emit_llvm_link); 1166 Diag(clang::diag::err_drv_emit_llvm_link);
1166 } 1167 }
1167 1168
1168 // Reject -Z* at the top level, these options should never have been exposed 1169 // Reject -Z* at the top level, these options should never have been exposed
1169 // by gcc. 1170 // by gcc.
1170 if (Arg *A = Args.getLastArg(options::OPT_Z_Joined)) 1171 if (Arg *A = Args.getLastArg(options::OPT_Z_Joined))
1171 Diag(clang::diag::err_drv_use_of_Z_option) << A->getAsString(Args); 1172 Diag(clang::diag::err_drv_use_of_Z_option) << A->getAsString(Args);
1172 1173
1173 // Diagnose misuse of /Fo. 1174 // Diagnose misuse of /Fo.
1174 if (Arg *A = Args.getLastArg(options::OPT__SLASH_Fo)) { 1175 if (Arg *A = Args.getLastArg(options::OPT__SLASH_Fo)) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 if (Phase > FinalPhase) 1260 if (Phase > FinalPhase)
1260 break; 1261 break;
1261 1262
1262 // Queue linker inputs. 1263 // Queue linker inputs.
1263 if (Phase == phases::Link) { 1264 if (Phase == phases::Link) {
1264 assert((i + 1) == e && "linking must be final compilation step."); 1265 assert((i + 1) == e && "linking must be final compilation step.");
1265 LinkerInputs.push_back(Current.release()); 1266 LinkerInputs.push_back(Current.release());
1266 break; 1267 break;
1267 } 1268 }
1268 1269
1270 // Virtual targets don't perform assembly step.
1271 if (Phase == phases::Assemble && TC.isBitcodeOnlyTarget())
1272 continue;
1273
1269 // Some types skip the assembler phase (e.g., llvm-bc), but we can't 1274 // Some types skip the assembler phase (e.g., llvm-bc), but we can't
1270 // encode this in the steps because the intermediate type depends on 1275 // encode this in the steps because the intermediate type depends on
1271 // arguments. Just special case here. 1276 // arguments. Just special case here.
1272 if (Phase == phases::Assemble && Current->getType() != types::TY_PP_Asm) 1277 if (Phase == phases::Assemble && Current->getType() != types::TY_PP_Asm)
1273 continue; 1278 continue;
1274 1279
1275 // Otherwise construct the appropriate action. 1280 // Otherwise construct the appropriate action.
1276 Current = ConstructPhaseAction(TC, Args, Phase, std::move(Current)); 1281 Current = ConstructPhaseAction(TC, Args, Phase, std::move(Current));
1277 if (Current->getType() == types::TY_Nothing) 1282 if (Current->getType() == types::TY_Nothing)
1278 break; 1283 break;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 types::TY_Nothing); 1362 types::TY_Nothing);
1358 return llvm::make_unique<CompileJobAction>(std::move(Input), 1363 return llvm::make_unique<CompileJobAction>(std::move(Input),
1359 types::TY_LLVM_BC); 1364 types::TY_LLVM_BC);
1360 } 1365 }
1361 case phases::Backend: { 1366 case phases::Backend: {
1362 if (IsUsingLTO(TC, Args)) { 1367 if (IsUsingLTO(TC, Args)) {
1363 types::ID Output = 1368 types::ID Output =
1364 Args.hasArg(options::OPT_S) ? types::TY_LTO_IR : types::TY_LTO_BC; 1369 Args.hasArg(options::OPT_S) ? types::TY_LTO_IR : types::TY_LTO_BC;
1365 return llvm::make_unique<BackendJobAction>(std::move(Input), Output); 1370 return llvm::make_unique<BackendJobAction>(std::move(Input), Output);
1366 } 1371 }
1367 if (Args.hasArg(options::OPT_emit_llvm)) { 1372 if (Args.hasArg(options::OPT_emit_llvm) || TC.isBitcodeOnlyTarget()) {
1368 types::ID Output = 1373 types::ID Output =
1369 Args.hasArg(options::OPT_S) ? types::TY_LLVM_IR : types::TY_LLVM_BC; 1374 Args.hasArg(options::OPT_S) ? types::TY_LLVM_IR : types::TY_LLVM_BC;
1370 return llvm::make_unique<BackendJobAction>(std::move(Input), Output); 1375 return llvm::make_unique<BackendJobAction>(std::move(Input), Output);
1371 } 1376 }
1372 return llvm::make_unique<BackendJobAction>(std::move(Input), 1377 return llvm::make_unique<BackendJobAction>(std::move(Input),
1373 types::TY_PP_Asm); 1378 types::TY_PP_Asm);
1374 } 1379 }
1375 case phases::Assemble: 1380 case phases::Assemble:
1376 return llvm::make_unique<AssembleJobAction>(std::move(Input), 1381 return llvm::make_unique<AssembleJobAction>(std::move(Input),
1377 types::TY_Object); 1382 types::TY_Object);
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 case llvm::Triple::Minix: 2061 case llvm::Triple::Minix:
2057 TC = new toolchains::Minix(*this, Target, Args); 2062 TC = new toolchains::Minix(*this, Target, Args);
2058 break; 2063 break;
2059 case llvm::Triple::Linux: 2064 case llvm::Triple::Linux:
2060 if (Target.getArch() == llvm::Triple::hexagon) 2065 if (Target.getArch() == llvm::Triple::hexagon)
2061 TC = new toolchains::Hexagon_TC(*this, Target, Args); 2066 TC = new toolchains::Hexagon_TC(*this, Target, Args);
2062 else 2067 else
2063 TC = new toolchains::Linux(*this, Target, Args); 2068 TC = new toolchains::Linux(*this, Target, Args);
2064 break; 2069 break;
2065 case llvm::Triple::NaCl: 2070 case llvm::Triple::NaCl:
2066 TC = new toolchains::NaCl_TC(*this, Target, Args); 2071 if (Target.getArch() == llvm::Triple::le32)
2072 TC = new toolchains::PNaClToolChain(*this, Target, Args);
2073 else
2074 TC = new toolchains::NaCl_TC(*this, Target, Args);
2067 break; 2075 break;
2068 case llvm::Triple::Solaris: 2076 case llvm::Triple::Solaris:
2069 TC = new toolchains::Solaris(*this, Target, Args); 2077 TC = new toolchains::Solaris(*this, Target, Args);
2070 break; 2078 break;
2071 case llvm::Triple::Win32: 2079 case llvm::Triple::Win32:
2072 switch (Target.getEnvironment()) { 2080 switch (Target.getEnvironment()) {
2073 default: 2081 default:
2074 if (Target.isOSBinFormatELF()) 2082 if (Target.isOSBinFormatELF())
2075 TC = new toolchains::Generic_ELF(*this, Target, Args); 2083 TC = new toolchains::Generic_ELF(*this, Target, Args);
2076 else if (Target.isOSBinFormatMachO()) 2084 else if (Target.isOSBinFormatMachO())
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 } else { 2197 } else {
2190 ExcludedFlagsBitmask |= options::CLOption; 2198 ExcludedFlagsBitmask |= options::CLOption;
2191 } 2199 }
2192 2200
2193 return std::make_pair(IncludedFlagsBitmask, ExcludedFlagsBitmask); 2201 return std::make_pair(IncludedFlagsBitmask, ExcludedFlagsBitmask);
2194 } 2202 }
2195 2203
2196 bool clang::driver::isOptimizationLevelFast(const llvm::opt::ArgList &Args) { 2204 bool clang::driver::isOptimizationLevelFast(const llvm::opt::ArgList &Args) {
2197 return Args.hasFlag(options::OPT_Ofast, options::OPT_O_Group, false); 2205 return Args.hasFlag(options::OPT_Ofast, options::OPT_O_Group, false);
2198 } 2206 }
OLDNEW
« no previous file with comments | « lib/Basic/Targets.cpp ('k') | lib/Driver/ToolChains.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698