@@ -54,7 +54,7 @@ def get_wasi_sysroot(rctx):
54
54
)
55
55
56
56
print (
57
- "\n \n It worked! Feel free to make a PR adding `{}` as the WASI URL for LLVM {} with sha256 = `{}`.\n \n " .format (
57
+ "\n \n It worked! Feel free to make a PR adding `{}` as the WASI sysroot URL for LLVM {} with sha256 = `{}`.\n \n " .format (
58
58
url ,
59
59
llvm_major_version ,
60
60
res .sha256
@@ -104,4 +104,34 @@ def wasi_compiler_rt_url(llvm_major_version):
104
104
return "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-{v}/libclang_rt.builtins-wasm32-wasi-{v}.0.tar.gz" .format (v = llvm_major_version )
105
105
106
106
def install_wasi_compiler_rt (rctx ):
107
- pass
107
+ llvm_version = rctx .attr .llvm_version
108
+ llvm_major_version = int (llvm_version .split ("." )[0 ])
109
+ common_download_params = {
110
+ "output" : "lib/clang/{}/lib/wasi" .format (llvm_version ),
111
+ "stripPrefix" : "lib/wasi" ,
112
+ "canonical_id" : str (llvm_major_version ),
113
+ }
114
+
115
+ if llvm_major_version in WASI_COMPILER_RT_LINKS :
116
+ url , sha = WASI_COMPILER_RT_LINKS [llvm_major_version ]
117
+ rctx .download_and_extract (
118
+ url = url ,
119
+ sha256 = sha ,
120
+ ** common_download_params
121
+ )
122
+ else :
123
+ url = wasi_compiler_rt_url (llvm_major_version )
124
+ print ("We don't have a WASI compiler_rt URL for LLVM {}; we'll try to use `{}`.." .format (llvm_major_version , url ))
125
+
126
+ res = rctx .download_and_extract (
127
+ url = url ,
128
+ ** common_download_params
129
+ )
130
+
131
+ print (
132
+ "\n \n It worked! Feel free to make a PR adding `{}` as the WASI compiler_rt URL for LLVM {} with sha256 = `{}`.\n \n " .format (
133
+ url ,
134
+ llvm_major_version ,
135
+ res .sha256
136
+ )
137
+ )
0 commit comments