From 9c3e1644e9b668dcf39755c9317c0b0a1e6ff5aa Mon Sep 17 00:00:00 2001 From: Greg Price Date: Mon, 1 Apr 2013 18:57:22 -0700 Subject: [PATCH] Better target the shorten-64-to-32 workaround (#325, #319) The previous version of this logic was causing us to pass the flag when * clang is on the PATH, and * $CC, or 'clang' if CC unset, accepts the flag. But this is totally wrong if we have clang installed, haven't set $CC, and are going to end up using gcc. We end up passing the flag to gcc, which rejects it. The real fix is to put this in the autoconf goo in MRI upstream -- the only correct way to decide whether to pass this flag is after we know exactly what compiler we're using and can test if that compiler accepts the flag. But we can do better than before by approximating autoconf's choice of compiler as $CC if set, 'cc' otherwise (which will typically be a symlink to gcc or clang or another.) Fixes: https://github.com/sstephenson/ruby-build/issues/319 and #325, which is a dupe. --- bin/ruby-build | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/ruby-build b/bin/ruby-build index 6663fc2851..946989b476 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -662,11 +662,10 @@ else TMP="${TMPDIR%/}" fi -# Work around warnings building Ruby 2.0 on Clang 2.x -if type clang &>/dev/null; then - if "${CC:-clang}" -x c /dev/null -E -Wno-error=shorten-64-to-32 &>/dev/null; then - RUBY_CFLAGS="$RUBY_CFLAGS -Wno-error=shorten-64-to-32" - fi +# Work around warnings building Ruby 2.0 on Clang 2.x: +# pass -Wno-error=shorten-64-to-32 if the compiler accepts it. +if "${CC:-cc}" -x c /dev/null -E -Wno-error=shorten-64-to-32 &>/dev/null; then + RUBY_CFLAGS="$RUBY_CFLAGS -Wno-error=shorten-64-to-32" fi if [ -z "$MAKE" ]; then