[cfe-dev] Filtering out a command line argument in the driver.

Alexander Potapenko glider at google.com
Fri Nov 25 00:20:48 PST 2011


[sorry for double-posting -- now with a proper subject]

Hi everyone,
While adding AddressSanitizer support
totools/clang/lib/Driver/Tools.cpp I've ran into the following
problem.
On Darwin ASan does not play well with the binaries having the MH_PIE
bit set.Because of it we need to add the -no_pie flag to the list of
flagspassed to ld (otherwise we'll have MH_PIE on OS X Lion)as well as
remove the -pie flag from the list of options (if both -pieand -no_pie
are passed to ld, the results depend on their order).
However the arguments are passed everywhere as a constant ArgList:
3501 void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
3502                                 const InputInfo &Output,
3503                                 const InputInfoList &Inputs,
3504                                 const ArgList &Args,
3505                                 const char *LinkingOutput) const {

, so it's not a good idea to just call Args.eraseArg().
What's the preferred way of not letting an argument make it into
thefinal CmdArgs of a link job?Should I copy the input ArgList and
filter it, or remove the "-pie"string directly from CmdArgs?
TIA,Alexander Potapenko
Software Engineer
Google Moscow




More information about the cfe-dev mailing list