Enhance host bcc to allow cross-compilation (eg. debug arm codegen on host):
eg. bcc -C armv7-none-linux-gnueabi # generate ARMv7
bcc -C i686-unknown-linux # generate x86 (default on Goobuntu)
Other targets are not supported at this moment.
Change-Id: If2f1199656664327cf35cf6a3670136f48c42cad
diff --git a/lib/ExecutionEngine/Android.mk b/lib/ExecutionEngine/Android.mk
index 695a975..e222a41 100644
--- a/lib/ExecutionEngine/Android.mk
+++ b/lib/ExecutionEngine/Android.mk
@@ -89,6 +89,7 @@
LOCAL_IS_HOST_MODULE := true
LOCAL_CFLAGS += $(libbcc_CFLAGS)
+LOCAL_CFLAGS += -D__HOST__
LOCAL_C_INCLUDES := $(libbcc_C_INCLUDES)
LOCAL_SRC_FILES := $(libbcc_executionengine_SRC_FILES)
diff --git a/lib/ExecutionEngine/Compiler.cpp b/lib/ExecutionEngine/Compiler.cpp
index dd370d9..4351079 100644
--- a/lib/ExecutionEngine/Compiler.cpp
+++ b/lib/ExecutionEngine/Compiler.cpp
@@ -91,6 +91,20 @@
bool Compiler::GlobalInitialized = false;
+
+#if !defined(__HOST__)
+ #define TARGET_TRIPLE_STRING DEFAULT_TARGET_TRIPLE_STRING
+#else
+// In host TARGET_TRIPLE_STRING is a variable to allow cross-compilation.
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+ char *TARGET_TRIPLE_STRING = (char*)DEFAULT_TARGET_TRIPLE_STRING;
+ #if defined(__cplusplus)
+ };
+ #endif
+#endif
+
// Code generation optimization level for the compiler
llvm::CodeGenOpt::Level Compiler::CodeGenOptLevel;