Skip to content

Commit

Permalink
bg
Browse files Browse the repository at this point in the history
  • Loading branch information
paperchalice committed Jun 1, 2024
1 parent 84cd603 commit 8758dff
Showing 1 changed file with 110 additions and 0 deletions.
110 changes: 110 additions & 0 deletions Formula/gcc/bootstrap-gcc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
class BootstrapGcc < Formula

Check failure on line 1 in Formula/gcc/bootstrap-gcc.rb

View workflow job for this annotation

GitHub Actions / test-bot (macos-13)

Non-libraries were installed to "/usr/local/opt/bootstrap-gcc/lib". Installing non-libraries to "lib" is discouraged. The offending files are: /usr/local/opt/bootstrap-gcc/lib/libstdc++.6.dylib-gdb.py /usr/local/opt/bootstrap-gcc/lib/libitm.spec /usr/local/opt/bootstrap-gcc/lib/libgphobos.spec /usr/local/opt/bootstrap-gcc/lib/libgomp.spec

Check failure on line 1 in Formula/gcc/bootstrap-gcc.rb

View workflow job for this annotation

GitHub Actions / test-bot (macos-13)

Binaries built for a non-native architecture were installed into bootstrap-gcc's prefix. The offending files are: /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/arm64-apple-darwin22-c++ (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/arm64-apple-darwin22-g++ (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/arm64-apple-darwin22-gcc (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/arm64-apple-darwin22-gcc-14 (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/arm64-apple-darwin22-gcc-ar (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/arm64-apple-darwin22-gcc-nm (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/arm64-apple-darwin22-gcc-ranlib (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/arm64-apple-darwin22-gdc (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/cpp (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gcc-ar (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gcc-nm (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gcc-ranlib (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gcov (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gcov-dump (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gcov-tool (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gdc (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gnat (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gnatbind (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gnatchop (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gnatclean (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gnatkr (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gnatlink (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gnatls (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gnatmake (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gnatname (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/gnatprep (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/bin/lto-dump (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/lib/gcc/arm64-apple-darwin22/14/adalib/libgnarl-14.dylib (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/lib/gcc/arm64-apple-darwin22/14/adalib/libgnat-14.dylib (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/lib/libatomic.1.dylib (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/lib/libgcc_s.1.1.dylib (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/lib/libgdruntime.5.dylib (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/lib/libgomp.1.dylib (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/lib/libgphobos.5.dylib (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/lib/libitm.1.dylib (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/lib/libquadmath.0.dylib (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/lib/libssp.0.dylib (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/lib/libstdc++.6.dylib (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/libexec/gcc/arm64-apple-darwin22/14/cc1 (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/libexec/gcc/arm64-apple-darwin22/14/cc1plus (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/libexec/gcc/arm64-apple-darwin22/14/collect2 (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/libexec/gcc/arm64-apple-darwin22/14/d21 (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/libexec/gcc/arm64-apple-darwin22/14/g++-mapper-server (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/libexec/gcc/arm64-apple-darwin22/14/gnat1 (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/libexec/gcc/arm64-apple-darwin22/14/install-tools/fixincl (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/libexec/gcc/arm64-apple-darwin22/14/lto-wrapper (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/libexec/gcc/arm64-apple-darwin22/14/lto1 (arm64) /usr/local/Cellar/bootstrap-gcc/14.1.0/libexec/gcc/arm64-apple-darwin22/14/plugin/gengtype (arm64)
desc "GNU compiler collection"
homepage "https://gcc.gnu.org/"
url "https://ftp.gnu.org/gnu/gcc/gcc-14.1.0/gcc-14.1.0.tar.xz"
sha256 "e283c654987afe3de9d8080bc0bd79534b5ca0d681a73a11ff2b5d3767426840"
license "GPL-3.0-or-later" => { with: "GCC-exception-3.1" }

keg_only "bootstrap formula"

depends_on "arm64-apple-darwin-gcc" => :build
depends_on "doxygen" => :build
depends_on "gcc-strap" => :build
depends_on "gettext" => :build
depends_on "make" => :build
depends_on "python" => :build
depends_on "rust" => :build
depends_on "texinfo" => :build
depends_on xcode: :build

# 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.
pour_bottle? only_if: :clt_installed

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

resource "isl" do
url "https://libisl.sourceforge.io/isl-0.26.tar.xz"
sha256 "a0b5cb06d24f9fa9e77b55fabbe9a3c94a336190345c2555f9915bb38e976504"
end

resource "mpc" do
url "https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz"
sha256 "ab642492f5cf882b74aa0cb730cd410a81edcdbec895183ce930e706c1c759b8"
end

resource "mpfr" do
url "https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz"
sha256 "277807353a6726978996945af13e52829e3abd7a9a5b7fb2793894e18f1fcbb2"
end

resource "gmp" do
url "https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz"
sha256 "a3c2b80201b89e68616f4ad30bc66aee4927c3ce50e33929ca819d5c43538898"
end

resource "gettext" do
url "https://ftp.gnu.org/gnu/gettext/gettext-0.22.5.tar.gz"
sha256 "ec1705b1e969b83a9f073144ec806151db88127f5e40fe5a94cb6c8fa48996a0"
end

patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/82b5c1cd38826ab67ac7fc498a8fe74376a40f4a/gcc/gcc-14.1.0.diff"
sha256 "1529cff128792fe197ede301a81b02036c8168cb0338df21e4bc7aafe755305a"
end

def install
ENV.delete "CC"
ENV.delete "CXX"
ENV.delete "LD"

inreplace "libgcc/config/t-darwin-min-5", "10.5", "11.7"

triple = "#{Hardware::CPU.arch}-apple-darwin#{OS.kernel_version.major}"
target = "arm64-apple-darwin#{OS.kernel_version.major}"
languages = %w[ada c c++ d]
sr = MacOS.sdk_path.to_str.tr "0-9", ""

configure_args = %W[
--build=#{triple}
--host=#{target}
--target=#{target}
--prefix=#{prefix}
--with-as=/usr/bin/as
--with-ld=/usr/bin/ld
--with-dsymutil=/usr/bin/dsymutil
--disable-bootstrap
--disable-multilib
--enable-checking=release
--enable-languages=#{languages.join(",")}
--with-gcc-major-version-only
--with-sysroot=#{sr}
--without-zstd
]

resources.each { |r| r.stage buildpath/r.name }
mkdir "build" do
system "../configure", *configure_args
system "gmake"
system "gmake", "install", "-j", "1"
end

cross = Formula["arm64-apple-darwin-gcc"]
gcc_s = (cross.prefix/"#{target}/lib"/shared_library("libgcc_s", "1.1")).to_s
gcc_ss = (lib/shared_library("libgcc_s", "1.1")).to_s
Pathname.glob(lib/"gcc/#{target}/#{version.major}/adalib"/shared_library("*")).each do |l|
d = MachO::Tools.dylibs l
MachO::Tools.change_install_name l.to_s, gcc_s, gcc_ss if d.include? gcc_s
end

libstdcxx = lib/shared_library("libstdc++", "6")
rm libstdcxx
cp cross.prefix/"#{target}/lib"/shared_library("libstdc++", "6"), libstdcxx
MachO::Tools.change_dylib_id libstdcxx.to_s, libstdcxx.to_s
end

test do
system "echo"
end
end

0 comments on commit 8758dff

Please sign in to comment.