summaryrefslogtreecommitdiffstats
path: root/tools/driver
diff options
context:
space:
mode:
Diffstat (limited to 'tools/driver')
-rw-r--r--tools/driver/CMakeLists.txt11
-rw-r--r--tools/driver/Makefile2
-rw-r--r--tools/driver/cc1_main.cpp68
-rw-r--r--tools/driver/driver.cpp17
4 files changed, 21 insertions, 77 deletions
diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt
index 1a95380..7900211 100644
--- a/tools/driver/CMakeLists.txt
+++ b/tools/driver/CMakeLists.txt
@@ -3,7 +3,6 @@ set(LLVM_NO_RTTI 1)
set( LLVM_USED_LIBS
clangDriver
clangBasic
- clangFrontend
)
set(LLVM_LINK_COMPONENTS system support bitreader bitwriter)
@@ -15,9 +14,15 @@ add_clang_executable(clang
add_dependencies(clang clang-cc)
+if(UNIX)
+ set(CLANGXX_LINK_OR_COPY create_symlink)
+else()
+ set(CLANGXX_LINK_OR_COPY copy)
+endif()
+
# Create the clang++ symlink in the build directory.
add_custom_target(clang++ ALL
- ${CMAKE_COMMAND} -E create_symlink
+ ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY}
"${LLVM_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX}"
"${LLVM_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/clang++${CMAKE_EXECUTABLE_SUFFIX}"
DEPENDS clang)
@@ -26,4 +31,4 @@ install(TARGETS clang
RUNTIME DESTINATION bin)
# Create the clang++ symlink at installation time.
-install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink \"${CMAKE_INSTALL_PREFIX}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}\" \"${CMAKE_INSTALL_PREFIX}/bin/clang++${CMAKE_EXECUTABLE_SUFFIX}\")")
+install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E ${CLANGXX_LINK_OR_COPY} \"${CMAKE_INSTALL_PREFIX}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}\" \"${CMAKE_INSTALL_PREFIX}/bin/clang++${CMAKE_EXECUTABLE_SUFFIX}\")")
diff --git a/tools/driver/Makefile b/tools/driver/Makefile
index 19f93a2..f250651 100644
--- a/tools/driver/Makefile
+++ b/tools/driver/Makefile
@@ -19,7 +19,7 @@ TOOL_NO_EXPORTS = 1
# FIXME: It is unfortunate we need to pull in the bitcode reader and
# writer just to get the serializer stuff used by clangBasic.
LINK_COMPONENTS := system support bitreader bitwriter
-USEDLIBS = clangDriver.a clangBasic.a clangFrontend.a
+USEDLIBS = clangDriver.a clangBasic.a
include $(LEVEL)/Makefile.common
diff --git a/tools/driver/cc1_main.cpp b/tools/driver/cc1_main.cpp
index c516359..a9d27ef 100644
--- a/tools/driver/cc1_main.cpp
+++ b/tools/driver/cc1_main.cpp
@@ -11,78 +11,14 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/Driver/Arg.h"
-#include "clang/Driver/ArgList.h"
-#include "clang/Driver/CC1Options.h"
-#include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/OptTable.h"
-#include "clang/Driver/Option.h"
-#include "clang/Frontend/CompilerInvocation.h"
#include "llvm/Support/raw_ostream.h"
-#include <cstdlib>
-#include <vector>
-using namespace clang;
-using namespace clang::driver;
-
-int cc1_main(Diagnostic &Diags, const char **ArgBegin, const char **ArgEnd) {
+int cc1_main(const char **ArgBegin, const char **ArgEnd,
+ const char *Argv0, void *MainAddr) {
llvm::errs() << "cc1 argv:";
for (const char **i = ArgBegin; i != ArgEnd; ++i)
llvm::errs() << " \"" << *i << '"';
llvm::errs() << "\n";
- // Parse the arguments.
- OptTable *Opts = createCC1OptTable();
- unsigned MissingArgIndex, MissingArgCount;
- InputArgList *Args = Opts->ParseArgs(ArgBegin, ArgEnd,
- MissingArgIndex, MissingArgCount);
-
- // Check for missing argument error.
- if (MissingArgCount)
- Diags.Report(clang::diag::err_drv_missing_argument)
- << Args->getArgString(MissingArgIndex) << MissingArgCount;
-
- // Dump the parsed arguments.
- llvm::errs() << "cc1 parsed options:\n";
- for (ArgList::const_iterator it = Args->begin(), ie = Args->end();
- it != ie; ++it)
- (*it)->dump();
-
- // Create a compiler invocation.
- llvm::errs() << "cc1 creating invocation.\n";
- CompilerInvocation Invocation;
- CompilerInvocation::CreateFromArgs(Invocation,
- llvm::SmallVector<llvm::StringRef, 32>(ArgBegin, ArgEnd));
-
- // Convert the invocation back to argument strings.
- std::vector<std::string> InvocationArgs;
- Invocation.toArgs(InvocationArgs);
-
- // Dump the converted arguments.
- llvm::SmallVector<llvm::StringRef, 32> Invocation2Args;
- llvm::errs() << "invocation argv:";
- for (unsigned i = 0, e = InvocationArgs.size(); i != e; ++i) {
- Invocation2Args.push_back(InvocationArgs[i]);
- llvm::errs() << " \"" << InvocationArgs[i] << '"';
- }
- llvm::errs() << "\n";
-
- // Convert those arguments to another invocation, and check that we got the
- // same thing.
- CompilerInvocation Invocation2;
- CompilerInvocation::CreateFromArgs(Invocation2, Invocation2Args);
-
- // FIXME: Implement CompilerInvocation comparison.
- if (memcmp(&Invocation, &Invocation2, sizeof(Invocation)) != 0) {
- llvm::errs() << "warning: Invocations differ!\n";
-
- std::vector<std::string> Invocation2Args;
- Invocation2.toArgs(Invocation2Args);
- llvm::errs() << "invocation argv:";
- for (unsigned i = 0, e = Invocation2Args.size(); i != e; ++i)
- llvm::errs() << " \"" << Invocation2Args[i] << '"';
- llvm::errs() << "\n";
- }
-
return 0;
}
diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp
index dbfc293..c61ee72 100644
--- a/tools/driver/driver.cpp
+++ b/tools/driver/driver.cpp
@@ -178,22 +178,23 @@ void ApplyQAOverride(std::vector<const char*> &Args, const char *OverrideStr,
}
}
-extern int cc1_main(Diagnostic &Diags,
- const char **ArgBegin, const char **ArgEnd);
+extern int cc1_main(const char **ArgBegin, const char **ArgEnd,
+ const char *Argv0, void *MainAddr);
int main(int argc, const char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal();
llvm::PrettyStackTraceProgram X(argc, argv);
+ // Dispatch to cc1_main if appropriate.
+ if (argc > 1 && llvm::StringRef(argv[1]) == "-cc1")
+ return cc1_main(argv+2, argv+argc, argv[0],
+ (void*) (intptr_t) GetExecutablePath);
+
llvm::sys::Path Path = GetExecutablePath(argv[0]);
DriverDiagnosticPrinter DiagClient(Path.getBasename(), llvm::errs());
Diagnostic Diags(&DiagClient);
- // Dispatch to cc1_main if appropriate.
- if (argc > 1 && llvm::StringRef(argv[1]) == "-cc1")
- return cc1_main(Diags, argv+2, argv+argc);
-
#ifdef CLANG_IS_PRODUCTION
bool IsProduction = true;
#else
@@ -208,7 +209,9 @@ int main(int argc, const char **argv) {
//
// Note that we intentionally want to use argv[0] here, to support "clang++"
// being a symlink.
- std::string ProgName(llvm::sys::Path(argv[0]).getBasename());
+ //
+ // We use *argv instead of argv[0] to work around a bogus g++ warning.
+ std::string ProgName(llvm::sys::Path(*argv).getBasename());
if (llvm::StringRef(ProgName).endswith("++") ||
llvm::StringRef(ProgName).rsplit('-').first.endswith("++"))
TheDriver.CCCIsCXX = true;
OpenPOWER on IntegriCloud