Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Commit

Permalink
revert to homebrew-version gcc48.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
tarebyte committed Jul 19, 2014
1 parent 17331ba commit 3ded2c9
Showing 1 changed file with 66 additions and 87 deletions.
153 changes: 66 additions & 87 deletions files/brews/gcc48.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
require "formula"
require 'formula'

class Gcc48 < Formula
def arch
if Hardware::CPU.type == :intel
if MacOS.prefer_64_bit?
"x86_64"
'x86_64'
else
"i686"
'i686'
end
elsif Hardware::CPU.type == :ppc
if MacOS.prefer_64_bit?
"powerpc64"
'powerpc64'
else
"powerpc"
'powerpc'
end
end
end
Expand All @@ -21,40 +21,41 @@ def osmajor
`uname -r`.chomp
end

homepage "http://gcc.gnu.org"
url "http://ftpmirror.gnu.org/gcc/gcc-4.8.3/gcc-4.8.3.tar.bz2"
mirror "ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.8.3/gcc-4.8.3.tar.bz2"
sha1 "da0a2b9ec074f2bf624a34f3507f812ebb6e4dce"
homepage 'http://gcc.gnu.org'
url 'http://ftpmirror.gnu.org/gcc/gcc-4.8.3/gcc-4.8.3.tar.bz2'
mirror 'ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.8.3/gcc-4.8.3.tar.bz2'
sha1 'da0a2b9ec074f2bf624a34f3507f812ebb6e4dce'
version '4.8.3-boxen1'

version "4.8.3-boxen1"

head "svn://gcc.gnu.org/svn/gcc/branches/gcc-4_8-branch"
head 'svn://gcc.gnu.org/svn/gcc/branches/gcc-4_8-branch'

bottle do
sha1 "0e4040eb5a667ecacba2b7e7c71a7a868a593386" => :mavericks
sha1 "78374c616c427d49e29656579d6a143cbb468b0b" => :mountain_lion
sha1 "b3320839c172d7abc4f9889a67822e604e080a75" => :lion
sha1 '97867c4e70e4eeaf98d42ad06a23a189abec3cc7' => :tiger_g3
sha1 'ddda3f3dae94812ef263a57fd2abe85bf97c3ca0' => :tiger_altivec
sha1 '3a01572c16a8bcde4fb53554790b350c31161309' => :tiger_g4e
sha1 '063016966578350a6048e22b45e468c3dc991619' => :leopard_g3
sha1 '16a24c342514a4917533c172cddbfb3156153adc' => :leopard_altivec
end

option "with-java", "Build the gcj compiler"
option "with-all-languages", "Enable all compilers and languages, except Ada"
option "with-nls", "Build with native language support (localization)"
option "with-profiled-build", "Make use of profile guided optimization when bootstrapping GCC"
option "without-fortran", "Build without the gfortran compiler"
option 'enable-fortran', 'Build the gfortran compiler'
option 'enable-java', 'Build the gcj compiler'
option 'enable-all-languages', 'Enable all compilers and languages, except Ada'
option 'enable-nls', 'Build with native language support (localization)'
option 'enable-profiled-build', 'Make use of profile guided optimization when bootstrapping GCC'
# enabling multilib on a host that can't run 64-bit results in build failures
option "without-multilib", "Build without multilib support" if MacOS.prefer_64_bit?
option 'disable-multilib', 'Build without multilib support' if MacOS.prefer_64_bit?

depends_on 'gmp4'
depends_on 'libmpc08'
depends_on 'mpfr2'
depends_on 'cloog018'
depends_on 'isl011'
depends_on "ecj" if build.with?("java") || build.with?("all-languages")
depends_on 'ecj' if build.include? 'enable-java' or build.include? 'enable-all-languages'

if MacOS.version < :leopard
# The as that comes with Tiger isn't capable of dealing with the
# PPC asm that comes in libitm
depends_on "cctools" => :build
depends_on 'cctools' => :build
# GCC 4.8.1 incorrectly determines that _Unwind_GetIPInfo is available on
# Tiger, resulting in a failed build
# Fixed upstream: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58710
Expand All @@ -63,45 +64,43 @@ def osmajor

fails_with :gcc_4_0

# GCC bootstraps itself, so it is OK to have an incompatible C++ stdlib
cxxstdlib_check :skip

# The bottles are built on systems with the CLT installed, and do not work
# out of the box on Xcode-only systems due to an incorrect sysroot.
def pour_bottle?
MacOS::CLT.installed?
end

def install
# GCC bootstraps itself, so it is OK to have an incompatible C++ stdlib
cxxstdlib_check :skip

# GCC will suffer build errors if forced to use a particular linker.
ENV.delete "LD"
ENV.delete 'LD'

if MacOS.version < :leopard
ENV["AS"] = ENV["AS_FOR_TARGET"] = "#{Formula["cctools"].bin}/as"
end

# C, C++, ObjC compilers are always built
languages = %w[c c++ objc obj-c++]
if build.include? 'enable-all-languages'
# Everything but Ada, which requires a pre-existing GCC Ada compiler
# (gnat) to bootstrap. GCC 4.6.0 add go as a language option, but it is
# currently only compilable on Linux.
languages = %w[c c++ fortran java objc obj-c++]
else
# C, C++, ObjC compilers are always built
languages = %w[c c++ objc obj-c++]

# Everything but Ada, which requires a pre-existing GCC Ada compiler
# (gnat) to bootstrap. GCC 4.6.0 add go as a language option, but it is
# currently only compilable on Linux.
languages << "fortran" if build.with?("fortran") || build.with?("all-languages")
languages << "java" if build.with?("java") || build.with?("all-languages")
languages << 'fortran' if build.include? 'enable-fortran'
languages << 'java' if build.include? 'enable-java'
end

version_suffix = version.to_s.slice(/\d\.\d/)

args = [
"--build=#{arch}-apple-darwin#{osmajor}",
"--prefix=#{prefix}",
"--enable-languages=#{languages.join(",")}",
"--enable-languages=#{languages.join(',')}",
# Make most executables versioned to avoid conflicts.
"--program-suffix=-#{version_suffix}",
"--with-gmp=#{Formula["gmp"].opt_prefix}",
"--with-mpfr=#{Formula["mpfr"].opt_prefix}",
"--with-mpc=#{Formula["libmpc"].opt_prefix}",
"--with-cloog=#{Formula["cloog"].opt_prefix}",
"--with-isl=#{Formula["isl"].opt_prefix}",
"--with-gmp=#{Formula["gmp4"].opt_prefix}",
"--with-mpfr=#{Formula["mpfr2"].opt_prefix}",
"--with-mpc=#{Formula["libmpc08"].opt_prefix}",
"--with-cloog=#{Formula["cloog018"].opt_prefix}",
"--with-isl=#{Formula["isl011"].opt_prefix}",
"--with-system-zlib",
# This ensures lib, libexec, include are sandboxed so that they
# don't wander around telling little children there is no Santa
Expand All @@ -115,7 +114,7 @@ def install
# raise errors. But still a good idea to include.
"--disable-werror",
"--with-pkgversion=Homebrew #{name} #{pkg_version} #{build.used_options*" "}".strip,
"--with-bugurl=https://github.com/Homebrew/homebrew/issues",
"--with-bugurl=https://github.com/Homebrew/homebrew-versions/issues",
]

# "Building GCC with plugin support requires a host that supports
Expand All @@ -124,67 +123,67 @@ def install

# Otherwise make fails during comparison at stage 3
# See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45248
args << "--with-dwarf2" if MacOS.version < :leopard
args << '--with-dwarf2' if MacOS.version < :leopard

args << "--disable-nls" if build.without? "nls"
args << '--disable-nls' unless build.include? 'enable-nls'

if build.with?("java") || build.with?("all-languages")
if build.include? 'enable-java' or build.include? 'enable-all-languages'
args << "--with-ecj-jar=#{Formula["ecj"].opt_prefix}/share/java/ecj.jar"
end

if build.without?("multilib") || !MacOS.prefer_64_bit?
args << "--disable-multilib"
if !MacOS.prefer_64_bit? || build.include?('disable-multilib')
args << '--disable-multilib'
else
args << "--enable-multilib"
args << '--enable-multilib'
end

mkdir "build" do
mkdir 'build' do
unless MacOS::CLT.installed?
# For Xcode-only systems, we need to tell the sysroot path.
# "native-system-header's will be appended
# 'native-system-header's will be appended
args << "--with-native-system-header-dir=/usr/include"
args << "--with-sysroot=#{MacOS.sdk_path}"
end

system "../configure", *args
system '../configure', *args

if build.with? "profiled-build"
if build.include? 'enable-profiled-build'
# Takes longer to build, may bug out. Provided for those who want to
# optimise all the way to 11.
system "make", "profiledbootstrap"
system 'make profiledbootstrap'
else
system "make", "bootstrap"
system 'make bootstrap'
end

# At this point `make check` could be invoked to run the testsuite. The
# deja-gnu and autogen formulae must be installed in order to do this.

system "make", "install"

if build.with?("fortran") || build.with?("all-languages")
bin.install_symlink bin/"gfortran-#{version_suffix}" => "gfortran"
end
system 'make install'
end

# Handle conflicts between GCC formulae and avoid interfering
# with system compilers.
# Handle conflicts between GCC formulae

# Since GCC 4.8 libffi stuff are no longer shipped.

# Rename libiberty.a.
Dir.glob(prefix/"**/libiberty.*") { |file| add_suffix file, version_suffix }

# Rename man7.
Dir.glob(man7/"*.7") { |file| add_suffix file, version_suffix }

# Even when suffixes are appended, the info pages conflict when
# install-info is run. TODO fix this.
info.rmtree

# Rename java properties
if build.with?("java") || build.with?("all-languages")
if build.include? 'enable-java' or build.include? 'enable-all-languages'
config_files = [
"#{lib}/logging.properties",
"#{lib}/security/classpath.security",
"#{lib}/i386/logging.properties",
"#{lib}/i386/security/classpath.security"
]

config_files.each do |file|
add_suffix file, version_suffix if File.exist? file
end
Expand All @@ -197,26 +196,6 @@ def add_suffix file, suffix
base = File.basename(file, ext)
File.rename file, "#{dir}/#{base}-#{suffix}#{ext}"
end

test do
if build.with?("fortran") || build.with?("all-languages")
fixture = <<-EOS.undent
integer,parameter::m=10000
real::a(m), b(m)
real::fact=0.5
do concurrent (i=1:m)
a(i) = a(i) + fact*b(i)
end do
print *, "done"
end
EOS
(testpath/"in.f90").write(fixture)
system "#{bin}/gfortran", "-c", "in.f90"
system "#{bin}/gfortran", "-o", "test", "in.o"
assert_equal "done", `./test`.strip
end
end
end

__END__
Expand Down

0 comments on commit 3ded2c9

Please sign in to comment.