@@ -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,41 @@ 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
84+
85+ # Check if the the system is using gcc linked to clang which may happen on OSX
86+ gcc_version_output = `gcc --version 2>&1`
87+ if gcc_version_output . include? ( "clang" )
88+ system "export" "PATH=/usr/local/bin:$PATH"
89+ end
6990
7091 system "./configure" , *args
7192 system "make"
0 commit comments