Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion interpreter/cling/lib/Interpreter/CIFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#define NOGDI
#define NOMINMAX
#include <Windows.h>
#include <sstream>
#include <direct.h>
#define popen _popen
#define pclose _pclose
Expand Down Expand Up @@ -426,6 +425,13 @@ namespace {
}
}
#else // _MSC_VER
// Skip LLVM_CXX execution if -nostdinc++ was provided.
for (const auto arg : args) {
if (!strcmp(arg, "-nostdinc++")) {
return;
}
}

static const char *CppInclQuery =
"echo | LC_ALL=C " LLVM_CXX " -xc++ -E -v - 2>&1 >/dev/null "
"| awk '/^#include </,/^End of search"
Expand Down
28 changes: 25 additions & 3 deletions interpreter/cling/lib/Interpreter/IncrementalExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ using namespace llvm;

namespace cling {

IncrementalExecutor::IncrementalExecutor(clang::DiagnosticsEngine& diags):
IncrementalExecutor::IncrementalExecutor(clang::DiagnosticsEngine& diags, const int& argc, const char* const *argv):
m_CurrentAtExitModule(0)
#if 0
: m_Diags(diags)
Expand All @@ -57,14 +57,14 @@ IncrementalExecutor::IncrementalExecutor(clang::DiagnosticsEngine& diags):
// can use this object yet.
m_AtExitFuncs.reserve(256);

m_JIT.reset(new IncrementalJIT(*this, std::move(CreateHostTargetMachine())));
m_JIT.reset(new IncrementalJIT(*this, std::move(CreateHostTargetMachine(argc, argv))));
}

// Keep in source: ~unique_ptr<ClingJIT> needs ClingJIT
IncrementalExecutor::~IncrementalExecutor() {}

std::unique_ptr<TargetMachine>
IncrementalExecutor::CreateHostTargetMachine() const {
IncrementalExecutor::CreateHostTargetMachine(const int& argc, const char* const *argv) const {
// TODO: make this configurable.
Triple TheTriple(sys::getProcessTriple());
#ifdef _WIN32
Expand All @@ -91,6 +91,28 @@ std::unique_ptr<TargetMachine>
CodeModel::Model CMModel = CodeModel::JITDefault;
CodeGenOpt::Level OptLevel = CodeGenOpt::Less;

for (int i = 0; i < argc; ++i) {
const std::string arg(argv[i]);
if (arg.length() != 3 || arg.rfind("-O", 0) != 0) {
continue;
}

switch (argv[i][2]) {
case '0':
OptLevel = CodeGenOpt::None;
break;
case '1':
OptLevel = CodeGenOpt::Less;
break;
case '2':
OptLevel = CodeGenOpt::Default;
break;
case '3':
OptLevel = CodeGenOpt::Aggressive;
break;
}
}

std::unique_ptr<TargetMachine> TM;
TM.reset(TheTarget->createTargetMachine(TheTriple.getTriple(),
MCPU, FeaturesStr,
Expand Down
4 changes: 2 additions & 2 deletions interpreter/cling/lib/Interpreter/IncrementalExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace cling {
clang::DiagnosticsEngine& m_Diags;
#endif

std::unique_ptr<llvm::TargetMachine> CreateHostTargetMachine() const;
std::unique_ptr<llvm::TargetMachine> CreateHostTargetMachine(const int& argc, const char* const *argv) const;

public:
enum ExecutionResult {
Expand All @@ -137,7 +137,7 @@ namespace cling {
kNumExeResults
};

IncrementalExecutor(clang::DiagnosticsEngine& diags);
IncrementalExecutor(clang::DiagnosticsEngine& diags, const int& argc, const char* const *argv);

~IncrementalExecutor();

Expand Down
2 changes: 1 addition & 1 deletion interpreter/cling/lib/Interpreter/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ namespace cling {
/*isTemp*/true), this));

if (!isInSyntaxOnlyMode())
m_Executor.reset(new IncrementalExecutor(SemaRef.Diags));
m_Executor.reset(new IncrementalExecutor(SemaRef.Diags, argc, argv));

// Tell the diagnostic client that we are entering file parsing mode.
DiagnosticConsumer& DClient = getCI()->getDiagnosticClient();
Expand Down