where should target specific flags be set?

Hi

I am needing to add “-fno-use-cxa-atexit” for the xcore target.
What is the correct mechanism for setting default flags for a target in general?

Should this be done in addClangTargetOptions() viz:
void XCore::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const {
CC1Args.push_back("-nostdsysteminc");
CC1Args.push_back("-fno-use-cxa-atexit");
}

Or in Clang::ConstructJob() viz:
// -fuse-cxa-atexit is default.
if (!Args.hasFlag(options::OPT_fuse_cxa_atexit,
options::OPT_fno_use_cxa_atexit,
getToolChain().getTriple().getOS() != llvm::Triple::Cygwin &&
getToolChain().getTriple().getOS() != llvm::Triple::MinGW32 &&
getToolChain().getArch() != llvm::Triple::hexagon &&
getToolChain().getArch() != llvm::Triple::xcore) ||
KernelOrKext)
CmdArgs.push_back("-fno-use-cxa-atexit");

I am guessing it depends upon the flag and how it is used.
Would setting a default best done in Clang::ConstructJob(), where it can be over-ridden by input from the user?
Would setting an absolute flag best be done in addClangTargetOptions()?
Also, binary-flags (with a “no_” option) I imagine would tend to follow the ‘default’ rather than the ‘absolute’ rule.

Thus, “-nostdsysteminc” is correctly placed in addClangTargetOptions()
and “-fno-use-cxa-atexit” should be placed in Clang::ConstructJob().

cheers

Robert