Unverified Commit 2dec28ca authored by Mislav Marohnić's avatar Mislav Marohnić Committed by GitHub
Browse files

Merge pull request #2232 from rbenv/clang-cleanup

Remove `require_gcc` implementation
parents f170c16c a4c6878f
Loading
Loading
Loading
Loading
+3 −112
Original line number Diff line number Diff line
@@ -886,110 +886,14 @@ require_java() {
  return 1
}

# keep for backwards compatibility
# Kept for backward compatibility with JRuby <= 9.1.17 definitions.
require_java7() {
  require_java 7
}

# Kept for backward compatibility with 3rd-party Ruby definitions.
require_gcc() {
  local gcc="$(locate_gcc || true)"

  if [ -z "$gcc" ]; then
    { echo
      colorize 1 "ERROR"
      echo ": This package must be compiled with GCC, but ruby-build couldn't"
      echo "find a suitable \`gcc\` executable on your system. Please install GCC"
      echo "and try again."
      echo

      if is_mac; then
        colorize 1 "DETAILS"
        echo ": Apple no longer includes the official GCC compiler with Xcode"
        echo "as of version 4.2. Instead, the \`gcc\` executable is a symlink to"
        echo "\`llvm-gcc\`, a modified version of GCC which outputs LLVM bytecode."
        echo
        echo "For most programs the \`llvm-gcc\` compiler works fine. However,"
        echo "versions of Ruby older than 1.9.3-p125 are incompatible with"
        echo "\`llvm-gcc\`. To build older versions of Ruby you must have the official"
        echo "GCC compiler installed on your system."
        echo

        colorize 1 "TO FIX THE PROBLEM"
        if type brew &>/dev/null; then
          echo ": Install Homebrew's GCC package with this"
          echo -n "command: "
          colorize 4 "brew install gcc@4.9"
        else
          echo ": Install the official GCC compiler using these"
          echo -n "packages: "
          colorize 4 "https://github.com/kennethreitz/osx-gcc-installer/downloads"
        fi

        echo
        echo
        echo "You will need to install the official GCC compiler to build older"
        echo "versions of Ruby even if you have installed Apple's Command Line Tools"
        echo "for Xcode package. The Command Line Tools for Xcode package only"
        echo "includes \`llvm-gcc\`."
      fi
    } >&3
    return 1
  fi

  export CC="$gcc"
  if is_mac -ge 1010; then
    export MACOSX_DEPLOYMENT_TARGET=10.9
  fi
}

locate_gcc() {
  local gcc gccs
  IFS=: gccs=($(gccs_in_path))
  IFS="$OLDIFS"

  verify_gcc "$CC" ||
  verify_gcc "$(command -v gcc || true)" || {
    for gcc in "${gccs[@]}"; do
      verify_gcc "$gcc" && break || true
    done
  }

  return 1
}

gccs_in_path() {
  local gcc path paths
  local gccs=()
  IFS=: paths=($PATH)
  IFS="$OLDIFS"

  shopt -s nullglob
  for path in "${paths[@]}"; do
    for gcc in "$path"/gcc-*; do
      gccs["${#gccs[@]}"]="$gcc"
    done
  done
  shopt -u nullglob

  printf :%s "${gccs[@]}"
}

verify_gcc() {
  local gcc="$1"
  if [ -z "$gcc" ]; then
    return 1
  fi

  local version="$("$gcc" --version 2>/dev/null || true)"
  if [ -z "$version" ]; then
    return 1
  fi

  if echo "$version" | grep LLVM >/dev/null; then
    return 1
  fi

  echo "$gcc"
  local stub=1
}

require_llvm() {
@@ -1489,19 +1393,6 @@ if [ -n "$noexec" ]; then
  exit 1
fi

# 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.
  #
  # 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
  if is_freebsd; then
    # Workaround for Ruby bug 16331: https://bugs.ruby-lang.org/issues/16331
+0 −1
Original line number Diff line number Diff line
require_gcc
install_package "ruby-1.8.5-p113" "https://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.5-p113.tar.bz2#216600f9ad07648c501766a25069009c5c543010821da2ad916dd2ca808efd01" warn_eol auto_tcltk standard
install_package "rubygems-1.3.7" "https://rubygems.org/rubygems/rubygems-1.3.7.tgz#388b90ae6273f655507b10c8ba6bee9ea72e7d49c3e610025531cb8c3ba67c9d" ruby
+0 −1
Original line number Diff line number Diff line
require_gcc
install_package "ruby-1.8.5-p114" "https://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.5-p114.tar.bz2#c503ae8eb47db72f78fb7a79fe1874ffef40a7094f7e803bacbf994a924244d9" warn_eol auto_tcltk standard
install_package "rubygems-1.3.7" "https://rubygems.org/rubygems/rubygems-1.3.7.tgz#388b90ae6273f655507b10c8ba6bee9ea72e7d49c3e610025531cb8c3ba67c9d" ruby
+0 −1
Original line number Diff line number Diff line
require_gcc
install_package "ruby-1.8.5-p115" "https://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.5-p115.tar.bz2#3b5b799d6445b4ec8bc8b2944c6797dbd031b22e1756c9ae8b08c1f5d6cdc398" warn_eol auto_tcltk standard
install_package "rubygems-1.3.7" "https://rubygems.org/rubygems/rubygems-1.3.7.tgz#388b90ae6273f655507b10c8ba6bee9ea72e7d49c3e610025531cb8c3ba67c9d" ruby
+0 −1
Original line number Diff line number Diff line
require_gcc
install_package "ruby-1.8.5-p231" "https://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.5-p231.tar.bz2#b31a8db0a3b538c28bca1c9b08a07eb55a39547fdaad00c045f073851019639c" warn_eol auto_tcltk standard
install_package "rubygems-1.3.7" "https://rubygems.org/rubygems/rubygems-1.3.7.tgz#388b90ae6273f655507b10c8ba6bee9ea72e7d49c3e610025531cb8c3ba67c9d" ruby
Loading