Fixed the llvm bits of the build process.
authorErik Verbruggen <erik.verbruggen@me.com>
Fri, 1 Feb 2013 11:57:22 +0000 (12:57 +0100)
committerLars Knoll <lars.knoll@digia.com>
Wed, 6 Feb 2013 07:48:12 +0000 (08:48 +0100)
Change-Id: I618e0ee413e9548817f84473917ccb8051f689f2
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
.gitignore
src/v4/llvm_installation.pri [new file with mode: 0644]
src/v4/v4.pri
src/v4/v4.pro
tools/v4/main.cpp
tools/v4/v4.pro

index 8df072a..2934c50 100644 (file)
@@ -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 (file)
index 0000000..99e955f
--- /dev/null
@@ -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
+}
index 6f70a8c..c1eabe6 100644 (file)
@@ -1,4 +1,4 @@
-
+include(llvm_installation.pri)
 include(../3rdparty/masm/masm-defs.pri)
 
 !llvm: DEFINES += QMLJS_NO_LLVM
index 3f1d741..60338cc 100644 (file)
@@ -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)
index 7ac064f..0d215b9 100644 (file)
@@ -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;
index 3f878fa..fcf1b28 100644 (file)
@@ -4,4 +4,7 @@ SOURCES = main.cpp
 
 include(../../src/v4/v4.pri)
 
+llvm-libs {
+    DEFINES += QMLJS_WITH_LLVM
+}
 load(qt_tool)