Created
March 12, 2024 05:18
-
-
Save hey-jude/e272aa2f35f89ecf599572a0d11db618 to your computer and use it in GitHub Desktop.
x86_64-elf-gcc 7 version for cross-compiling - pintos on ubuntu 18.04
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 X8664ElfGccAT7 < Formula | |
desc "GNU compiler collection for x86_64-elf" | |
homepage "https://gcc.gnu.org" | |
url "https://ftp.gnu.org/gnu/gcc/gcc-7.5.0/gcc-7.5.0.tar.xz" | |
mirror "https://ftpmirror.gnu.org/gcc/gcc-7.5.0/gcc-7.5.0.tar.xz" | |
sha256 "b81946e7f01f90528a1f7352ab08cc602b9ccc05d4e44da4bd501c5a189ee661" | |
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 "isl" | |
depends_on "x86_64-elf-binutils" | |
uses_from_macos "zlib" | |
cxxstdlib_check :skip | |
def install | |
target = "x86_64-elf" | |
sdk = MacOS.sdk_path_if_needed | |
mkdir "x86_64-elf-gcc-7-build" do | |
# fix against ld gt_pch_save error | |
# https://github.com/riscv-software-src/homebrew-riscv/pull/48/files | |
system "sed", "-i", ".bak", "s/.*=host-darwin.o$//", "../gcc/config.host" | |
system "sed", "-i", ".bak", "s/.* x-darwin.$//", "../gcc/config.host" | |
system "../configure", "--target=#{target}", | |
"--prefix=#{prefix}", | |
"--infodir=#{info}/#{target}", | |
"--disable-nls", | |
"--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", | |
"--program-prefix=#{target}-", | |
"--program-suffix=-#{version.major}", | |
"--with-system-zlib", | |
"--with-native-system-header-dir=/usr/include", | |
"--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
$ brew install -v --build-from-source x86_64-elf-gcc@7.rb