diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-06-15 12:07:01 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-06-15 12:07:01 +0000 |
commit | bddf2fd6999c0d1e579c8ec7a8638ed81d9762c9 (patch) | |
tree | b9717eba858f3ff6e47e8821a6271b378ed170a0 /llvm/tools/llvm-stub/llvm-stub.c | |
parent | 5037fe21aaa73942d70920752c54048eda125b69 (diff) | |
download | bcm5719-llvm-bddf2fd6999c0d1e579c8ec7a8638ed81d9762c9.tar.gz bcm5719-llvm-bddf2fd6999c0d1e579c8ec7a8638ed81d9762c9.zip |
Make sure that the current executable filename has "exe" suffix on Windows.
llvm-svn: 52286
Diffstat (limited to 'llvm/tools/llvm-stub/llvm-stub.c')
-rw-r--r-- | llvm/tools/llvm-stub/llvm-stub.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/tools/llvm-stub/llvm-stub.c b/llvm/tools/llvm-stub/llvm-stub.c index 7e123cf6074..91537a0b9cc 100644 --- a/llvm/tools/llvm-stub/llvm-stub.c +++ b/llvm/tools/llvm-stub/llvm-stub.c @@ -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 @@ int main(int argc, char** argv) { /* 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". */ |