Skip to content

Commit 0fee9d9

Browse files
committed
workaround for enabling rvv
1 parent 94eac5c commit 0fee9d9

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

riscv-gnu-toolchain.rb

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class RiscvGnuToolchain < Formula
3636

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

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

54-
# need to pull in needed submodules (now that they are disabled above)
55-
system "git", "submodule", "update", "--init", "--recursive", "newlib"
56-
system "git", "submodule", "update", "--init", "--recursive", "binutils"
57-
system "git", "submodule", "update", "--init", "--recursive", "gcc"
58-
5955
args = [
6056
"--prefix=#{prefix}",
6157
"--with-cmodel=medany",
6258
]
6359
args << "--enable-multilib" unless build.with?("NOmultilib")
6460

61+
if build.with?("enable-rvv")
62+
puts "Enable RISCV Vector Extension"
63+
system "git", "clone", "https://github.com/gcc-mirror/gcc", "-b", "releases/gcc-13", "gcc-13"
64+
current_path = `pwd`.chomp
65+
args << "--with-gcc-src="+current_path+"/gcc-13"
66+
end
67+
68+
# need to pull in needed submodules (now that they are disabled above)
69+
system "git", "submodule", "update", "--init", "--recursive", "newlib"
70+
system "git", "submodule", "update", "--init", "--recursive", "binutils"
71+
unless build.with?("enable-rvv")
72+
system "git", "submodule", "update", "--init", "--recursive", "gcc"
73+
end
74+
6575
# Workaround for M1
6676
# See https://github.com/riscv/homebrew-riscv/issues/47
67-
system "sed", "-i", ".bak", "s/.*=host-darwin.o$//", "gcc/gcc/config.host"
68-
system "sed", "-i", ".bak", "s/.* x-darwin.$//", "gcc/gcc/config.host"
77+
if build.with?("enable-rvv")
78+
system "sed", "-i", ".bak", "s/.*=host-darwin.o$//", "gcc-13/gcc/config.host"
79+
system "sed", "-i", ".bak", "s/.* x-darwin.$//", "gcc-13/gcc/config.host"
80+
else
81+
system "sed", "-i", ".bak", "s/.*=host-darwin.o$//", "gcc/gcc/config.host"
82+
system "sed", "-i", ".bak", "s/.* x-darwin.$//", "gcc/gcc/config.host"
83+
end
6984

7085
system "./configure", *args
7186
system "make"

riscv-tools.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ class RiscvTools < Formula
55
version "0.2"
66
sha256 "cb919eb7cf11071c6d11c721a9e77893a2dbe9158466e444eb3dd8476a89b7b4"
77

8+
option "with-enable-rvv", "Workaround to enable RISCV Vector Extension"
9+
810
# install rest of tools
9-
depends_on "riscv-gnu-toolchain"
11+
depends_on "riscv-gnu-toolchain" => [:build, "--with-enable-rvv"]
1012
depends_on "riscv-isa-sim"
1113
depends_on "riscv-pk"
1214

0 commit comments

Comments
 (0)