Skip to content

Commit 35a8d61

Browse files
committed
gcc14 14.2.0
1 parent 5915ef7 commit 35a8d61

File tree

1 file changed

+229
-0
lines changed

1 file changed

+229
-0
lines changed

Library/Formula/gcc14.rb

+229
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
class Gcc14 < Formula
2+
def arch
3+
if Hardware::CPU.type == :intel
4+
if MacOS.prefer_64_bit?
5+
"x86_64"
6+
else
7+
"i686"
8+
end
9+
elsif Hardware::CPU.type == :ppc
10+
if MacOS.prefer_64_bit?
11+
"powerpc64"
12+
else
13+
"powerpc"
14+
end
15+
end
16+
end
17+
18+
def osmajor
19+
`uname -r`.chomp
20+
end
21+
22+
desc "GNU compiler collection"
23+
homepage "https://gcc.gnu.org"
24+
url "https://ftp.gnu.org/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz"
25+
mirror "https://ftpmirror.gnu.org/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz"
26+
sha256 "a7b39bc69cbf9e25826c5a60ab26477001f7c08d85cec04bc0e29cabed6f3cc9"
27+
28+
bottle do
29+
end
30+
31+
option "with-nls", "Build with native language support (localization)"
32+
# enabling multilib on a host that can't run 64-bit results in build failures
33+
option "without-multilib", "Build without multilib support" if MacOS.prefer_64_bit?
34+
# JIT fails to build on i386, or any platform for Tiger
35+
if !(Hardware::CPU.type == :intel && !MacOS.prefer_64_bit?) || MacOS.version > :leopard
36+
option "with-jit", "Build just-in-time compiler"
37+
end
38+
39+
depends_on :ld64
40+
# System texinfo is too old
41+
depends_on "texinfo" => :build
42+
depends_on "gmp"
43+
depends_on "libmpc"
44+
depends_on "mpfr"
45+
depends_on "isl"
46+
47+
if MacOS.version < :leopard
48+
# The as that comes with Tiger isn't capable of dealing with the
49+
# PPC asm that comes in libitm
50+
depends_on "cctools" => :build
51+
end
52+
53+
# Needs a newer tigerbrew-provided GCC to build
54+
fails_with :gcc_4_0
55+
fails_with :gcc
56+
fails_with :llvm
57+
58+
# GCC bootstraps itself, so it is OK to have an incompatible C++ stdlib
59+
cxxstdlib_check :skip
60+
61+
# Applied upstream: https://github.com/gcc-mirror/gcc/commit/1cfe4a4d0d4447b364815d5e5c889deb2e533669
62+
# Can remove in a later version.
63+
patch :p0 do
64+
url "https://github.com/macports/macports-ports/raw/b5a5b6679f59dcad1b21f66bb01e3f8a3a377b4b/lang/gcc14/files/darwin-ppc-fpu.patch"
65+
sha256 "7f14356f2e9efdf46503ca1156302c9b294db52569f4d56073267142b6d2ee71"
66+
end
67+
68+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117834
69+
patch :p0 do
70+
url "https://github.com/macports/macports-ports/raw/b5a5b6679f59dcad1b21f66bb01e3f8a3a377b4b/lang/gcc14/files/darwin8-define-PTHREAD_RWLOCK_INITIALIZER.patch"
71+
sha256 "57ffac38f4d5eb4d92634d9e7c339f961e3eb908d13a944d622bfc6915a4f435"
72+
end
73+
74+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117857
75+
patch :p0 do
76+
url "https://github.com/macports/macports-ports/raw/b5a5b6679f59dcad1b21f66bb01e3f8a3a377b4b/lang/gcc14/files/darwin8-ttyname_r.patch"
77+
sha256 "b81cbbe43e07a8575c1f626e76db18f4ca9e11772077b71fc5caacbfb8e24dbf"
78+
end
79+
80+
# The bottles are built on systems with the CLT installed, and do not work
81+
# out of the box on Xcode-only systems due to an incorrect sysroot.
82+
def pour_bottle?
83+
MacOS::CLT.installed?
84+
end
85+
86+
def version_suffix
87+
version.to_s.slice(/\d\d/)
88+
end
89+
90+
def install
91+
# GCC Bug 25127 for PowerPC
92+
# https://gcc.gnu.org/bugzilla//show_bug.cgi?id=25127
93+
# ../../../libgcc/unwind.inc: In function '_Unwind_RaiseException':
94+
# ../../../libgcc/unwind.inc:136:1: internal compiler error: in rs6000_emit_prologue, at config/rs6000/rs6000.c:26535
95+
# GCC 7 fails to install on 10.6 x86_64 at stage3
96+
# https://github.com/mistydemeo/tigerbrew/issues/554
97+
ENV.no_optimization
98+
99+
# Otherwise libstdc++ will be incorrectly tagged with cpusubtype 10 (G4e)
100+
# https://github.com/mistydemeo/tigerbrew/issues/538
101+
if Hardware::CPU.family == :g3 || ARGV.bottle_arch == :g3
102+
ENV.append_to_cflags "-force_cpusubtype_ALL"
103+
end
104+
105+
if MacOS.version < :leopard
106+
ENV["AS"] = ENV["AS_FOR_TARGET"] = "#{Formula["cctools"].bin}/as"
107+
end
108+
109+
# We avoiding building:
110+
# - Ada, which requires a pre-existing GCC Ada compiler to bootstrap
111+
# - Go, currently not supported on macOS
112+
# - BRIG
113+
languages = %w[c c++ objc obj-c++ fortran]
114+
115+
# JIT compiler is off by default, enabling it has performance cost
116+
languages << "jit" if build.with? "jit"
117+
118+
args = [
119+
"--build=#{arch}-apple-darwin#{osmajor}",
120+
"--prefix=#{prefix}",
121+
"--libdir=#{lib}/gcc/#{version_suffix}",
122+
"--enable-languages=#{languages.join(",")}",
123+
# Make most executables versioned to avoid conflicts.
124+
"--program-suffix=-#{version_suffix}",
125+
"--with-gmp=#{Formula["gmp"].opt_prefix}",
126+
"--with-mpfr=#{Formula["mpfr"].opt_prefix}",
127+
"--with-mpc=#{Formula["libmpc"].opt_prefix}",
128+
"--with-isl=#{Formula["isl"].opt_prefix}",
129+
"--enable-checking=release",
130+
"--with-pkgversion=Tigerbrew #{name} #{pkg_version} #{build.used_options*" "}".strip,
131+
"--with-bugurl=https://github.com/mistydemeo/tigerbrew/issues",
132+
]
133+
134+
# "Building GCC with plugin support requires a host that supports
135+
# -fPIC, -shared, -ldl and -rdynamic."
136+
args << "--enable-plugin" if MacOS.version > :leopard
137+
138+
# Otherwise make fails during comparison at stage 3
139+
# See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45248
140+
args << "--with-dwarf2" if MacOS.version < :leopard
141+
142+
args << "--disable-nls" if build.without? "nls"
143+
144+
if build.without?("multilib") || !MacOS.prefer_64_bit?
145+
args << "--disable-multilib"
146+
else
147+
args << "--enable-multilib"
148+
end
149+
150+
args << "--enable-host-shared" if build.with?("jit")
151+
152+
mkdir "build" do
153+
unless MacOS::CLT.installed?
154+
# For Xcode-only systems, we need to tell the sysroot path.
155+
# "native-system-headers" will be appended
156+
args << "--with-native-system-header-dir=/usr/include"
157+
args << "--with-sysroot=#{MacOS.sdk_path}"
158+
end
159+
160+
system "../configure", *args
161+
system "make"
162+
system "make", "install"
163+
end
164+
165+
# Handle conflicts between GCC formulae and avoid interfering
166+
# with system compilers.
167+
# Since GCC 4.8 libffi stuff are no longer shipped.
168+
# Rename man7.
169+
Dir.glob(man7/"*.7") { |file| add_suffix file, version_suffix }
170+
# Even when suffixes are appended, the info pages conflict when
171+
# install-info is run. TODO fix this.
172+
info.rmtree
173+
end
174+
175+
def add_suffix(file, suffix)
176+
dir = File.dirname(file)
177+
ext = File.extname(file)
178+
base = File.basename(file, ext)
179+
File.rename file, "#{dir}/#{base}-#{suffix}#{ext}"
180+
end
181+
182+
def caveats
183+
if build.with?("multilib") then <<-EOS.undent
184+
GCC has been built with multilib support. Notably, OpenMP may not work:
185+
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60670
186+
If you need OpenMP support you may want to
187+
brew reinstall gcc --without-multilib
188+
EOS
189+
end
190+
end
191+
192+
test do
193+
(testpath/"hello-c.c").write <<-EOS.undent
194+
#include <stdio.h>
195+
int main()
196+
{
197+
puts("Hello, world!");
198+
return 0;
199+
}
200+
EOS
201+
system "#{bin}/gcc-#{version_suffix}", "-o", "hello-c", "hello-c.c"
202+
assert_equal "Hello, world!\n", `./hello-c`
203+
204+
(testpath/"hello-cc.cc").write <<-EOS.undent
205+
#include <iostream>
206+
int main()
207+
{
208+
std::cout << "Hello, world!" << std::endl;
209+
return 0;
210+
}
211+
EOS
212+
system "#{bin}/g++-#{version_suffix}", "-o", "hello-cc", "hello-cc.cc"
213+
assert_equal "Hello, world!\n", `./hello-cc`
214+
215+
(testpath/"test.f90").write <<-EOS.undent
216+
integer,parameter::m=10000
217+
real::a(m), b(m)
218+
real::fact=0.5
219+
220+
do concurrent (i=1:m)
221+
a(i) = a(i) + fact*b(i)
222+
end do
223+
write(*,"(A)") "Done"
224+
end
225+
EOS
226+
system "#{bin}/gfortran-8", "-o", "test", "test.f90"
227+
assert_equal "Done\n", `./test`
228+
end
229+
end

0 commit comments

Comments
 (0)