diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | src/v4/llvm_installation.pri | 23 | ||||
-rw-r--r-- | src/v4/v4.pri | 2 | ||||
-rw-r--r-- | src/v4/v4.pro | 14 | ||||
-rw-r--r-- | tools/v4/main.cpp | 33 | ||||
-rw-r--r-- | tools/v4/v4.pro | 3 |
6 files changed, 48 insertions, 28 deletions
@@ -1,5 +1,6 @@ *.o Makefile +Makefile.* src/tools/v4 udis86_itab.* *.pyc diff --git a/src/v4/llvm_installation.pri b/src/v4/llvm_installation.pri new file mode 100644 index 00000000..99e955fd --- /dev/null +++ b/src/v4/llvm_installation.pri @@ -0,0 +1,23 @@ +LLVM_CONFIG=llvm-config +# Pick up the qmake variable or environment variable for LLVM_INSTALL_DIR. If either was set, change the LLVM_CONFIG to use that. +isEmpty(LLVM_INSTALL_DIR):LLVM_INSTALL_DIR=$$(LLVM_INSTALL_DIR) +!isEmpty(LLVM_INSTALL_DIR):LLVM_CONFIG=$$LLVM_INSTALL_DIR/bin/llvm-config +exists ($${LLVM_CONFIG}) { + CONFIG += llvm-libs + message("Found LLVM in $$LLVM_INSTALL_DIR") +} + +llvm-libs { + win32 { + LLVM_INCLUDEPATH = $$LLVM_INSTALL_DIR/include +# TODO: check if the next line is needed somehow for the llvm_runtime target. + LLVM_LIBS += -ladvapi32 -lshell32 + } + + unix { + LLVM_INCLUDEPATH = $$system($$LLVM_CONFIG --includedir) + LLVM_LIBDIR = $$system($$LLVM_CONFIG --libdir) + } + + LLVM_DEFINES += __STDC_LIMIT_MACROS __STDC_CONSTANT_MACROS +} diff --git a/src/v4/v4.pri b/src/v4/v4.pri index 6f70a8c6..c1eabe64 100644 --- a/src/v4/v4.pri +++ b/src/v4/v4.pri @@ -1,4 +1,4 @@ - +include(llvm_installation.pri) include(../3rdparty/masm/masm-defs.pri) !llvm: DEFINES += QMLJS_NO_LLVM diff --git a/src/v4/v4.pro b/src/v4/v4.pro index 3f1d7413..60338cc4 100644 --- a/src/v4/v4.pro +++ b/src/v4/v4.pro @@ -4,7 +4,7 @@ QT = core CONFIG += internal_module -LLVM_CONFIG=llvm-config +include(v4.pri) OBJECTS_DIR=.obj @@ -15,11 +15,6 @@ CONFIG += warn_off #win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000 #TODO ??! - -# Pick up the qmake variable or environment variable for LLVM_INSTALL_DIR. If either was set, change the LLVM_CONFIG to use that. -isEmpty(LLVM_INSTALL_DIR):LLVM_INSTALL_DIR=$$(LLVM_INSTALL_DIR) -!isEmpty(LLVM_INSTALL_DIR):LLVM_CONFIG=$$LLVM_INSTALL_DIR/bin/llvm-config - !macx-clang*:LIBS += -rdynamic SOURCES += \ @@ -93,7 +88,7 @@ HEADERS += \ qv4objectiterator.h \ qv4regexp.h -llvm { +llvm-libs { SOURCES += \ qv4isel_llvm.cpp @@ -104,6 +99,7 @@ HEADERS += \ LLVM_RUNTIME_BC = $$PWD/llvm_runtime.bc DEFINES += LLVM_RUNTIME="\"\\\"$$LLVM_RUNTIME_BC\\\"\"" +DEFINES += QMLJS_WITH_LLVM INCLUDEPATH += \ $$system($$LLVM_CONFIG --includedir) @@ -122,8 +118,7 @@ GEN_LLVM_RUNTIME_FLAGS = $$system($$LLVM_CONFIG --cppflags) GEN_LLVM_RUNTIME_FLAGS -= -pedantic gen_llvm_runtime.target = llvm_runtime -gen_llvm_runtime.commands = clang -O2 -emit-llvm -c $(INCPATH) $$GEN_LLVM_RUNTIME_FLAGS -DQMLJS_LLVM_RUNTIME llvm_runtime.cpp -o $$LLVM_RUNTIME_BC - +gen_llvm_runtime.commands = clang -O2 -emit-llvm -c -I$$PWD -I$$PWD/../3rdparty/masm $$join(QT.core.includes, " -I", "-I") $$GEN_LLVM_RUNTIME_FLAGS -DQMLJS_LLVM_RUNTIME llvm_runtime.cpp -o $$LLVM_RUNTIME_BC } # Use SSE2 floating point math on 32 bit instead of the default @@ -150,4 +145,3 @@ QMAKE_EXTRA_TARGETS += checkmothtarget include(moth/moth.pri) include(../3rdparty/masm/masm.pri) include(../3rdparty/double-conversion/double-conversion.pri) -include(v4.pri) diff --git a/tools/v4/main.cpp b/tools/v4/main.cpp index 7ac064fb..0d215b9e 100644 --- a/tools/v4/main.cpp +++ b/tools/v4/main.cpp @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#ifndef QMLJS_NO_LLVM +#ifdef QMLJS_WITH_LLVM # include "private/qv4_llvm_p.h" -#endif +#endif // QMLJS_WITH_LLVM #include "private/debugging.h" #include "private/qv4object.h" @@ -153,7 +153,7 @@ static void showException(QQmlJS::VM::ExecutionContext *ctx) } } -#ifndef QMLJS_NO_LLVM +#ifdef QMLJS_WITH_LLVM int executeLLVMCode(void *codePtr) { using namespace QQmlJS; @@ -260,8 +260,7 @@ int evaluateCompiledCode(const QStringList &files) return EXIT_SUCCESS; } - -#endif +#endif // QMLJS_WITH_LLVM int main(int argc, char *argv[]) @@ -278,9 +277,9 @@ int main(int argc, char *argv[]) use_llvm_jit } mode = use_masm; -#ifndef QMLJS_NO_LLVM +#ifdef QMLJS_WITH_LLVM QQmlJS::LLVMOutputType fileType = QQmlJS::LLVMOutputObject; -#endif // QMLJS_NO_LLVM +#endif // QMLJS_WITH_LLVM bool enableDebugging = false; if (!args.isEmpty()) { @@ -301,7 +300,7 @@ int main(int argc, char *argv[]) args.removeFirst(); } -#ifndef QMLJS_NO_LLVM +#ifdef QMLJS_WITH_LLVM if (args.first() == QLatin1String("--compile")) { mode = use_llvm_compiler; args.removeFirst(); @@ -328,7 +327,7 @@ int main(int argc, char *argv[]) mode = use_llvm_jit; args.removeFirst(); } -#endif // QMLJS_NO_LLVM +#endif // QMLJS_WITH_LLVM if (args.first() == QLatin1String("--help")) { std::cerr << "Usage: v4 [|--debug|-d] [|--jit|--interpret|--compile|--aot|--llvm-jit] file..." << std::endl; return EXIT_SUCCESS; @@ -336,20 +335,20 @@ int main(int argc, char *argv[]) } switch (mode) { -#ifdef QMLJS_NO_LLVM - case use_llvm_compiler: - case use_llvm_runtime: - case use_llvm_jit: - std::cerr << "LLVM backend was not built, compiler is unavailable." << std::endl; - return EXIT_FAILURE; -#else // QMLJS_NO_LLVM +#ifdef QMLJS_WITH_LLVM case use_llvm_jit: return compileFiles(args, QQmlJS::LLVMOutputJit); case use_llvm_compiler: return compileFiles(args, fileType); case use_llvm_runtime: return evaluateCompiledCode(args); -#endif // QMLJS_NO_LLVM +#else // !QMLJS_WITH_LLVM + case use_llvm_compiler: + case use_llvm_runtime: + case use_llvm_jit: + std::cerr << "LLVM backend was not built, compiler is unavailable." << std::endl; + return EXIT_FAILURE; +#endif // QMLJS_WITH_LLVM case use_masm: case use_moth: { QScopedPointer<QQmlJS::EvalISelFactory> iSelFactory; diff --git a/tools/v4/v4.pro b/tools/v4/v4.pro index 3f878fa6..fcf1b285 100644 --- a/tools/v4/v4.pro +++ b/tools/v4/v4.pro @@ -4,4 +4,7 @@ SOURCES = main.cpp include(../../src/v4/v4.pri) +llvm-libs { + DEFINES += QMLJS_WITH_LLVM +} load(qt_tool) |