From e38155a6daf7c709c1b9ce5900665d1eed1762f5 Mon Sep 17 00:00:00 2001 From: Yuichiro NAITO Date: Wed, 18 Jan 2017 11:02:37 +0900 Subject: [PATCH 1/2] Fix to build with gcc on FreeBSD --- bin/ruby-build | 19 +++++++++++-------- test/compiler.bats | 6 +++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/bin/ruby-build b/bin/ruby-build index 55fc36ea..d64ed3b1 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -1236,14 +1236,17 @@ if [ -n "$noexec" ]; then exit 1 fi -# Work around warnings building Ruby 2.0 on Clang 2.x: -# pass -Wno-error=shorten-64-to-32 if the compiler accepts it. -# -# When we set CFLAGS, Ruby won't apply its default flags, though. Since clang -# builds 1.9.x and 2.x only, where -O3 is default, we can safely set that flag. -# Ensure it's the first flag since later flags take precedence. -if "${CC:-cc}" -x c /dev/null -E -Wno-error=shorten-64-to-32 &>/dev/null; then - RUBY_CFLAGS="-O3 -Wno-error=shorten-64-to-32 $RUBY_CFLAGS" +# Apply following work around, if gcc is not available. +if [ -z "$(locate_gcc)" ]; then + # Work around warnings building Ruby 2.0 on Clang 2.x: + # pass -Wno-error=shorten-64-to-32 if the compiler accepts it. + # + # When we set CFLAGS, Ruby won't apply its default flags, though. Since clang + # builds 1.9.x and 2.x only, where -O3 is default, we can safely set that flag. + # Ensure it's the first flag since later flags take precedence. + if "${CC:-cc}" -x c /dev/null -E -Wno-error=shorten-64-to-32 &>/dev/null; then + RUBY_CFLAGS="-O3 -Wno-error=shorten-64-to-32 $RUBY_CFLAGS" + fi fi if [ -z "$MAKE" ]; then diff --git a/test/compiler.bats b/test/compiler.bats index 970e5193..33c6f202 100755 --- a/test/compiler.bats +++ b/test/compiler.bats @@ -10,7 +10,7 @@ export -n RUBY_CONFIGURE_OPTS @test "require_gcc on OS X 10.9" { stub uname '-s : echo Darwin' stub sw_vers '-productVersion : echo 10.9.5' - stub gcc '--version : echo 4.2.1' + stub gcc '--version : echo 4.2.1' '--version : echo 4.2.1' run_inline_definition <&2; echo 4.2.1' + stub gcc '--version : echo warning >&2; echo 4.2.1' '--version : echo warning >&2; echo 4.2.1' run_inline_definition < Date: Thu, 19 Jan 2017 10:05:20 +0900 Subject: [PATCH 2/2] Fix comment --- bin/ruby-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ruby-build b/bin/ruby-build index d64ed3b1..84ea71d7 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -1236,7 +1236,7 @@ if [ -n "$noexec" ]; then exit 1 fi -# Apply following work around, if gcc is not available. +# Apply following work around, if gcc is not installed. if [ -z "$(locate_gcc)" ]; then # Work around warnings building Ruby 2.0 on Clang 2.x: # pass -Wno-error=shorten-64-to-32 if the compiler accepts it.