Skip to content

Commit 682c401

Browse files
committed
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.
1 parent 32a81d1 commit 682c401

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

configure

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -579,26 +579,32 @@ then
579579
CFG_ENABLE_CLANG=1
580580
putvar CFG_ENABLE_CLANG
581581
else
582-
# on OS X, with xcode 5 and newer, certain developers may have
583-
# cc, gcc and g++ point to a mixture of clang and gcc
584-
# if so, this will create very strange build errors
585-
# this last stanza is to detect some such problems and save the future rust
586-
# contributor some time solving that issue.
587-
# this detection could be generalized to other OSes aside from OS X
588-
# but the issue seems most likely to happen on OS X
589-
590-
chk_cc () {
591-
$1 --version 2> /dev/null | grep -q $2
592-
}
593-
# check that gcc, cc and g++ all point to the same compiler.
594-
# note that for xcode 5, g++ points to clang, not clang++
595-
if !((chk_cc gcc clang && chk_cc g++ clang) ||
596-
(chk_cc gcc gcc &&( chk_cc g++ g++ || chk g++ gcc))) then
597-
err "the gcc and g++ in your path point to different compilers.
598-
Check which versions are in your path with cc --version and g++ --version.
599-
To resolve this problem, either fix your PATH or run configure with --enable-clang"
600-
fi
582+
if [ $("$CFG_GCC" --version 2>&1 | grep -c ' 4\.[0-6]') -ne 0 ]; then
583+
step_msg "older GCC found, using clang instead"
584+
CFG_ENABLE_CLANG=1
585+
putvar CFG_ENABLE_CLANG
586+
else
587+
# on OS X, with xcode 5 and newer, certain developers may have
588+
# cc, gcc and g++ point to a mixture of clang and gcc
589+
# if so, this will create very strange build errors
590+
# this last stanza is to detect some such problems and save the future rust
591+
# contributor some time solving that issue.
592+
# this detection could be generalized to other OSes aside from OS X
593+
# but the issue seems most likely to happen on OS X
594+
595+
chk_cc () {
596+
$1 --version 2> /dev/null | grep -q $2
597+
}
598+
# check that gcc, cc and g++ all point to the same compiler.
599+
# note that for xcode 5, g++ points to clang, not clang++
600+
if !((chk_cc gcc clang && chk_cc g++ clang) ||
601+
(chk_cc gcc gcc &&( chk_cc g++ g++ || chk g++ gcc))) then
602+
err "the gcc and g++ in your path point to different compilers.
603+
Check which versions are in your path with cc --version and g++ --version.
604+
To resolve this problem, either fix your PATH or run configure with --enable-clang"
605+
fi
601606

607+
fi
602608
fi
603609
fi
604610

0 commit comments

Comments
 (0)