Index: stable/10/contrib/llvm/patches/patch-r257109-add-CC-aliases.diff =================================================================== --- stable/10/contrib/llvm/patches/patch-r257109-add-CC-aliases.diff (revision 293781) +++ stable/10/contrib/llvm/patches/patch-r257109-add-CC-aliases.diff (nonexistent) @@ -1,25 +0,0 @@ -This patch adds "CC" and "clang-CC" to the list of program name aliases which -invoke the C++ compiler. - -Introduced here: http://svnweb.freebsd.org/changeset/base/257109 - -Index: tools/clang/tools/driver/driver.cpp -=================================================================== ---- tools/clang/tools/driver/driver.cpp -+++ tools/clang/tools/driver/driver.cpp -@@ -215,6 +215,7 @@ static void ParseProgName(SmallVectorImpl &SavedStrings, StringRef S) { return SavedStrings.insert(S).first->c_str(); } /// ApplyQAOverride - Apply a list of edits to the input argument lists. /// /// The input string is a space separate list of edits to perform, /// they are applied in order to the input argument lists. Edits /// should be one of the following forms: /// /// '#': Silence information about the changes to the command line arguments. /// /// '^': Add FOO as a new argument at the beginning of the command line. /// /// '+': Add FOO as a new argument at the end of the command line. /// /// 's/XXX/YYY/': Substitute the regular expression XXX with YYY in the command /// line. /// /// 'xOPTION': Removes all instances of the literal argument OPTION. /// /// 'XOPTION': Removes all instances of the literal argument OPTION, /// and the following argument. /// /// 'Ox': Removes all flags matching 'O' or 'O[sz0-9]' and adds 'Ox' /// at the end of the command line. /// /// \param OS - The stream to write edit information to. /// \param Args - The vector of command line arguments. /// \param Edit - The override command to perform. /// \param SavedStrings - Set to use for storing string representations. static void ApplyOneQAOverride(raw_ostream &OS, SmallVectorImpl &Args, StringRef Edit, std::set &SavedStrings) { // This does not need to be efficient. if (Edit[0] == '^') { const char *Str = SaveStringInSet(SavedStrings, Edit.substr(1)); OS << "### Adding argument " << Str << " at beginning\n"; Args.insert(Args.begin() + 1, Str); } else if (Edit[0] == '+') { const char *Str = SaveStringInSet(SavedStrings, Edit.substr(1)); OS << "### Adding argument " << Str << " at end\n"; Args.push_back(Str); } else if (Edit[0] == 's' && Edit[1] == '/' && Edit.endswith("/") && Edit.slice(2, Edit.size()-1).find('/') != StringRef::npos) { StringRef MatchPattern = Edit.substr(2).split('/').first; StringRef ReplPattern = Edit.substr(2).split('/').second; ReplPattern = ReplPattern.slice(0, ReplPattern.size()-1); for (unsigned i = 1, e = Args.size(); i != e; ++i) { std::string Repl = llvm::Regex(MatchPattern).sub(ReplPattern, Args[i]); if (Repl != Args[i]) { OS << "### Replacing '" << Args[i] << "' with '" << Repl << "'\n"; Args[i] = SaveStringInSet(SavedStrings, Repl); } } } else if (Edit[0] == 'x' || Edit[0] == 'X') { std::string Option = Edit.substr(1, std::string::npos); for (unsigned i = 1; i < Args.size();) { if (Option == Args[i]) { OS << "### Deleting argument " << Args[i] << '\n'; Args.erase(Args.begin() + i); if (Edit[0] == 'X') { if (i < Args.size()) { OS << "### Deleting argument " << Args[i] << '\n'; Args.erase(Args.begin() + i); } else OS << "### Invalid X edit, end of command line!\n"; } } else ++i; } } else if (Edit[0] == 'O') { for (unsigned i = 1; i < Args.size();) { const char *A = Args[i]; if (A[0] == '-' && A[1] == 'O' && (A[2] == '\0' || (A[3] == '\0' && (A[2] == 's' || A[2] == 'z' || ('0' <= A[2] && A[2] <= '9'))))) { OS << "### Deleting argument " << Args[i] << '\n'; Args.erase(Args.begin() + i); } else ++i; } OS << "### Adding argument " << Edit << " at end\n"; Args.push_back(SaveStringInSet(SavedStrings, '-' + Edit.str())); } else { OS << "### Unrecognized edit: " << Edit << "\n"; } } /// ApplyQAOverride - Apply a comma separate list of edits to the /// input argument lists. See ApplyOneQAOverride. static void ApplyQAOverride(SmallVectorImpl &Args, const char *OverrideStr, std::set &SavedStrings) { raw_ostream *OS = &llvm::errs(); if (OverrideStr[0] == '#') { ++OverrideStr; OS = &llvm::nulls(); } *OS << "### QA_OVERRIDE_GCC3_OPTIONS: " << OverrideStr << "\n"; // This does not need to be efficient. const char *S = OverrideStr; while (*S) { const char *End = ::strchr(S, ' '); if (!End) End = S + strlen(S); if (End != S) ApplyOneQAOverride(*OS, Args, std::string(S, End), SavedStrings); S = End; if (*S != '\0') ++S; } } extern int cc1_main(const char **ArgBegin, const char **ArgEnd, const char *Argv0, void *MainAddr); extern int cc1as_main(const char **ArgBegin, const char **ArgEnd, const char *Argv0, void *MainAddr); static void ParseProgName(SmallVectorImpl &ArgVector, std::set &SavedStrings, Driver &TheDriver) { // Try to infer frontend type and default target from the program name. // suffixes[] contains the list of known driver suffixes. // Suffixes are compared against the program name in order. // If there is a match, the frontend type is updated as necessary (CPP/C++). // If there is no match, a second round is done after stripping the last // hyphen and everything following it. This allows using something like // "clang++-2.9". // If there is a match in either the first or second round, // the function tries to identify a target as prefix. E.g. // "x86_64-linux-clang" as interpreted as suffix "clang" with // target prefix "x86_64-linux". If such a target prefix is found, // is gets added via -target as implicit first argument. static const struct { const char *Suffix; const char *ModeFlag; } suffixes [] = { { "clang", 0 }, { "clang++", "--driver-mode=g++" }, - { "clang-CC", "--driver-mode=g++" }, { "clang-c++", "--driver-mode=g++" }, { "clang-cc", 0 }, { "clang-cpp", "--driver-mode=cpp" }, { "clang-g++", "--driver-mode=g++" }, { "clang-gcc", 0 }, { "clang-cl", "--driver-mode=cl" }, - { "CC", "--driver-mode=g++" }, { "cc", 0 }, { "cpp", "--driver-mode=cpp" }, { "cl" , "--driver-mode=cl" }, { "++", "--driver-mode=g++" }, }; std::string ProgName(llvm::sys::path::stem(ArgVector[0])); #ifdef _WIN32 std::transform(ProgName.begin(), ProgName.end(), ProgName.begin(), toLowercase); #endif StringRef ProgNameRef(ProgName); StringRef Prefix; for (int Components = 2; Components; --Components) { bool FoundMatch = false; size_t i; for (i = 0; i < sizeof(suffixes) / sizeof(suffixes[0]); ++i) { if (ProgNameRef.endswith(suffixes[i].Suffix)) { FoundMatch = true; SmallVectorImpl::iterator it = ArgVector.begin(); if (it != ArgVector.end()) ++it; if (suffixes[i].ModeFlag) ArgVector.insert(it, suffixes[i].ModeFlag); break; } } if (FoundMatch) { StringRef::size_type LastComponent = ProgNameRef.rfind('-', ProgNameRef.size() - strlen(suffixes[i].Suffix)); if (LastComponent != StringRef::npos) Prefix = ProgNameRef.slice(0, LastComponent); break; } StringRef::size_type LastComponent = ProgNameRef.rfind('-'); if (LastComponent == StringRef::npos) break; ProgNameRef = ProgNameRef.slice(0, LastComponent); } if (Prefix.empty()) return; std::string IgnoredError; if (llvm::TargetRegistry::lookupTarget(Prefix, IgnoredError)) { SmallVectorImpl::iterator it = ArgVector.begin(); if (it != ArgVector.end()) ++it; const char* Strings[] = { SaveStringInSet(SavedStrings, std::string("-target")), SaveStringInSet(SavedStrings, Prefix) }; ArgVector.insert(it, Strings, Strings + llvm::array_lengthof(Strings)); } } namespace { class StringSetSaver : public llvm::cl::StringSaver { public: StringSetSaver(std::set &Storage) : Storage(Storage) {} const char *SaveString(const char *Str) LLVM_OVERRIDE { return SaveStringInSet(Storage, Str); } private: std::set &Storage; }; } int main(int argc_, const char **argv_) { llvm::sys::PrintStackTraceOnErrorSignal(); llvm::PrettyStackTraceProgram X(argc_, argv_); SmallVector argv; llvm::SpecificBumpPtrAllocator ArgAllocator; llvm::error_code EC = llvm::sys::Process::GetArgumentVector( argv, llvm::ArrayRef(argv_, argc_), ArgAllocator); if (EC) { llvm::errs() << "error: couldn't get arguments: " << EC.message() << '\n'; return 1; } std::set SavedStrings; StringSetSaver Saver(SavedStrings); llvm::cl::ExpandResponseFiles(Saver, llvm::cl::TokenizeGNUCommandLine, argv); // Handle -cc1 integrated tools. if (argv.size() > 1 && StringRef(argv[1]).startswith("-cc1")) { StringRef Tool = argv[1] + 4; if (Tool == "") return cc1_main(argv.data()+2, argv.data()+argv.size(), argv[0], (void*) (intptr_t) GetExecutablePath); if (Tool == "as") return cc1as_main(argv.data()+2, argv.data()+argv.size(), argv[0], (void*) (intptr_t) GetExecutablePath); // Reject unknown tools. llvm::errs() << "error: unknown integrated tool '" << Tool << "'\n"; return 1; } bool CanonicalPrefixes = true; for (int i = 1, size = argv.size(); i < size; ++i) { if (StringRef(argv[i]) == "-no-canonical-prefixes") { CanonicalPrefixes = false; break; } } // Handle QA_OVERRIDE_GCC3_OPTIONS and CCC_ADD_ARGS, used for editing a // command line behind the scenes. if (const char *OverrideStr = ::getenv("QA_OVERRIDE_GCC3_OPTIONS")) { // FIXME: Driver shouldn't take extra initial argument. ApplyQAOverride(argv, OverrideStr, SavedStrings); } std::string Path = GetExecutablePath(argv[0], CanonicalPrefixes); IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions; { OwningPtr Opts(createDriverOptTable()); unsigned MissingArgIndex, MissingArgCount; OwningPtr Args(Opts->ParseArgs(argv.begin()+1, argv.end(), MissingArgIndex, MissingArgCount)); // We ignore MissingArgCount and the return value of ParseDiagnosticArgs. // Any errors that would be diagnosed here will also be diagnosed later, // when the DiagnosticsEngine actually exists. (void) ParseDiagnosticArgs(*DiagOpts, *Args); } // Now we can create the DiagnosticsEngine with a properly-filled-out // DiagnosticOptions instance. TextDiagnosticPrinter *DiagClient = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts); // If the clang binary happens to be named cl.exe for compatibility reasons, // use clang-cl.exe as the prefix to avoid confusion between clang and MSVC. StringRef ExeBasename(llvm::sys::path::filename(Path)); if (ExeBasename.equals_lower("cl.exe")) ExeBasename = "clang-cl.exe"; DiagClient->setPrefix(ExeBasename); IntrusiveRefCntPtr DiagID(new DiagnosticIDs()); DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagClient); ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false); Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), "a.out", Diags); // Attempt to find the original path used to invoke the driver, to determine // the installed path. We do this manually, because we want to support that // path being a symlink. { SmallString<128> InstalledPath(argv[0]); // Do a PATH lookup, if there are no directory components. if (llvm::sys::path::filename(InstalledPath) == InstalledPath) { std::string Tmp = llvm::sys::FindProgramByName( llvm::sys::path::filename(InstalledPath.str())); if (!Tmp.empty()) InstalledPath = Tmp; } llvm::sys::fs::make_absolute(InstalledPath); InstalledPath = llvm::sys::path::parent_path(InstalledPath); bool exists; if (!llvm::sys::fs::exists(InstalledPath.str(), exists) && exists) TheDriver.setInstalledDir(InstalledPath); } llvm::InitializeAllTargets(); ParseProgName(argv, SavedStrings, TheDriver); // Handle CC_PRINT_OPTIONS and CC_PRINT_OPTIONS_FILE. TheDriver.CCPrintOptions = !!::getenv("CC_PRINT_OPTIONS"); if (TheDriver.CCPrintOptions) TheDriver.CCPrintOptionsFilename = ::getenv("CC_PRINT_OPTIONS_FILE"); // Handle CC_PRINT_HEADERS and CC_PRINT_HEADERS_FILE. TheDriver.CCPrintHeaders = !!::getenv("CC_PRINT_HEADERS"); if (TheDriver.CCPrintHeaders) TheDriver.CCPrintHeadersFilename = ::getenv("CC_PRINT_HEADERS_FILE"); // Handle CC_LOG_DIAGNOSTICS and CC_LOG_DIAGNOSTICS_FILE. TheDriver.CCLogDiagnostics = !!::getenv("CC_LOG_DIAGNOSTICS"); if (TheDriver.CCLogDiagnostics) TheDriver.CCLogDiagnosticsFilename = ::getenv("CC_LOG_DIAGNOSTICS_FILE"); OwningPtr C(TheDriver.BuildCompilation(argv)); int Res = 0; SmallVector, 4> FailingCommands; if (C.get()) Res = TheDriver.ExecuteCompilation(*C, FailingCommands); // Force a crash to test the diagnostics. if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH")) { Diags.Report(diag::err_drv_force_crash) << "FORCE_CLANG_DIAGNOSTICS_CRASH"; const Command *FailingCommand = 0; FailingCommands.push_back(std::make_pair(-1, FailingCommand)); } for (SmallVectorImpl< std::pair >::iterator it = FailingCommands.begin(), ie = FailingCommands.end(); it != ie; ++it) { int CommandRes = it->first; const Command *FailingCommand = it->second; if (!Res) Res = CommandRes; // If result status is < 0, then the driver command signalled an error. // If result status is 70, then the driver command reported a fatal error. // In these cases, generate additional diagnostic information if possible. if (CommandRes < 0 || CommandRes == 70) { TheDriver.generateCompilationDiagnostics(*C, FailingCommand); break; } } // If any timers were active but haven't been destroyed yet, print their // results now. This happens in -disable-free mode. llvm::TimerGroup::printAll(llvm::errs()); llvm::llvm_shutdown(); #ifdef _WIN32 // Exit status should not be negative on Win32, unless abnormal termination. // Once abnormal termiation was caught, negative status should not be // propagated. if (Res < 0) Res = 1; #endif // If we have multiple failing commands, we return the result of the first // failing command. return Res; } Index: stable/10/usr.bin/clang/clang/CC.sh =================================================================== --- stable/10/usr.bin/clang/clang/CC.sh (nonexistent) +++ stable/10/usr.bin/clang/clang/CC.sh (revision 293782) @@ -0,0 +1,4 @@ +#!/bin/sh +# $FreeBSD$ +# This file is in the public domain. +exec /usr/bin/c++ "$@" Property changes on: stable/10/usr.bin/clang/clang/CC.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/10/usr.bin/clang/clang/Makefile =================================================================== --- stable/10/usr.bin/clang/clang/Makefile (revision 293781) +++ stable/10/usr.bin/clang/clang/Makefile (revision 293782) @@ -1,121 +1,123 @@ # $FreeBSD$ .include PROG_CXX=clang SRCDIR= tools/clang/tools/driver SRCS= cc1_main.cpp \ cc1as_main.cpp \ driver.cpp .if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= yes .endif LINKS= ${BINDIR}/clang ${BINDIR}/clang++ \ ${BINDIR}/clang ${BINDIR}/clang-cpp MLINKS= clang.1 clang++.1 \ clang.1 clang-cpp.1 .if ${MK_CLANG_IS_CC} != "no" +SCRIPTS=CC.sh +SCRIPTSNAME=CC + LINKS+= ${BINDIR}/clang ${BINDIR}/cc \ ${BINDIR}/clang ${BINDIR}/c++ \ - ${BINDIR}/clang ${BINDIR}/CC \ ${BINDIR}/clang ${BINDIR}/cpp MLINKS+= clang.1 cc.1 \ clang.1 c++.1 \ clang.1 CC.1 \ clang.1 cpp.1 .endif TGHDRS= CC1AsOptions \ DiagnosticCommonKinds \ DiagnosticDriverKinds \ DiagnosticFrontendKinds \ DiagnosticLexKinds \ DiagnosticSemaKinds \ Options .if !defined(EARLY_BUILD) && defined(MK_CLANG_FULL) && ${MK_CLANG_FULL} != "no" _clangstaticanalyzer= \ clangstaticanalyzerfrontend \ clangstaticanalyzercheckers \ clangstaticanalyzercore _clangarcmigrate= \ clangarcmigrate _clangrewriter= \ clangrewritefrontend \ clangrewritecore .endif # !EARLY_BUILD && MK_CLANG_FULL LIBDEPS=clangfrontendtool \ clangfrontend \ clangdriver \ clangserialization \ clangcodegen \ clangparse \ clangsema \ ${_clangstaticanalyzer} \ ${_clangarcmigrate} \ ${_clangrewriter} \ clanganalysis \ clangedit \ clangast \ clangbasic \ clanglex \ llvmoption \ llvmlinker \ llvmirreader \ llvmipo \ llvmvectorize \ llvminstrumentation \ llvmbitwriter \ llvmbitreader \ llvmasmparser \ llvmarmdisassembler \ llvmarmcodegen \ llvmarmasmparser \ llvmarmdesc \ llvmarminfo \ llvmarminstprinter \ llvmmipsdisassembler \ llvmmipscodegen \ llvmmipsasmparser \ llvmmipsdesc \ llvmmipsinfo \ llvmmipsinstprinter \ llvmpowerpccodegen \ llvmpowerpcasmparser \ llvmpowerpcdesc \ llvmpowerpcinfo \ llvmpowerpcinstprinter \ llvmsparcdisassembler \ llvmsparccodegen \ llvmsparcasmparser \ llvmsparcdesc \ llvmsparcinfo \ llvmsparcinstprinter \ llvmx86disassembler \ llvmx86asmparser \ llvmx86codegen \ llvmselectiondag \ llvmasmprinter \ llvmmcparser \ llvmcodegen \ llvmobjcarcopts \ llvmscalaropts \ llvminstcombine \ llvmtransformutils \ llvmipa \ llvmanalysis \ llvmx86desc \ llvmx86info \ llvmtarget \ llvmx86instprinter \ llvmmc \ llvmobject \ llvmx86utils \ llvmcore \ llvmsupport .include "../clang.prog.mk" Index: stable/10 =================================================================== --- stable/10 (revision 293781) +++ stable/10 (revision 293782) Property changes on: stable/10 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r292950 Index: stable/9/contrib/llvm/patches/patch-r257109-add-CC-aliases.diff =================================================================== --- stable/9/contrib/llvm/patches/patch-r257109-add-CC-aliases.diff (revision 293781) +++ stable/9/contrib/llvm/patches/patch-r257109-add-CC-aliases.diff (nonexistent) @@ -1,25 +0,0 @@ -This patch adds "CC" and "clang-CC" to the list of program name aliases which -invoke the C++ compiler. - -Introduced here: http://svnweb.freebsd.org/changeset/base/257109 - -Index: tools/clang/tools/driver/driver.cpp -=================================================================== ---- tools/clang/tools/driver/driver.cpp -+++ tools/clang/tools/driver/driver.cpp -@@ -215,6 +215,7 @@ static void ParseProgName(SmallVectorImpl &SavedStrings, StringRef S) { return SavedStrings.insert(S).first->c_str(); } /// ApplyQAOverride - Apply a list of edits to the input argument lists. /// /// The input string is a space separate list of edits to perform, /// they are applied in order to the input argument lists. Edits /// should be one of the following forms: /// /// '#': Silence information about the changes to the command line arguments. /// /// '^': Add FOO as a new argument at the beginning of the command line. /// /// '+': Add FOO as a new argument at the end of the command line. /// /// 's/XXX/YYY/': Substitute the regular expression XXX with YYY in the command /// line. /// /// 'xOPTION': Removes all instances of the literal argument OPTION. /// /// 'XOPTION': Removes all instances of the literal argument OPTION, /// and the following argument. /// /// 'Ox': Removes all flags matching 'O' or 'O[sz0-9]' and adds 'Ox' /// at the end of the command line. /// /// \param OS - The stream to write edit information to. /// \param Args - The vector of command line arguments. /// \param Edit - The override command to perform. /// \param SavedStrings - Set to use for storing string representations. static void ApplyOneQAOverride(raw_ostream &OS, SmallVectorImpl &Args, StringRef Edit, std::set &SavedStrings) { // This does not need to be efficient. if (Edit[0] == '^') { const char *Str = SaveStringInSet(SavedStrings, Edit.substr(1)); OS << "### Adding argument " << Str << " at beginning\n"; Args.insert(Args.begin() + 1, Str); } else if (Edit[0] == '+') { const char *Str = SaveStringInSet(SavedStrings, Edit.substr(1)); OS << "### Adding argument " << Str << " at end\n"; Args.push_back(Str); } else if (Edit[0] == 's' && Edit[1] == '/' && Edit.endswith("/") && Edit.slice(2, Edit.size()-1).find('/') != StringRef::npos) { StringRef MatchPattern = Edit.substr(2).split('/').first; StringRef ReplPattern = Edit.substr(2).split('/').second; ReplPattern = ReplPattern.slice(0, ReplPattern.size()-1); for (unsigned i = 1, e = Args.size(); i != e; ++i) { std::string Repl = llvm::Regex(MatchPattern).sub(ReplPattern, Args[i]); if (Repl != Args[i]) { OS << "### Replacing '" << Args[i] << "' with '" << Repl << "'\n"; Args[i] = SaveStringInSet(SavedStrings, Repl); } } } else if (Edit[0] == 'x' || Edit[0] == 'X') { std::string Option = Edit.substr(1, std::string::npos); for (unsigned i = 1; i < Args.size();) { if (Option == Args[i]) { OS << "### Deleting argument " << Args[i] << '\n'; Args.erase(Args.begin() + i); if (Edit[0] == 'X') { if (i < Args.size()) { OS << "### Deleting argument " << Args[i] << '\n'; Args.erase(Args.begin() + i); } else OS << "### Invalid X edit, end of command line!\n"; } } else ++i; } } else if (Edit[0] == 'O') { for (unsigned i = 1; i < Args.size();) { const char *A = Args[i]; if (A[0] == '-' && A[1] == 'O' && (A[2] == '\0' || (A[3] == '\0' && (A[2] == 's' || A[2] == 'z' || ('0' <= A[2] && A[2] <= '9'))))) { OS << "### Deleting argument " << Args[i] << '\n'; Args.erase(Args.begin() + i); } else ++i; } OS << "### Adding argument " << Edit << " at end\n"; Args.push_back(SaveStringInSet(SavedStrings, '-' + Edit.str())); } else { OS << "### Unrecognized edit: " << Edit << "\n"; } } /// ApplyQAOverride - Apply a comma separate list of edits to the /// input argument lists. See ApplyOneQAOverride. static void ApplyQAOverride(SmallVectorImpl &Args, const char *OverrideStr, std::set &SavedStrings) { raw_ostream *OS = &llvm::errs(); if (OverrideStr[0] == '#') { ++OverrideStr; OS = &llvm::nulls(); } *OS << "### QA_OVERRIDE_GCC3_OPTIONS: " << OverrideStr << "\n"; // This does not need to be efficient. const char *S = OverrideStr; while (*S) { const char *End = ::strchr(S, ' '); if (!End) End = S + strlen(S); if (End != S) ApplyOneQAOverride(*OS, Args, std::string(S, End), SavedStrings); S = End; if (*S != '\0') ++S; } } extern int cc1_main(const char **ArgBegin, const char **ArgEnd, const char *Argv0, void *MainAddr); extern int cc1as_main(const char **ArgBegin, const char **ArgEnd, const char *Argv0, void *MainAddr); static void ParseProgName(SmallVectorImpl &ArgVector, std::set &SavedStrings, Driver &TheDriver) { // Try to infer frontend type and default target from the program name. // suffixes[] contains the list of known driver suffixes. // Suffixes are compared against the program name in order. // If there is a match, the frontend type is updated as necessary (CPP/C++). // If there is no match, a second round is done after stripping the last // hyphen and everything following it. This allows using something like // "clang++-2.9". // If there is a match in either the first or second round, // the function tries to identify a target as prefix. E.g. // "x86_64-linux-clang" as interpreted as suffix "clang" with // target prefix "x86_64-linux". If such a target prefix is found, // is gets added via -target as implicit first argument. static const struct { const char *Suffix; const char *ModeFlag; } suffixes [] = { { "clang", 0 }, { "clang++", "--driver-mode=g++" }, - { "clang-CC", "--driver-mode=g++" }, { "clang-c++", "--driver-mode=g++" }, { "clang-cc", 0 }, { "clang-cpp", "--driver-mode=cpp" }, { "clang-g++", "--driver-mode=g++" }, { "clang-gcc", 0 }, { "clang-cl", "--driver-mode=cl" }, - { "CC", "--driver-mode=g++" }, { "cc", 0 }, { "cpp", "--driver-mode=cpp" }, { "cl" , "--driver-mode=cl" }, { "++", "--driver-mode=g++" }, }; std::string ProgName(llvm::sys::path::stem(ArgVector[0])); #ifdef _WIN32 std::transform(ProgName.begin(), ProgName.end(), ProgName.begin(), toLowercase); #endif StringRef ProgNameRef(ProgName); StringRef Prefix; for (int Components = 2; Components; --Components) { bool FoundMatch = false; size_t i; for (i = 0; i < sizeof(suffixes) / sizeof(suffixes[0]); ++i) { if (ProgNameRef.endswith(suffixes[i].Suffix)) { FoundMatch = true; SmallVectorImpl::iterator it = ArgVector.begin(); if (it != ArgVector.end()) ++it; if (suffixes[i].ModeFlag) ArgVector.insert(it, suffixes[i].ModeFlag); break; } } if (FoundMatch) { StringRef::size_type LastComponent = ProgNameRef.rfind('-', ProgNameRef.size() - strlen(suffixes[i].Suffix)); if (LastComponent != StringRef::npos) Prefix = ProgNameRef.slice(0, LastComponent); break; } StringRef::size_type LastComponent = ProgNameRef.rfind('-'); if (LastComponent == StringRef::npos) break; ProgNameRef = ProgNameRef.slice(0, LastComponent); } if (Prefix.empty()) return; std::string IgnoredError; if (llvm::TargetRegistry::lookupTarget(Prefix, IgnoredError)) { SmallVectorImpl::iterator it = ArgVector.begin(); if (it != ArgVector.end()) ++it; const char* Strings[] = { SaveStringInSet(SavedStrings, std::string("-target")), SaveStringInSet(SavedStrings, Prefix) }; ArgVector.insert(it, Strings, Strings + llvm::array_lengthof(Strings)); } } namespace { class StringSetSaver : public llvm::cl::StringSaver { public: StringSetSaver(std::set &Storage) : Storage(Storage) {} const char *SaveString(const char *Str) LLVM_OVERRIDE { return SaveStringInSet(Storage, Str); } private: std::set &Storage; }; } int main(int argc_, const char **argv_) { llvm::sys::PrintStackTraceOnErrorSignal(); llvm::PrettyStackTraceProgram X(argc_, argv_); SmallVector argv; llvm::SpecificBumpPtrAllocator ArgAllocator; llvm::error_code EC = llvm::sys::Process::GetArgumentVector( argv, llvm::ArrayRef(argv_, argc_), ArgAllocator); if (EC) { llvm::errs() << "error: couldn't get arguments: " << EC.message() << '\n'; return 1; } std::set SavedStrings; StringSetSaver Saver(SavedStrings); llvm::cl::ExpandResponseFiles(Saver, llvm::cl::TokenizeGNUCommandLine, argv); // Handle -cc1 integrated tools. if (argv.size() > 1 && StringRef(argv[1]).startswith("-cc1")) { StringRef Tool = argv[1] + 4; if (Tool == "") return cc1_main(argv.data()+2, argv.data()+argv.size(), argv[0], (void*) (intptr_t) GetExecutablePath); if (Tool == "as") return cc1as_main(argv.data()+2, argv.data()+argv.size(), argv[0], (void*) (intptr_t) GetExecutablePath); // Reject unknown tools. llvm::errs() << "error: unknown integrated tool '" << Tool << "'\n"; return 1; } bool CanonicalPrefixes = true; for (int i = 1, size = argv.size(); i < size; ++i) { if (StringRef(argv[i]) == "-no-canonical-prefixes") { CanonicalPrefixes = false; break; } } // Handle QA_OVERRIDE_GCC3_OPTIONS and CCC_ADD_ARGS, used for editing a // command line behind the scenes. if (const char *OverrideStr = ::getenv("QA_OVERRIDE_GCC3_OPTIONS")) { // FIXME: Driver shouldn't take extra initial argument. ApplyQAOverride(argv, OverrideStr, SavedStrings); } std::string Path = GetExecutablePath(argv[0], CanonicalPrefixes); IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions; { OwningPtr Opts(createDriverOptTable()); unsigned MissingArgIndex, MissingArgCount; OwningPtr Args(Opts->ParseArgs(argv.begin()+1, argv.end(), MissingArgIndex, MissingArgCount)); // We ignore MissingArgCount and the return value of ParseDiagnosticArgs. // Any errors that would be diagnosed here will also be diagnosed later, // when the DiagnosticsEngine actually exists. (void) ParseDiagnosticArgs(*DiagOpts, *Args); } // Now we can create the DiagnosticsEngine with a properly-filled-out // DiagnosticOptions instance. TextDiagnosticPrinter *DiagClient = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts); // If the clang binary happens to be named cl.exe for compatibility reasons, // use clang-cl.exe as the prefix to avoid confusion between clang and MSVC. StringRef ExeBasename(llvm::sys::path::filename(Path)); if (ExeBasename.equals_lower("cl.exe")) ExeBasename = "clang-cl.exe"; DiagClient->setPrefix(ExeBasename); IntrusiveRefCntPtr DiagID(new DiagnosticIDs()); DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagClient); ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false); Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), "a.out", Diags); // Attempt to find the original path used to invoke the driver, to determine // the installed path. We do this manually, because we want to support that // path being a symlink. { SmallString<128> InstalledPath(argv[0]); // Do a PATH lookup, if there are no directory components. if (llvm::sys::path::filename(InstalledPath) == InstalledPath) { std::string Tmp = llvm::sys::FindProgramByName( llvm::sys::path::filename(InstalledPath.str())); if (!Tmp.empty()) InstalledPath = Tmp; } llvm::sys::fs::make_absolute(InstalledPath); InstalledPath = llvm::sys::path::parent_path(InstalledPath); bool exists; if (!llvm::sys::fs::exists(InstalledPath.str(), exists) && exists) TheDriver.setInstalledDir(InstalledPath); } llvm::InitializeAllTargets(); ParseProgName(argv, SavedStrings, TheDriver); // Handle CC_PRINT_OPTIONS and CC_PRINT_OPTIONS_FILE. TheDriver.CCPrintOptions = !!::getenv("CC_PRINT_OPTIONS"); if (TheDriver.CCPrintOptions) TheDriver.CCPrintOptionsFilename = ::getenv("CC_PRINT_OPTIONS_FILE"); // Handle CC_PRINT_HEADERS and CC_PRINT_HEADERS_FILE. TheDriver.CCPrintHeaders = !!::getenv("CC_PRINT_HEADERS"); if (TheDriver.CCPrintHeaders) TheDriver.CCPrintHeadersFilename = ::getenv("CC_PRINT_HEADERS_FILE"); // Handle CC_LOG_DIAGNOSTICS and CC_LOG_DIAGNOSTICS_FILE. TheDriver.CCLogDiagnostics = !!::getenv("CC_LOG_DIAGNOSTICS"); if (TheDriver.CCLogDiagnostics) TheDriver.CCLogDiagnosticsFilename = ::getenv("CC_LOG_DIAGNOSTICS_FILE"); OwningPtr C(TheDriver.BuildCompilation(argv)); int Res = 0; SmallVector, 4> FailingCommands; if (C.get()) Res = TheDriver.ExecuteCompilation(*C, FailingCommands); // Force a crash to test the diagnostics. if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH")) { Diags.Report(diag::err_drv_force_crash) << "FORCE_CLANG_DIAGNOSTICS_CRASH"; const Command *FailingCommand = 0; FailingCommands.push_back(std::make_pair(-1, FailingCommand)); } for (SmallVectorImpl< std::pair >::iterator it = FailingCommands.begin(), ie = FailingCommands.end(); it != ie; ++it) { int CommandRes = it->first; const Command *FailingCommand = it->second; if (!Res) Res = CommandRes; // If result status is < 0, then the driver command signalled an error. // If result status is 70, then the driver command reported a fatal error. // In these cases, generate additional diagnostic information if possible. if (CommandRes < 0 || CommandRes == 70) { TheDriver.generateCompilationDiagnostics(*C, FailingCommand); break; } } // If any timers were active but haven't been destroyed yet, print their // results now. This happens in -disable-free mode. llvm::TimerGroup::printAll(llvm::errs()); llvm::llvm_shutdown(); #ifdef _WIN32 // Exit status should not be negative on Win32, unless abnormal termination. // Once abnormal termiation was caught, negative status should not be // propagated. if (Res < 0) Res = 1; #endif // If we have multiple failing commands, we return the result of the first // failing command. return Res; } Index: stable/9/contrib/llvm/tools/clang =================================================================== --- stable/9/contrib/llvm/tools/clang (revision 293781) +++ stable/9/contrib/llvm/tools/clang (revision 293782) Property changes on: stable/9/contrib/llvm/tools/clang ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head/contrib/llvm/tools/clang:r292950 Index: stable/9/contrib/llvm =================================================================== --- stable/9/contrib/llvm (revision 293781) +++ stable/9/contrib/llvm (revision 293782) Property changes on: stable/9/contrib/llvm ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head/contrib/llvm:r292950 Index: stable/9/usr.bin/clang/clang/CC.sh =================================================================== --- stable/9/usr.bin/clang/clang/CC.sh (nonexistent) +++ stable/9/usr.bin/clang/clang/CC.sh (revision 293782) @@ -0,0 +1,4 @@ +#!/bin/sh +# $FreeBSD$ +# This file is in the public domain. +exec /usr/bin/c++ "$@" Property changes on: stable/9/usr.bin/clang/clang/CC.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/9/usr.bin/clang/clang/Makefile =================================================================== --- stable/9/usr.bin/clang/clang/Makefile (revision 293781) +++ stable/9/usr.bin/clang/clang/Makefile (revision 293782) @@ -1,121 +1,123 @@ # $FreeBSD$ .include PROG_CXX=clang SRCDIR= tools/clang/tools/driver SRCS= cc1_main.cpp \ cc1as_main.cpp \ driver.cpp .if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= yes .endif LINKS= ${BINDIR}/clang ${BINDIR}/clang++ \ ${BINDIR}/clang ${BINDIR}/clang-cpp MLINKS= clang.1 clang++.1 \ clang.1 clang-cpp.1 .if ${MK_CLANG_IS_CC} != "no" +SCRIPTS=CC.sh +SCRIPTSNAME=CC + LINKS+= ${BINDIR}/clang ${BINDIR}/cc \ ${BINDIR}/clang ${BINDIR}/c++ \ - ${BINDIR}/clang ${BINDIR}/CC \ ${BINDIR}/clang ${BINDIR}/cpp MLINKS+= clang.1 cc.1 \ clang.1 c++.1 \ clang.1 CC.1 \ clang.1 cpp.1 .endif TGHDRS= CC1AsOptions \ DiagnosticCommonKinds \ DiagnosticDriverKinds \ DiagnosticFrontendKinds \ DiagnosticLexKinds \ DiagnosticSemaKinds \ Options .if !defined(EARLY_BUILD) && defined(MK_CLANG_FULL) && ${MK_CLANG_FULL} != "no" _clangstaticanalyzer= \ clangstaticanalyzerfrontend \ clangstaticanalyzercheckers \ clangstaticanalyzercore _clangarcmigrate= \ clangarcmigrate _clangrewriter= \ clangrewritefrontend \ clangrewritecore .endif # !EARLY_BUILD && MK_CLANG_FULL LIBDEPS=clangfrontendtool \ clangfrontend \ clangdriver \ clangserialization \ clangcodegen \ clangparse \ clangsema \ ${_clangstaticanalyzer} \ ${_clangarcmigrate} \ ${_clangrewriter} \ clanganalysis \ clangedit \ clangast \ clangbasic \ clanglex \ llvmoption \ llvmlinker \ llvmirreader \ llvmipo \ llvmvectorize \ llvminstrumentation \ llvmbitwriter \ llvmbitreader \ llvmasmparser \ llvmarmdisassembler \ llvmarmcodegen \ llvmarmasmparser \ llvmarmdesc \ llvmarminfo \ llvmarminstprinter \ llvmmipsdisassembler \ llvmmipscodegen \ llvmmipsasmparser \ llvmmipsdesc \ llvmmipsinfo \ llvmmipsinstprinter \ llvmpowerpccodegen \ llvmpowerpcasmparser \ llvmpowerpcdesc \ llvmpowerpcinfo \ llvmpowerpcinstprinter \ llvmsparcdisassembler \ llvmsparccodegen \ llvmsparcasmparser \ llvmsparcdesc \ llvmsparcinfo \ llvmsparcinstprinter \ llvmx86disassembler \ llvmx86asmparser \ llvmx86codegen \ llvmselectiondag \ llvmasmprinter \ llvmmcparser \ llvmcodegen \ llvmobjcarcopts \ llvmscalaropts \ llvminstcombine \ llvmtransformutils \ llvmipa \ llvmanalysis \ llvmx86desc \ llvmx86info \ llvmtarget \ llvmx86instprinter \ llvmmc \ llvmobject \ llvmx86utils \ llvmcore \ llvmsupport .include "../clang.prog.mk" Index: stable/9/usr.bin/clang =================================================================== --- stable/9/usr.bin/clang (revision 293781) +++ stable/9/usr.bin/clang (revision 293782) Property changes on: stable/9/usr.bin/clang ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head/usr.bin/clang:r292950