In the base use case for Purify on Unix, it only needs to be run as the linker when linking the executable binary:
purify gcc -o out out.o -lmyLib
I've provided a quick and dirty patch that will add a "purify" flag to the "linker" element. When this is specified as true, the LinkerDef will store the flag and when the CommandLineLinker is setting up its command, the purify flag will be retrieved and stored as a member boolean. When the command is being set up via the "prepareArguments" call, if the purify flag is set to 'true', the "purify" command will be placed as the first argument in the map. The other arguments will then follow normally.
Thus, the command will be executed as "purify <linker> <linker args>", which will allow purify to instrument the code.
This is a pretty quick hack, so it may not be the best method to include a purify feature, and it doesn't work for compiling in purify's libraries (for operator new and delete), but it works for the base use case.
The diffs are attached.
Thanks!
--Mike Micucci
--Senior Software Engineer - Roguewave Software Inc.
Diffs for purify patch
Logged In: YES
user_id=1869105
Originator: YES
Please also bear in mind that any extra calls to purify have to be hardcoded into the CommandLineLinker with this patch (such as "-handle-calls-to-java"). Add the argument right after the "purify" is added to the arg list. For example:
allArgs[index++] = "purify";
allArgs[index++] = "-handle-calls-to-java";
And make sure to increment the arg count by 2 instead of one:
if (this.purify) {
allArgsCount+=2;
}
A better solution would be to allow purify args to be passed in via elements under the linker element.
This solution is also pretty hacked. Incorporating a purify flag into the cc element, the compiler element, and the linker element and allowing different linkers to specify their own purify options via the linker elements would probably be better, although it seems like it'd be a non-trivial amount of work.
Thanks!
--Mike Micucci
--Senior Software Engineer - Roguewave Software Inc.