Mikhail Glushenkov wrote:> Hi Sanjiv, > > 2009/6/18 Sanjiv Gupta <sanjiv.gupta at microchip.com>: > >> Hi Mikhail, >> Thanks for your wonderful help so far. I have few more questions to ask: >> >> How do I modify the driver to pick tools from where the driver itself >> resides, rather than from the PATH? >> Do I need to write some C++ code to customize such behaviors? >> > > Yes, this is what hooks are for. You're supposed to change the > cmd_line property to something like this: > > (cmd_line "$CALL(PrependCustomizedPath, 'toolname') --tool --options") > > The PrependCustomizedPath function above is implemented in C++ (just > drop a .cpp file into the plugin directory). > >Hi Mikhail, I want to retrieve the value of argv[0] (which was passed to main function of the driver) in PrependCustomizedPath. Do we have some standard name for argv[0] in tablegen? - Sanjiv
Hi Sanjiv, 2009/6/29 Sanjiv Gupta <sanjiv.gupta at microchip.com>:> Hi Mikhail, > > I want to retrieve the value of argv[0] (which was passed to main function > of the driver) in PrependCustomizedPath. > Do we have some standard name for argv[0] in tablegen?This is not possible ATM, but is easy to add (assign argv to a global variable Argv in main, then refer to Argv via an extern declaration in PrependCustomizedPath; btw, the same mechanism can be used to refer to command-line options). On the other hand, you shouldn't have to condition on argv[0]. Look at what the Base plugin does to choose the correct linker options (think 'gcc' versus 'g++'). By default, this information is deduced from the input file names (if there are files ending with .cpp/.cxx/etc, we choose the C++ linker), but the C++ linker can also be forced with the -linker=c++ option. Then the analog of the 'g++' command can be implemented as an alias to 'llvmc -linker=c++'. I prefer to do things this way, that's why it's not possible to access argv[0] from tablegen:-) -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments
Hi Sanjiv, 2009/6/29 Sanjiv Gupta <sanjiv.gupta at microchip.com>:> I want to retrieve the value of argv[0] (which was passed to main function > of the driver) in PrependCustomizedPath.I've added a way to access argv[0] in hooks: http://thread.gmane.org/gmane.comp.compilers.llvm.cvs/50789 -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments
Mikhail Glushenkov wrote:> Hi Sanjiv, > > 2009/6/29 Sanjiv Gupta <sanjiv.gupta at microchip.com>: > >> I want to retrieve the value of argv[0] (which was passed to main function >> of the driver) in PrependCustomizedPath. >> > > I've added a way to access argv[0] in hooks: > http://thread.gmane.org/gmane.comp.compilers.llvm.cvs/50789 > > >Thanks for that. My purpose is not to depend upon the "executable name". I wanted to be able to retrieve the absolute path from where the executable was picked as that location will contain other stuff (libs and header files) which I need to pass to the tools that driver executes. Your changes will serve the purpose. Thanks, Sanjiv
Mikhail Glushenkov wrote:> Hi Sanjiv, > > 2009/6/29 Sanjiv Gupta <sanjiv.gupta at microchip.com>: > >> I want to retrieve the value of argv[0] (which was passed to main function >> of the driver) in PrependCustomizedPath. >> > > I've added a way to access argv[0] in hooks: > http://thread.gmane.org/gmane.comp.compilers.llvm.cvs/50789 > > >One more thing: How to make --save-temps always on, so that users won't have to specify it every time they invoke the driver? - Sanjiv