[LLVMdev] lli should not put .bc in argv[0]

Brian R. Gaeke gaeke at uiuc.edu
Fri May 23 00:32:01 PDT 2003


When you run a program foo linked with gccld (i.e., by running the script
"foo" it outputs which runs lli) it passes foo.bc instead of foo as the
argv[0] for the program. This is surprising to the user, who is expecting
that a program started by running "./foo" will call itself "./foo", not
"./foo.bc".

Fixed by removing ".bc" from the end of InputFile if it is there, in
tools/lli/lli.cpp:main().

Ok to commit?

-- 
gaeke at uiuc.edu

Index: lli.cpp
===================================================================
RCS file: /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/tools/lli/lli.cpp,v
retrieving revision 1.17
diff -u -a -d -p -r1.17 lli.cpp
--- lli.cpp	12 May 2003 14:31:57 -0000	1.17
+++ lli.cpp	23 May 2003 04:45:39 -0000
@@ -88,6 +88,13 @@ int main(int argc, char** argv) {
     EE = ExecutionEngine::createInterpreter(M, Config, DebugMode, TraceMode);
 
   // Add the module name to the start of the argv vector...
+  // But delete .bc first, since programs (and users) might not expect to
+  // see it.
+  const std::string ByteCodeFileSuffix (".bc");
+  if (InputFile.rfind (ByteCodeFileSuffix) ==
+      InputFile.length () - ByteCodeFileSuffix.length ()) {
+    InputFile.erase (InputFile.length () - ByteCodeFileSuffix.length ());
+  }
   InputArgv.insert(InputArgv.begin(), InputFile);
 
   // Run the main function!



More information about the llvm-dev mailing list