aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm-stub/llvm-stub.c
diff options
context:
space:
mode:
authorJohn Criswell <criswell@uiuc.edu>2005-11-02 18:05:50 +0000
committerJohn Criswell <criswell@uiuc.edu>2005-11-02 18:05:50 +0000
commitcfa435f79bf39fead32263a8b71c9ae440b55214 (patch)
tree2f1ef0a4c3fb5549b8bbb014891f92866d46e042 /tools/llvm-stub/llvm-stub.c
Mark these as failing on sparc instead of sparcv9.
The configure script no longer tells us that we're configuring for SparcV9 specifically. 2004-06-17-UnorderedCompares may work on SparcV8, but it's experiental anyway. 2005-02-20-AggregateSAVEEXPR should fail on any Solaris machine, as Solaris doesn't provide complex number support. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_16@24155 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-stub/llvm-stub.c')
-rw-r--r--tools/llvm-stub/llvm-stub.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/tools/llvm-stub/llvm-stub.c b/tools/llvm-stub/llvm-stub.c
new file mode 100644
index 0000000000..10b025633f
--- /dev/null
+++ b/tools/llvm-stub/llvm-stub.c
@@ -0,0 +1,69 @@
+/*===- llvm-stub.c - Stub executable to run llvm bytecode files -----------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This tool is used by the gccld program to enable transparent execution of
+// bytecode files by the user. Specifically, gccld outputs two files when asked
+// to compile a <program> file:
+// 1. It outputs the LLVM bytecode file to <program>.bc
+// 2. It outputs a stub executable that runs lli on <program>.bc
+//
+// This allows the end user to just say ./<program> and have the JIT executed
+// automatically. On unix, the stub executable emitted is actually a bourne
+// shell script that does the forwarding. Windows does not like #!/bin/sh
+// programs in .exe files, so we make it an actual program, defined here.
+//
+//===----------------------------------------------------------------------===*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "llvm/Config/config.h"
+
+#if defined(HAVE_UNISTD_H) && !defined(_MSC_VER)
+#include <unistd.h>
+#endif
+
+#ifdef _WIN32
+#include <process.h>
+#include <io.h>
+#endif
+
+int main(int argc, char** argv) {
+ const char *Interp = getenv("LLVMINTERP");
+ const char **Args;
+ if (Interp == 0) Interp = "lli";
+
+ /* Set up the command line options to pass to the JIT. */
+ Args = (const char**)malloc(sizeof(char*) * (argc+2));
+ /* argv[0] is the JIT */
+ Args[0] = Interp;
+
+#ifdef __CYGWIN32__
+ /* Cygwin strips the .exe suffix off of argv[0] to "help" us. Put it back
+ * on.
+ */
+ argv[0] = strcat(strcpy((char*)malloc(strlen(argv[0])+5), argv[0]), ".exe");
+#endif
+
+ /* argv[1] is argv[0] + ".bc". */
+ Args[1] = strcat(strcpy((char*)malloc(strlen(argv[0])+4), argv[0]), ".bc");
+
+ /* The rest of the args are as before. */
+ memcpy(Args+2, argv+1, sizeof(char*)*argc);
+
+ /* Run the JIT. */
+ execvp(Interp, (char *const*)Args);
+
+ /* if _execv returns, the JIT could not be started. */
+ fprintf(stderr, "Could not execute the LLVM JIT. Either add 'lli' to your"
+ " path, or set the\ninterpreter you want to use in the LLVMINTERP "
+ "environment variable.\n");
+ return 1;
+}