Skip to content

Commit 8f696a4

Browse files
committed
gcc14: promote to gcc
1 parent 7103d76 commit 8f696a4

File tree

2 files changed

+64
-279
lines changed

2 files changed

+64
-279
lines changed

Library/Formula/gcc.rb

+64-23
Original file line numberDiff line numberDiff line change
@@ -21,54 +21,70 @@ def osmajor
2121

2222
desc "GNU compiler collection"
2323
homepage "https://gcc.gnu.org"
24-
url "https://ftp.gnu.org/gnu/gcc/gcc-8.5.0/gcc-8.5.0.tar.xz"
25-
mirror "https://ftpmirror.gnu.org/gcc/gcc-8.5.0/gcc-8.5.0.tar.xz"
26-
sha256 "d308841a511bb830a6100397b0042db24ce11f642dab6ea6ee44842e5325ed50"
27-
revision 1
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"
2827

2928
bottle do
30-
sha256 "092a1e615cdea11f55784252145d1da94f968d1a0ec59266d4f3a9e846be242d" => :tiger_altivec
3129
end
3230

33-
conflicts_with "gcc8", :because => "both install the same version of GCC"
34-
3531
option "with-nls", "Build with native language support (localization)"
36-
option "with-jit", "Build just-in-time compiler"
3732
# enabling multilib on a host that can't run 64-bit results in build failures
3833
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
3938

39+
# System texinfo is too old
40+
depends_on "texinfo" => :build
4041
depends_on "gmp"
4142
depends_on "libmpc"
4243
depends_on "mpfr"
43-
depends_on "isl018"
44+
depends_on "isl"
45+
# System zlib is missing crc32_combine on Tiger
46+
depends_on "zlib"
4447

4548
if MacOS.version < :leopard
4649
# The as that comes with Tiger isn't capable of dealing with the
4750
# PPC asm that comes in libitm
48-
depends_on "cctools" => :build
51+
depends_on "cctools"
52+
# GCC invokes ld with flags the system ld doesn't have
53+
depends_on "ld64"
4954
end
5055

51-
# Bug 21514 - [DR 488] templates and anonymous enum - fixed in 4.0.2
52-
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21514
56+
# Needs a newer tigerbrew-provided GCC to build
5357
fails_with :gcc_4_0
58+
fails_with :gcc
5459
fails_with :llvm
5560

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

64+
# Applied upstream: https://github.com/gcc-mirror/gcc/commit/1cfe4a4d0d4447b364815d5e5c889deb2e533669
65+
# Can remove in a later version.
66+
patch :p0 do
67+
url "https://github.com/macports/macports-ports/raw/b5a5b6679f59dcad1b21f66bb01e3f8a3a377b4b/lang/gcc14/files/darwin-ppc-fpu.patch"
68+
sha256 "7f14356f2e9efdf46503ca1156302c9b294db52569f4d56073267142b6d2ee71"
69+
end
70+
71+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117834
72+
patch :p0 do
73+
url "https://github.com/macports/macports-ports/raw/b5a5b6679f59dcad1b21f66bb01e3f8a3a377b4b/lang/gcc14/files/darwin8-define-PTHREAD_RWLOCK_INITIALIZER.patch"
74+
sha256 "57ffac38f4d5eb4d92634d9e7c339f961e3eb908d13a944d622bfc6915a4f435"
75+
end
76+
5977
# The bottles are built on systems with the CLT installed, and do not work
6078
# out of the box on Xcode-only systems due to an incorrect sysroot.
6179
def pour_bottle?
6280
MacOS::CLT.installed?
6381
end
6482

6583
def version_suffix
66-
version.to_s.slice(/\d/)
84+
version.to_s.slice(/\d\d/)
6785
end
6886

6987
def install
70-
# GCC will suffer build errors if forced to use a particular linker.
71-
ENV.delete "LD"
7288
# GCC Bug 25127 for PowerPC
7389
# https://gcc.gnu.org/bugzilla//show_bug.cgi?id=25127
7490
# ../../../libgcc/unwind.inc: In function '_Unwind_RaiseException':
@@ -83,10 +99,6 @@ def install
8399
ENV.append_to_cflags "-force_cpusubtype_ALL"
84100
end
85101

86-
if MacOS.version < :leopard
87-
ENV["AS"] = ENV["AS_FOR_TARGET"] = "#{Formula["cctools"].bin}/as"
88-
end
89-
90102
# We avoiding building:
91103
# - Ada, which requires a pre-existing GCC Ada compiler to bootstrap
92104
# - Go, currently not supported on macOS
@@ -106,7 +118,7 @@ def install
106118
"--with-gmp=#{Formula["gmp"].opt_prefix}",
107119
"--with-mpfr=#{Formula["mpfr"].opt_prefix}",
108120
"--with-mpc=#{Formula["libmpc"].opt_prefix}",
109-
"--with-isl=#{Formula["isl018"].opt_prefix}",
121+
"--with-isl=#{Formula["isl"].opt_prefix}",
110122
"--with-system-zlib",
111123
"--enable-checking=release",
112124
"--with-pkgversion=Tigerbrew #{name} #{pkg_version} #{build.used_options*" "}".strip,
@@ -131,9 +143,38 @@ def install
131143

132144
args << "--enable-host-shared" if build.with?("jit")
133145

134-
# Ensure correct install names when linking against libgcc_s;
135-
# see discussion in https://github.com/Homebrew/homebrew/pull/34303
136-
inreplace "libgcc/config/t-slibgcc-darwin", "@shlib_slibdir@", "#{HOMEBREW_PREFIX}/lib/gcc/#{version_suffix}"
146+
# These two flags are required for zlib to be found in the last stage
147+
inreplace "gcc/Makefile.in" do |s|
148+
s.change_make_var! "ZLIB", "-L#{Formula["zlib"].opt_lib} -lz"
149+
s.change_make_var! "ZLIBINC", "-I#{Formula["zlib"].opt_include}"
150+
end
151+
152+
if MacOS.version < :leopard
153+
# We need to use a newer as to build, but we also want the compiler
154+
# to use it at runtime
155+
ENV["AS"] = ENV["AS_FOR_TARGET"] = "#{Formula["cctools"].bin}/as"
156+
# Following Macports on which tools to specify both in the environment
157+
# and as configure args
158+
args << "--with-as=#{Formula["cctools"].bin}/as"
159+
# We'll also configure the compiler to use the rest of the newer cctools
160+
ENV["AR_FOR_TARGET"] = "#{Formula["cctools"].bin}/ar"
161+
args << "--with-ar=#{Formula["cctools"].bin}/ar"
162+
ENV["NM_FOR_TARGET"] = "#{Formula["cctools"].bin}/nm"
163+
ENV["RANLIB_FOR_TARGET"] = "#{Formula["cctools"].bin}/ranlib"
164+
ENV["STRIP_FOR_TARGET"] = "#{Formula["cctools"].bin}/strip"
165+
166+
# We need ld both for the build and for the end result compiler to use
167+
# Note that unlike the above, which are more nice-to-haves, gcc-14
168+
# will actually fail to use the system ld on Tiger.
169+
ENV.ld64
170+
ENV["LD_FOR_TARGET"] = ENV["LD"]
171+
args << "--with-ld=#{ENV["LD"]}"
172+
173+
# Avoids the need for the ttyname_r patch
174+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117857
175+
# https://github.com/mistydemeo/tigerbrew/pull/1286#issuecomment-2664224824
176+
ENV.append_to_cflags "-D__DARWIN_UNIX03"
177+
end
137178

138179
mkdir "build" do
139180
unless MacOS::CLT.installed?

0 commit comments

Comments
 (0)