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

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

Issue 887223008: Rebased localmods in clang to 223109. (Closed)
Patch Set: Created 5 years, 10 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/Driver/ToolChains.h ('k') | lib/Driver/Tools.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 //===--- ToolChains.cpp - ToolChain Implementations -----------------------===// 1 //===--- ToolChains.cpp - ToolChain Implementations -----------------------===//
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 "ToolChains.h" 10 #include "ToolChains.h"
(...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after
2073 } 2073 }
2074 2074
2075 void Generic_ELF::addClangTargetOptions(const ArgList &DriverArgs, 2075 void Generic_ELF::addClangTargetOptions(const ArgList &DriverArgs,
2076 ArgStringList &CC1Args) const { 2076 ArgStringList &CC1Args) const {
2077 const Generic_GCC::GCCVersion &V = GCCInstallation.getVersion(); 2077 const Generic_GCC::GCCVersion &V = GCCInstallation.getVersion();
2078 bool UseInitArrayDefault = 2078 bool UseInitArrayDefault =
2079 getTriple().getArch() == llvm::Triple::aarch64 || 2079 getTriple().getArch() == llvm::Triple::aarch64 ||
2080 getTriple().getArch() == llvm::Triple::aarch64_be || 2080 getTriple().getArch() == llvm::Triple::aarch64_be ||
2081 (getTriple().getOS() == llvm::Triple::Linux && 2081 (getTriple().getOS() == llvm::Triple::Linux &&
2082 (!V.isOlderThan(4, 7, 0) || 2082 (!V.isOlderThan(4, 7, 0) ||
2083 getTriple().getEnvironment() == llvm::Triple::Android)); 2083 getTriple().getEnvironment() == llvm::Triple::Android)) ||
2084 getTriple().getOS() == llvm::Triple::NaCl; // @LOCALMOD
2084 2085
2085 if (DriverArgs.hasFlag(options::OPT_fuse_init_array, 2086 if (DriverArgs.hasFlag(options::OPT_fuse_init_array,
2086 options::OPT_fno_use_init_array, 2087 options::OPT_fno_use_init_array,
2087 UseInitArrayDefault)) 2088 UseInitArrayDefault))
2088 CC1Args.push_back("-fuse-init-array"); 2089 CC1Args.push_back("-fuse-init-array");
2089 } 2090 }
2090 2091
2091 /// Hexagon Toolchain 2092 /// Hexagon Toolchain
2092 2093
2093 std::string Hexagon_TC::GetGnuDir(const std::string &InstalledDir, 2094 std::string Hexagon_TC::GetGnuDir(const std::string &InstalledDir,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2296 case 3: 2297 case 3:
2297 return "v3"; 2298 return "v3";
2298 case 2: 2299 case 2:
2299 return "v2"; 2300 return "v2";
2300 case 1: 2301 case 1:
2301 return "v1"; 2302 return "v1";
2302 } 2303 }
2303 } 2304 }
2304 // End Hexagon 2305 // End Hexagon
2305 2306
2307 // @LOCALMOD-START
2308 /// NaCl Toolchain
2309 NaCl_TC::NaCl_TC(const Driver &D, const llvm::Triple &Triple,
2310 const ArgList &Args)
2311 : Generic_ELF(D, Triple, Args) {
2312
2313 // Remove paths added by Generic_GCC. NaCl Toolchain cannot use the
2314 // default paths, and must instead only use the paths provided
2315 // with this toolchain based on architecture.
2316 path_list& file_paths = getFilePaths();
2317 path_list& prog_paths = getProgramPaths();
2318
2319 file_paths.clear();
2320 prog_paths.clear();
2321
2322 // Path for library files (libc.a, ...)
2323 std::string FilePath(getDriver().Dir + "/../");
2324
2325 // Path for tools (clang, ld, etc..)
2326 std::string ProgPath(getDriver().Dir + "/../");
2327
2328 // Path for toolchain libraries (libgcc.a, ...)
2329 std::string ToolPath(getDriver().ResourceDir + "/lib/");
2330
2331 switch(Triple.getArch()) {
2332 case llvm::Triple::x86: {
2333 file_paths.push_back(FilePath + "x86_64-nacl/lib32");
2334 file_paths.push_back(FilePath + "x86_64-nacl/usr/lib32");
2335 prog_paths.push_back(ProgPath + "x86_64-nacl/bin");
2336 file_paths.push_back(ToolPath + "i686-nacl");
2337 break;
2338 }
2339 case llvm::Triple::x86_64: {
2340 file_paths.push_back(FilePath + "x86_64-nacl/lib");
2341 file_paths.push_back(FilePath + "x86_64-nacl/usr/lib");
2342 prog_paths.push_back(ProgPath + "x86_64-nacl/bin");
2343 file_paths.push_back(ToolPath + "x86_64-nacl");
2344 break;
2345 }
2346 case llvm::Triple::arm: {
2347 file_paths.push_back(FilePath + "arm-nacl/lib");
2348 file_paths.push_back(FilePath + "arm-nacl/usr/lib");
2349 prog_paths.push_back(ProgPath + "arm-nacl/bin");
2350 file_paths.push_back(ToolPath + "arm-nacl");
2351 break;
2352 }
2353 default:
2354 break;
2355 }
2356
2357 // Use provided linker, not system linker
2358 Linker = GetProgramPath("ld");
2359 NaClArmMacrosPath = GetFilePath("nacl-arm-macros.s");
2360 }
2361
2362 void NaCl_TC::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
2363 ArgStringList &CC1Args) const {
2364 const Driver &D = getDriver();
2365 if (DriverArgs.hasArg(options::OPT_nostdinc))
2366 return;
2367
2368 if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
2369 SmallString<128> P(D.ResourceDir);
2370 llvm::sys::path::append(P, "include");
2371 addSystemInclude(DriverArgs, CC1Args, P.str());
2372 }
2373
2374 if (DriverArgs.hasArg(options::OPT_nostdlibinc))
2375 return;
2376
2377 SmallString<128> P(D.Dir + "/../");
2378 if (getTriple().getArch() == llvm::Triple::arm) {
2379 llvm::sys::path::append(P, "arm-nacl/usr/include");
2380 } else if (getTriple().getArch() == llvm::Triple::x86) {
2381 llvm::sys::path::append(P, "x86_64-nacl/usr/include");
2382 } else if (getTriple().getArch() == llvm::Triple::x86_64) {
2383 llvm::sys::path::append(P, "x86_64-nacl/usr/include");
2384 } else {
2385 return;
2386 }
2387
2388 addSystemInclude(DriverArgs, CC1Args, P.str());
2389 llvm::sys::path::remove_filename(P);
2390 llvm::sys::path::remove_filename(P);
2391 llvm::sys::path::append(P, "include");
2392 addSystemInclude(DriverArgs, CC1Args, P.str());
2393 }
2394
2395 void NaCl_TC::AddCXXStdlibLibArgs(const ArgList &Args,
2396 ArgStringList &CmdArgs) const {
2397 // Allow and ignore -stdlib=libc++ without warning, but not libstdc++
2398 GetCXXStdlibType(Args);
2399 CmdArgs.push_back("-lc++");
2400 }
2401
2402 void NaCl_TC::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
2403 ArgStringList &CC1Args) const {
2404 const Driver &D = getDriver();
2405 if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
2406 DriverArgs.hasArg(options::OPT_nostdincxx))
2407 return;
2408
2409 // Allow and ignore -stdlib=libc++ without warning, but not libstdc++
2410 GetCXXStdlibType(DriverArgs);
2411
2412 if (getTriple().getArch() == llvm::Triple::arm) {
2413 SmallString<128> P(D.Dir + "/../");
2414 llvm::sys::path::append(P, "arm-nacl/include/c++/v1");
2415 addSystemInclude(DriverArgs, CC1Args, P.str());
2416 } else if (getTriple().getArch() == llvm::Triple::x86) {
2417 SmallString<128> P(D.Dir + "/../");
2418 llvm::sys::path::append(P, "x86_64-nacl/include/c++/v1");
2419 addSystemInclude(DriverArgs, CC1Args, P.str());
2420 } else if (getTriple().getArch() == llvm::Triple::x86_64) {
2421 SmallString<128> P(D.Dir + "/../");
2422 llvm::sys::path::append(P, "x86_64-nacl/include/c++/v1");
2423 addSystemInclude(DriverArgs, CC1Args, P.str());
2424 }
2425 }
2426
2427 ToolChain::CXXStdlibType NaCl_TC::GetCXXStdlibType(const ArgList &Args) const {
2428 if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
2429 StringRef Value = A->getValue();
2430 if (Value == "libc++")
2431 return ToolChain::CST_Libcxx;
2432 getDriver().Diag(diag::err_drv_invalid_stdlib_name)
2433 << A->getAsString(Args);
2434 }
2435
2436 return ToolChain::CST_Libcxx;
2437 }
2438
2439 std::string NaCl_TC::ComputeEffectiveClangTriple(
2440 const ArgList &Args, types::ID InputType) const {
2441 llvm::Triple TheTriple(ComputeLLVMTriple(Args, InputType));
2442 if (TheTriple.getArch() == llvm::Triple::arm &&
2443 TheTriple.getEnvironment() == llvm::Triple::UnknownEnvironment)
2444 TheTriple.setEnvironment(llvm::Triple::GNUEABIHF);
2445 return TheTriple.getTriple();
2446 }
2447
2448 Tool *NaCl_TC::buildLinker() const {
2449 return new tools::nacltools::Link(*this);
2450 }
2451
2452 Tool *NaCl_TC::buildAssembler() const {
2453 if (getTriple().getArch() == llvm::Triple::arm)
2454 return new tools::nacltools::AssembleARM(*this);
2455 return new tools::gnutools::Assemble(*this);
2456 }
2457 // End NaCl
2458 // @LOCALMOD-END
2459
2306 /// TCEToolChain - A tool chain using the llvm bitcode tools to perform 2460 /// TCEToolChain - A tool chain using the llvm bitcode tools to perform
2307 /// all subcommands. See http://tce.cs.tut.fi for our peculiar target. 2461 /// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
2308 /// Currently does not support anything else but compilation. 2462 /// Currently does not support anything else but compilation.
2309 2463
2310 TCEToolChain::TCEToolChain(const Driver &D, const llvm::Triple& Triple, 2464 TCEToolChain::TCEToolChain(const Driver &D, const llvm::Triple& Triple,
2311 const ArgList &Args) 2465 const ArgList &Args)
2312 : ToolChain(D, Triple, Args) { 2466 : ToolChain(D, Triple, Args) {
2313 // Path mangling to find libexec 2467 // Path mangling to find libexec
2314 std::string Path(getDriver().Dir); 2468 std::string Path(getDriver().Dir);
2315 2469
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
3477 StringRef(cl_include_dir).split(Dirs, StringRef(EnvPathSeparatorStr)); 3631 StringRef(cl_include_dir).split(Dirs, StringRef(EnvPathSeparatorStr));
3478 ArrayRef<StringRef> DirVec(Dirs); 3632 ArrayRef<StringRef> DirVec(Dirs);
3479 addSystemIncludes(DriverArgs, CC1Args, DirVec); 3633 addSystemIncludes(DriverArgs, CC1Args, DirVec);
3480 } 3634 }
3481 } 3635 }
3482 3636
3483 void XCore::AddCXXStdlibLibArgs(const ArgList &Args, 3637 void XCore::AddCXXStdlibLibArgs(const ArgList &Args,
3484 ArgStringList &CmdArgs) const { 3638 ArgStringList &CmdArgs) const {
3485 // We don't output any lib args. This is handled by xcc. 3639 // We don't output any lib args. This is handled by xcc.
3486 } 3640 }
OLDNEW
« no previous file with comments | « lib/Driver/ToolChains.h ('k') | lib/Driver/Tools.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698