Ticket #55382: 9001-macports-libstdcxx.diff

File 9001-macports-libstdcxx.diff, 4.9 KB (added by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez), 7 years ago)
  • tools/clang/include/clang/Lex/HeaderSearchOptions.h

    old new  
    157157  /// Use libc++ instead of the default libstdc++.
    158158  unsigned UseLibcxx : 1;
    159159
     160  /// Use MacPorts libstdc++ instead of default system libstdc++.
     161  unsigned UseMacPortsLibstdcxx : 1;
     162
    160163  /// Whether header search information should be output as for -v.
    161164  unsigned Verbose : 1;
    162165
  • tools/clang/lib/Frontend/CompilerInvocation.cpp

    old new  
    10941094  Opts.UseBuiltinIncludes = !Args.hasArg(OPT_nobuiltininc);
    10951095  Opts.UseStandardSystemIncludes = !Args.hasArg(OPT_nostdsysteminc);
    10961096  Opts.UseStandardCXXIncludes = !Args.hasArg(OPT_nostdincxx);
    1097   if (const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
     1097  if (const Arg *A = Args.getLastArg(OPT_stdlib_EQ)) {
    10981098    Opts.UseLibcxx = (strcmp(A->getValue(), "libc++") == 0);
     1099    Opts.UseMacPortsLibstdcxx = (strcmp(A->getValue(), "macports-libstdc++") == 0);
     1100  }
    10991101  Opts.ResourceDir = Args.getLastArgValue(OPT_resource_dir);
    11001102  Opts.ModuleCachePath = Args.getLastArgValue(OPT_fmodules_cache_path);
    11011103  Opts.ModuleUserBuildPath = Args.getLastArgValue(OPT_fmodules_user_build_path);
  • tools/clang/lib/Frontend/InitHeaderSearch.cpp

    old new  
    108108#if defined(LLVM_ON_WIN32)
    109109  return !Path.empty() && llvm::sys::path::is_separator(Path[0]);
    110110#else
    111   return llvm::sys::path::is_absolute(Path);
     111  return llvm::sys::path::is_absolute(Path) && Path.find("@@MACPORTS_GCC_INCLUDE_DIR@@")!=0;
    112112#endif
    113113}
    114114
     
    337337
    338338    case llvm::Triple::ppc:
    339339    case llvm::Triple::ppc64:
     340      if (HSOpts.UseMacPortsLibstdcxx) {
     341        AddGnuCPlusPlusIncludePaths("@@MACPORTS_GCC_INCLUDE_DIR@@",
     342                                    "@@MACPORTS_HOST_NAME@@", "@@MACPORTS_GCC_SUBDIRECTORY_ppc@@", "@@MACPORTS_GCC_SUBDIRECTORY_ppc64@@",
     343                                    triple);
     344      }
    340345      AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
    341346                                  "powerpc-apple-darwin10", "", "ppc64",
    342347                                  triple);
     
    347352
    348353    case llvm::Triple::x86:
    349354    case llvm::Triple::x86_64:
     355      if (HSOpts.UseMacPortsLibstdcxx) {
     356        AddGnuCPlusPlusIncludePaths("@@MACPORTS_GCC_INCLUDE_DIR@@",
     357                                    "@@MACPORTS_HOST_NAME@@", "@@MACPORTS_GCC_SUBDIRECTORY_i386@@", "@@MACPORTS_GCC_SUBDIRECTORY_x86_64@@", triple);
     358      }
    350359      AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
    351360                                  "i686-apple-darwin10", "", "x86_64", triple);
    352361      AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
  • tools/clang/include/clang/Driver/ToolChain.h

    old new  
    4646
    4747  enum CXXStdlibType {
    4848    CST_Libcxx,
    49     CST_Libstdcxx
     49    CST_Libstdcxx,
     50    CST_MacPortsLibstdcxx
    5051  };
    5152
    5253  enum RuntimeLibType {
  • tools/clang/lib/Driver/ToolChains.cpp

    old new  
    572572    CmdArgs.push_back("-lc++");
    573573    break;
    574574
    575   case ToolChain::CST_Libstdcxx: {
     575  case ToolChain::CST_Libstdcxx:
     576  case ToolChain::CST_MacPortsLibstdcxx: {
     577    if (Type==ToolChain::CST_MacPortsLibstdcxx && llvm::sys::fs::exists("@@MACPORTS_libstdc++@@")) {
     578      CmdArgs.push_back("@@MACPORTS_libstdc++@@");
     579      return;
     580    }
     581
    576582    // Unfortunately, -lstdc++ doesn't always exist in the standard search path;
    577583    // it was previously found in the gcc lib dir. However, for all the Darwin
    578584    // platforms we care about it was -lstdc++.6, so we search for that
     
    22432249    return ToolChain::CST_Libstdcxx;
    22442250
    22452251  StringRef Value = A->getValue();
     2252  if (Value == "macports-libstdc++")
     2253      return ToolChain::CST_MacPortsLibstdcxx;
    22462254  if (Value != "libstdc++") {
    22472255    getDriver().Diag(diag::err_drv_invalid_stdlib_name) << A->getAsString(Args);
    22482256  }
  • tools/clang/lib/Driver/ToolChain.cpp

    old new  
    383383      return ToolChain::CST_Libcxx;
    384384    if (Value == "libstdc++")
    385385      return ToolChain::CST_Libstdcxx;
     386    if (Value == "macports-libstdc++")
     387      return ToolChain::CST_MacPortsLibstdcxx;
    386388    getDriver().Diag(diag::err_drv_invalid_stdlib_name)
    387389      << A->getAsString(Args);
    388390  }
     
    455457    break;
    456458
    457459  case ToolChain::CST_Libstdcxx:
     460  case ToolChain::CST_MacPortsLibstdcxx:
    458461    CmdArgs.push_back("-lstdc++");
    459462    break;
    460463  }