@@ -36,6 +36,7 @@ class RiscvGnuToolchain < Formula
36
36
37
37
# enabling multilib by default, must choose to build without
38
38
option "with-NOmultilib" , "Build WITHOUT multilib support"
39
+ option "with-enable-rvv" , "Workaround to enable RISCV Vector Extension"
39
40
40
41
depends_on "gawk" => :build
41
42
depends_on "gnu-sed" => :build
@@ -51,21 +52,35 @@ def install
51
52
# disable crazy flag additions
52
53
ENV . delete "CPATH"
53
54
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
-
59
55
args = [
60
56
"--prefix=#{ prefix } " ,
61
57
"--with-cmodel=medany" ,
62
58
]
63
59
args << "--enable-multilib" unless build . with? ( "NOmultilib" )
64
60
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
+
65
75
# Workaround for M1
66
76
# 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
69
84
70
85
system "./configure" , *args
71
86
system "make"
0 commit comments