diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-04-14 10:27:16 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-04-17 11:11:39 -0700 |
| commit | 682c401045fbc24ecec8cab0e315293192825c69 (patch) | |
| tree | 118b9ede74fd44779d9255849292c0f992abb3ac | |
| parent | 32a81d1e161a8b4a498c88ddb79955775d18fbfd (diff) | |
| download | rust-682c401045fbc24ecec8cab0e315293192825c69.tar.gz rust-682c401045fbc24ecec8cab0e315293192825c69.zip | |
configure: Enable clang for older OSX gcc versions
OSX often has a more recent version of clang than it does for GCC. When an older version of gcc is detected on OSX, the --enable-clang flag is implicitly enabled.
| -rwxr-xr-x | configure | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/configure b/configure index 5b6c26daaa3..8d0116cb0ca 100755 --- a/configure +++ b/configure @@ -579,26 +579,32 @@ then CFG_ENABLE_CLANG=1 putvar CFG_ENABLE_CLANG else - # on OS X, with xcode 5 and newer, certain developers may have - # cc, gcc and g++ point to a mixture of clang and gcc - # if so, this will create very strange build errors - # this last stanza is to detect some such problems and save the future rust - # contributor some time solving that issue. - # this detection could be generalized to other OSes aside from OS X - # but the issue seems most likely to happen on OS X - - chk_cc () { - $1 --version 2> /dev/null | grep -q $2 - } - # check that gcc, cc and g++ all point to the same compiler. - # note that for xcode 5, g++ points to clang, not clang++ - if !((chk_cc gcc clang && chk_cc g++ clang) || - (chk_cc gcc gcc &&( chk_cc g++ g++ || chk g++ gcc))) then - err "the gcc and g++ in your path point to different compilers. -Check which versions are in your path with cc --version and g++ --version. -To resolve this problem, either fix your PATH or run configure with --enable-clang" - fi + if [ $("$CFG_GCC" --version 2>&1 | grep -c ' 4\.[0-6]') -ne 0 ]; then + step_msg "older GCC found, using clang instead" + CFG_ENABLE_CLANG=1 + putvar CFG_ENABLE_CLANG + else + # on OS X, with xcode 5 and newer, certain developers may have + # cc, gcc and g++ point to a mixture of clang and gcc + # if so, this will create very strange build errors + # this last stanza is to detect some such problems and save the future rust + # contributor some time solving that issue. + # this detection could be generalized to other OSes aside from OS X + # but the issue seems most likely to happen on OS X + + chk_cc () { + $1 --version 2> /dev/null | grep -q $2 + } + # check that gcc, cc and g++ all point to the same compiler. + # note that for xcode 5, g++ points to clang, not clang++ + if !((chk_cc gcc clang && chk_cc g++ clang) || + (chk_cc gcc gcc &&( chk_cc g++ g++ || chk g++ gcc))) then + err "the gcc and g++ in your path point to different compilers. + Check which versions are in your path with cc --version and g++ --version. + To resolve this problem, either fix your PATH or run configure with --enable-clang" + fi + fi fi fi |
