class Riscv64ElfGcc < Formula desc "GNU compiler collection for riscv64-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: "6a6b9c6a1a1ab30d64f79c4c9b12a1b7f89bf343443c93acea3f44cb0e3fd024" sha256 arm64_sequoia: "eda840ed9aaacfdde29945a1325d50059be192215fd503f7ad753fe6a725a2e0" sha256 arm64_sonoma: "45056ecd7ba6c56903bba4818af026245cbd835f35103ba855c3b3d4135f520e" sha256 sonoma: "14b7e6f6aa5b7ba859c8e1fcae88569f7e3394d33623935ac3383c97c964e4f1" sha256 arm64_linux: "76017c17d960c82448240e53d2da221ba33ceffc88a280da36da5de17847a0c4" sha256 x86_64_linux: "58d842ae0c40efa2fc02e673a634723797ac19b422dc816b3e8854c4568a80da" end depends_on "gmp" depends_on "libmpc" depends_on "mpfr" depends_on "riscv64-elf-binutils" depends_on "zstd" on_linux do depends_on "zlib-ng-compat" end def install target = "riscv64-elf" mkdir "riscv64-elf-gcc-build" do system "../configure", "--target=#{target}", "--prefix=#{prefix}", "--infodir=#{info}/#{target}", "--disable-nls", "--without-isl", "--without-headers", "--with-as=#{Formula["riscv64-elf-binutils"].bin}/riscv64-elf-as", "--with-ld=#{Formula["riscv64-elf-binutils"].bin}/riscv64-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/"riscv64-elf-gcc", "-c", "-o", "test-c.o", "test-c.c" assert_match "file format elf64-littleriscv", shell_output("#{Formula["riscv64-elf-binutils"].bin}/riscv64-elf-objdump -a test-c.o") end end