[llvm-commits] [llvm] r52286 - /llvm/trunk/tools/llvm-stub/llvm-stub.c

Argiris Kirtzidis akyrtzi at gmail.com
Sun Jun 15 05:07:01 PDT 2008


Author: akirtzidis
Date: Sun Jun 15 07:07:01 2008
New Revision: 52286

URL: http://llvm.org/viewvc/llvm-project?rev=52286&view=rev
Log:
Make sure that the current executable filename has "exe" suffix on Windows.

Modified:
    llvm/trunk/tools/llvm-stub/llvm-stub.c

Modified: llvm/trunk/tools/llvm-stub/llvm-stub.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-stub/llvm-stub.c?rev=52286&r1=52285&r2=52286&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-stub/llvm-stub.c (original)
+++ llvm/trunk/tools/llvm-stub/llvm-stub.c Sun Jun 15 07:07:01 2008
@@ -38,6 +38,7 @@
 int main(int argc, char** argv) {
   const char *Interp = getenv("LLVMINTERP");
   const char **Args;
+  int len;
   if (Interp == 0) Interp = "lli";
 
   /* Set up the command line options to pass to the JIT. */
@@ -45,11 +46,14 @@
   /* 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");
+#ifdef LLVM_ON_WIN32
+  len = strlen(argv[0]);
+  if (len < 4 || strcmp(argv[0] + len - 4, ".exe") != 0) {
+    /* .exe suffix is stripped off of argv[0] if the executable was run on the
+     * command line without one. Put it back on.
+     */
+    argv[0] = strcat(strcpy((char*)malloc(len + 5), argv[0]), ".exe");
+  }
 #endif
 
   /* argv[1] is argv[0] + ".bc". */





More information about the llvm-commits mailing list