fix wasi-libc caching path
This commit is contained in:
@@ -180,15 +180,9 @@ func use(goos, goarch string, wasiThreads bool) (export Export, err error) {
|
|||||||
// If not exists in LLGoROOT, download and use cached wasiSdkRoot
|
// If not exists in LLGoROOT, download and use cached wasiSdkRoot
|
||||||
if _, err = os.Stat(wasiSdkRoot); err != nil {
|
if _, err = os.Stat(wasiSdkRoot); err != nil {
|
||||||
sdkDir := filepath.Join(cacheDir(), llvm.GetTargetTriple(goos, goarch))
|
sdkDir := filepath.Join(cacheDir(), llvm.GetTargetTriple(goos, goarch))
|
||||||
if _, err = os.Stat(sdkDir); err != nil {
|
if wasiSdkRoot, err = checkDownloadAndExtract(wasiSdkUrl, sdkDir); err != nil {
|
||||||
if !errors.Is(err, fs.ErrNotExist) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if wasiSdkRoot, err = downloadAndExtract(wasiSdkUrl, sdkDir); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// WASI-SDK configuration
|
// WASI-SDK configuration
|
||||||
triple := "wasm32-wasip1"
|
triple := "wasm32-wasip1"
|
||||||
|
|||||||
@@ -12,10 +12,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func downloadAndExtract(url, dir string) (wasiSdkRoot string, err error) {
|
func checkDownloadAndExtract(url, dir string) (wasiSdkRoot string, err error) {
|
||||||
if _, err = os.Stat(dir); err == nil {
|
if _, err = os.Stat(dir); err != nil {
|
||||||
os.RemoveAll(dir)
|
os.RemoveAll(dir)
|
||||||
}
|
|
||||||
tempDir := dir + ".temp"
|
tempDir := dir + ".temp"
|
||||||
os.RemoveAll(tempDir)
|
os.RemoveAll(tempDir)
|
||||||
if err := os.MkdirAll(tempDir, 0755); err != nil {
|
if err := os.MkdirAll(tempDir, 0755); err != nil {
|
||||||
@@ -43,6 +42,7 @@ func downloadAndExtract(url, dir string) (wasiSdkRoot string, err error) {
|
|||||||
if err = os.Rename(tempDir, dir); err != nil {
|
if err = os.Rename(tempDir, dir); err != nil {
|
||||||
return "", fmt.Errorf("failed to rename directory: %w", err)
|
return "", fmt.Errorf("failed to rename directory: %w", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
wasiSdkRoot = filepath.Join(dir, "wasi-sdk-25.0-x86_64-macos")
|
wasiSdkRoot = filepath.Join(dir, "wasi-sdk-25.0-x86_64-macos")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user