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

Chris Lattner sabre at nondot.org
Fri May 23 07:57:20 PDT 2003


On Fri, 23 May 2003, Brian R. Gaeke wrote:
> 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?

Make sense to me.  If you chose to you could just forward substitute ".bc"
in everywhere you use ByteCodeFileSuffix (or 3 if looking at the length),
but performance isn't exactly critical here.  :)

Go ahead and commit.  :)

-Chris

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);


-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/





More information about the llvm-bugs mailing list