diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-04-26 02:10:51 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-04-26 02:10:51 +0000 |
commit | 4f50c50e783461ea1ec47dd6fe9be10aafcd76ad (patch) | |
tree | fd13ec10fa9364e7e68ffcaccd32d56488200b63 /lib/Driver/Tools.cpp | |
parent | 86e6fdcf1a04edc4c24f53f9dbacf7e1b52f306d (diff) |
Fix a long-standing bug where Clang had a different default from GCC on
Linux and other (non-Darwin) platforms and have it use -fmath-errno by
default (for better or worse).
Darwin has seen the light here and uses -fno-math-errno by default, this
patch preserves that.
If any maintainers for a non-Linux platform would also like to opt-in to
-fno-math-errno by default, I'm happy to add folks, but we're currently
getting buts and misleading comparisons with GCC due to this difference
in behavior on Linux at least.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155607 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Tools.cpp')
-rw-r--r-- | lib/Driver/Tools.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index b61b8dcf2d..13d9820159 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1617,16 +1617,15 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, A->getOption().getID() != options::OPT_fhonor_nans) CmdArgs.push_back("-menable-no-nans"); - // -fno-math-errno is default. - bool MathErrno = false; + // -fno-math-errno is default on Darwin. Other platforms, -fmath-errno is the + // default. + bool MathErrno = !getToolChain().getTriple().isOSDarwin(); if (Arg *A = Args.getLastArg(options::OPT_ffast_math, options::OPT_fmath_errno, - options::OPT_fno_math_errno)) { - if (A->getOption().getID() == options::OPT_fmath_errno) { - CmdArgs.push_back("-fmath-errno"); - MathErrno = true; - } - } + options::OPT_fno_math_errno)) + MathErrno = A->getOption().getID() == options::OPT_fmath_errno; + if (MathErrno) + CmdArgs.push_back("-fmath-errno"); // There are several flags which require disabling very specific // optimizations. Any of these being disabled forces us to turn off the |