Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround for enabling rvv #109

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions riscv-gnu-toolchain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class RiscvGnuToolchain < Formula

# enabling multilib by default, must choose to build without
option "with-NOmultilib", "Build WITHOUT multilib support"
option "with-enable-rvv", "Workaround to enable RISCV Vector Extension"

depends_on "gawk" => :build
depends_on "gnu-sed" => :build
Expand All @@ -51,21 +52,35 @@ def install
# disable crazy flag additions
ENV.delete "CPATH"

# need to pull in needed submodules (now that they are disabled above)
system "git", "submodule", "update", "--init", "--recursive", "newlib"
system "git", "submodule", "update", "--init", "--recursive", "binutils"
system "git", "submodule", "update", "--init", "--recursive", "gcc"

args = [
"--prefix=#{prefix}",
"--with-cmodel=medany",
]
args << "--enable-multilib" unless build.with?("NOmultilib")

if build.with?("enable-rvv")
puts "Enable RISCV Vector Extension"
system "git", "clone", "https://github.com/gcc-mirror/gcc", "-b", "releases/gcc-13", "gcc-13"
current_path = `pwd`.chomp
args << "--with-gcc-src="+current_path+"/gcc-13"
end

# need to pull in needed submodules (now that they are disabled above)
system "git", "submodule", "update", "--init", "--recursive", "newlib"
system "git", "submodule", "update", "--init", "--recursive", "binutils"
unless build.with?("enable-rvv")
system "git", "submodule", "update", "--init", "--recursive", "gcc"
end

# Workaround for M1
# See https://github.com/riscv/homebrew-riscv/issues/47
system "sed", "-i", ".bak", "s/.*=host-darwin.o$//", "gcc/gcc/config.host"
system "sed", "-i", ".bak", "s/.* x-darwin.$//", "gcc/gcc/config.host"
if build.with?("enable-rvv")
system "sed", "-i", ".bak", "s/.*=host-darwin.o$//", "gcc-13/gcc/config.host"
system "sed", "-i", ".bak", "s/.* x-darwin.$//", "gcc-13/gcc/config.host"
else
system "sed", "-i", ".bak", "s/.*=host-darwin.o$//", "gcc/gcc/config.host"
system "sed", "-i", ".bak", "s/.* x-darwin.$//", "gcc/gcc/config.host"
end

system "./configure", *args
system "make"
Expand Down
4 changes: 3 additions & 1 deletion riscv-tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ class RiscvTools < Formula
version "0.2"
sha256 "cb919eb7cf11071c6d11c721a9e77893a2dbe9158466e444eb3dd8476a89b7b4"

option "with-enable-rvv", "Workaround to enable RISCV Vector Extension"

# install rest of tools
depends_on "riscv-gnu-toolchain"
depends_on "riscv-gnu-toolchain" => [:build, "--with-enable-rvv"]
depends_on "riscv-isa-sim"
depends_on "riscv-pk"

Expand Down