class X8664ElfGcc < Formula desc "GNU compiler collection for x86_64-elf" homepage "https://gcc.gnu.org" url "https://ftpmirror.gnu.org/gnu/gcc/gcc-15.2.0/gcc-15.2.0.tar.xz" mirror "https://ftp.gnu.org/gnu/gcc/gcc-15.2.0/gcc-15.2.0.tar.xz" sha256 "438fd996826b0c82485a29da03a72d71d6e3541a83ec702df4271f6fe025d24e" license "GPL-3.0-or-later" => { with: "GCC-exception-3.1" } livecheck do formula "gcc" end bottle do rebuild 1 sha256 arm64_tahoe: "c09336382ae4333e2e8f4f87bed391f86a47470a3432321a0f56c404c1146f36" sha256 arm64_sequoia: "77f70f69f5c62e425fd619acfabba6efe710c92a04c1a1c9ec149aad59ee84b4" sha256 arm64_sonoma: "0e8de4013e8b6d1de430cf0444be0bc9400f391b1f6342373a82dc20fc7cd761" sha256 sonoma: "e6e89c590cd3487f158f988cf1863712045e517286c04ff610320dba1cecb0fb" sha256 arm64_linux: "69660b3b18050c91c9859d50d3406528769f9962151040832bb521c842333bad" sha256 x86_64_linux: "29f9506ffca0f41dbf6c866535ea4cef4dcdde626822d291adbdc27f3c6a0eac" end depends_on "gmp" depends_on "libmpc" depends_on "mpfr" depends_on "x86_64-elf-binutils" depends_on "zstd" on_linux do depends_on "zlib-ng-compat" end def install target = "x86_64-elf" mkdir "x86_64-elf-gcc-build" do system "../configure", "--target=#{target}", "--prefix=#{prefix}", "--infodir=#{info}/#{target}", "--disable-nls", "--without-isl", "--without-headers", "--with-as=#{Formula["x86_64-elf-binutils"].bin}/x86_64-elf-as", "--with-ld=#{Formula["x86_64-elf-binutils"].bin}/x86_64-elf-ld", "--with-system-zlib", "--enable-languages=c,c++" system "make", "all-gcc" system "make", "install-gcc" system "make", "all-target-libgcc" system "make", "install-target-libgcc" # FSF-related man pages may conflict with native gcc rm_r(share/"man/man7") end end test do (testpath/"test-c.c").write <<~C int main(void) { int i=0; while(i<10) i++; return i; } C system bin/"x86_64-elf-gcc", "-c", "-o", "test-c.o", "test-c.c" output = shell_output("#{Formula["x86_64-elf-binutils"].bin}/x86_64-elf-objdump -a test-c.o") assert_match "file format elf64-x86-64", output end end