Created
November 24, 2023 06:11
-
-
Save hey-jude/dbb9f39f8bb85b25d927133d2733f849 to your computer and use it in GitHub Desktop.
x86_64-elf-gcc 11 version for cross-compiling - pintos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class X8664ElfGccAT11 < Formula | |
desc "GNU compiler collection for x86_64-elf" | |
homepage "https://gcc.gnu.org" | |
url "https://ftp.gnu.org/gnu/gcc/gcc-11.4.0/gcc-11.4.0.tar.xz" | |
mirror "https://ftpmirror.gnu.org/gcc/gcc-11.4.0/gcc-11.4.0.tar.xz" | |
sha256 "3f2db222b007e8a4a23cd5ba56726ef08e8b1f1eb2055ee72c1402cea73a8dd9" | |
license "GPL-3.0-or-later" => { with: "GCC-exception-3.1" } | |
livecheck do | |
formula "gcc" | |
end | |
depends_on "gmp" | |
depends_on "libmpc" | |
depends_on "mpfr" | |
depends_on "x86_64-elf-binutils" | |
depends_on "zstd" | |
uses_from_macos "zlib" | |
cxxstdlib_check :skip | |
patch do | |
url "https://raw.githubusercontent.com/Homebrew/formula-patches/c233b1a8d81b9c9f5827510d8d285080ee11de2e/gcc/gcc-11.4.0.diff" | |
sha256 "440f6e965966c86a7925506e63eb06f7f54c00b1d146db8d0c567bdb8820072f" | |
end | |
def install | |
target = "x86_64-elf" | |
sdk = MacOS.sdk_path_if_needed | |
mkdir "x86_64-elf-gcc-11-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-zstd=#{Formula["zstd"].opt_prefix}", | |
"--program-prefix=#{target}-", | |
"--program-suffix=-#{version.major}", | |
"--with-system-zlib", | |
"--with-sysroot=#{sdk}", | |
"--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 | |
(share/"man/man7").rmtree | |
end | |
end | |
test do | |
(testpath/"test-c.c").write <<~EOS | |
int main(void) | |
{ | |
int i=0; | |
while(i<10) i++; | |
return i; | |
} | |
EOS | |
system "#{bin}/x86_64-elf-gcc-#{version.major}", "-c", "-o", "test-c.o", "test-c.c" | |
assert_match "file format elf64-x86-64", | |
shell_output("#{Formula["x86_64-elf-binutils"].bin}/x86_64-elf-objdump -a test-c.o") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I made this one for porting pintos execution environment to apple silicon mac.
Use only at your own risk.