Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 417541
Collapse All | Expand All

(-)a/a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp (+155 lines)
Lines 2305-2310 void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, Link Here
2305
  }
2305
  }
2306
}
2306
}
2307
2307
2308
void FreeBSD::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
2309
                                      ArgStringList &CC1Args) const {
2310
  const Driver &D = getDriver();
2311
2312
  if (DriverArgs.hasArg(options::OPT_nostdinc))
2313
    return;
2314
2315
  if (!DriverArgs.hasArg(options::OPT_nostdlibinc))
2316
    addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/usr/local/include");
2317
2318
  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
2319
    llvm::sys::Path P(D.ResourceDir);
2320
    P.appendComponent("include");
2321
    addSystemInclude(DriverArgs, CC1Args, P.str());
2322
  }
2323
2324
  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
2325
    return;
2326
2327
  // Check for configure-time C include directories.
2328
  StringRef CIncludeDirs(C_INCLUDE_DIRS);
2329
  if (CIncludeDirs != "") {
2330
    SmallVector<StringRef, 5> dirs;
2331
    CIncludeDirs.split(dirs, ":");
2332
    for (SmallVectorImpl<StringRef>::iterator I = dirs.begin(), E = dirs.end();
2333
         I != E; ++I) {
2334
      StringRef Prefix = llvm::sys::path::is_absolute(*I) ? D.SysRoot : "";
2335
      addExternCSystemInclude(DriverArgs, CC1Args, Prefix + *I);
2336
    }
2337
    return;
2338
  }
2339
2340
  // Lacking those, try to detect the correct set of system includes for the
2341
  // target triple.
2342
2343
  // Implement generic Debian multiarch support.
2344
  const StringRef X86_64MultiarchIncludeDirs[] = {
2345
    "/usr/include/x86_64-linux-gnu",
2346
2347
    // FIXME: These are older forms of multiarch. It's not clear that they're
2348
    // in use in any released version of Debian, so we should consider
2349
    // removing them.
2350
    "/usr/include/i686-linux-gnu/64",
2351
    "/usr/include/i486-linux-gnu/64"
2352
  };
2353
  const StringRef X86MultiarchIncludeDirs[] = {
2354
    "/usr/include/i386-linux-gnu",
2355
2356
    // FIXME: These are older forms of multiarch. It's not clear that they're
2357
    // in use in any released version of Debian, so we should consider
2358
    // removing them.
2359
    "/usr/include/x86_64-linux-gnu/32",
2360
    "/usr/include/i686-linux-gnu",
2361
    "/usr/include/i486-linux-gnu"
2362
  };
2363
  const StringRef ARMMultiarchIncludeDirs[] = {
2364
    "/usr/include/arm-linux-gnueabi"
2365
  };
2366
  const StringRef MIPSMultiarchIncludeDirs[] = {
2367
    "/usr/include/mips-linux-gnu"
2368
  };
2369
  const StringRef MIPSELMultiarchIncludeDirs[] = {
2370
    "/usr/include/mipsel-linux-gnu"
2371
  };
2372
  const StringRef PPCMultiarchIncludeDirs[] = {
2373
    "/usr/include/powerpc-linux-gnu"
2374
  };
2375
  const StringRef PPC64MultiarchIncludeDirs[] = {
2376
    "/usr/include/powerpc64-linux-gnu"
2377
  };
2378
  ArrayRef<StringRef> MultiarchIncludeDirs;
2379
  if (getTriple().getArch() == llvm::Triple::x86_64) {
2380
    MultiarchIncludeDirs = X86_64MultiarchIncludeDirs;
2381
  } else if (getTriple().getArch() == llvm::Triple::x86) {
2382
    MultiarchIncludeDirs = X86MultiarchIncludeDirs;
2383
  } else if (getTriple().getArch() == llvm::Triple::arm) {
2384
    MultiarchIncludeDirs = ARMMultiarchIncludeDirs;
2385
  } else if (getTriple().getArch() == llvm::Triple::mips) {
2386
    MultiarchIncludeDirs = MIPSMultiarchIncludeDirs;
2387
  } else if (getTriple().getArch() == llvm::Triple::mipsel) {
2388
    MultiarchIncludeDirs = MIPSELMultiarchIncludeDirs;
2389
  } else if (getTriple().getArch() == llvm::Triple::ppc) {
2390
    MultiarchIncludeDirs = PPCMultiarchIncludeDirs;
2391
  } else if (getTriple().getArch() == llvm::Triple::ppc64) {
2392
    MultiarchIncludeDirs = PPC64MultiarchIncludeDirs;
2393
  }
2394
  for (ArrayRef<StringRef>::iterator I = MultiarchIncludeDirs.begin(),
2395
                                     E = MultiarchIncludeDirs.end();
2396
       I != E; ++I) {
2397
    if (llvm::sys::fs::exists(D.SysRoot + *I)) {
2398
      addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + *I);
2399
      break;
2400
    }
2401
  }
2402
2403
  if (getTriple().getOS() == llvm::Triple::RTEMS)
2404
    return;
2405
2406
  // Add an include of '/include' directly. This isn't provided by default by
2407
  // system GCCs, but is often used with cross-compiling GCCs, and harmless to
2408
  // add even when Clang is acting as-if it were a system compiler.
2409
  addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include");
2410
2411
  addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/usr/include");
2412
}
2413
2414
/// \brief Helper to add the thre variant paths for a libstdc++ installation.
2415
/*static*/ bool FreeBSD::addLibStdCXXIncludePaths(Twine Base, Twine TargetArchDir,
2416
                                                const ArgList &DriverArgs,
2417
                                                ArgStringList &CC1Args) {
2418
  if (!llvm::sys::fs::exists(Base))
2419
    return false;
2420
  addSystemInclude(DriverArgs, CC1Args, Base);
2421
  addSystemInclude(DriverArgs, CC1Args, Base + "/" + TargetArchDir);
2422
  addSystemInclude(DriverArgs, CC1Args, Base + "/backward");
2423
  return true;
2424
}
2425
2426
void FreeBSD::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
2427
                                         ArgStringList &CC1Args) const {
2428
  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
2429
      DriverArgs.hasArg(options::OPT_nostdincxx))
2430
    return;
2431
2432
  // Check if libc++ has been enabled and provide its include paths if so.
2433
  if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) {
2434
    // libc++ is always installed at a fixed path on Linux currently.
2435
    addSystemInclude(DriverArgs, CC1Args,
2436
                     getDriver().SysRoot + "/usr/include/c++/v1");
2437
    return;
2438
  }
2439
2440
  // We need a detected GCC installation on Linux to provide libstdc++'s
2441
  // headers. We handled the libc++ case above.
2442
  if (!GCCInstallation.isValid())
2443
    return;
2444
2445
  // By default, look for the C++ headers in an include directory adjacent to
2446
  // the lib directory of the GCC installation. Note that this is expect to be
2447
  // equivalent to '/usr/include/c++/X.Y' in almost all cases.
2448
  StringRef LibDir = GCCInstallation.getParentLibPath();
2449
  StringRef InstallDir = GCCInstallation.getInstallPath();
2450
  StringRef Version = GCCInstallation.getVersion();
2451
  if (!addLibStdCXXIncludePaths(LibDir + "/../include/c++/" + Version,
2452
                                (GCCInstallation.getTriple().str() +
2453
                                 GCCInstallation.getMultiarchSuffix()),
2454
                                DriverArgs, CC1Args)) {
2455
    // Gentoo is weird and places its headers inside the GCC install, so if the
2456
    // first attempt to find the headers fails, try this pattern.
2457
    addLibStdCXXIncludePaths(InstallDir + "/include/g++-v4",
2458
                             getDriver().DefaultTargetTriple,
2459
                             DriverArgs, CC1Args);
2460
  }
2461
}
2462
2308
/// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
2463
/// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
2309
2464
2310
DragonFly::DragonFly(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
2465
DragonFly::DragonFly(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
(-)a/a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.h (+10 lines)
Lines 489-494 public: Link Here
489
489
490
  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
490
  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
491
                           const ActionList &Inputs) const;
491
                           const ActionList &Inputs) const;
492
493
  virtual void AddClangSystemIncludeArgs(const ArgList &DriverArgs,
494
                                         ArgStringList &CC1Args) const;
495
  virtual void AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
496
                                            ArgStringList &CC1Args) const;
497
498
private:
499
  static bool addLibStdCXXIncludePaths(Twine Base, Twine TargetArchDir,
500
                                       const ArgList &DriverArgs,
501
                                       ArgStringList &CC1Args);
492
};
502
};
493
503
494
class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
504
class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {

Return to bug 417541