wasi: specify wasi-libc in a different way
This way is more consistent with how picolibc is specified and allows generating a helpful error message. This error message should never be generated for TinyGo binary releases, only when doing local development.
Этот коммит содержится в:
родитель
9c3e479432
коммит
869baca117
3 изменённых файлов: 17 добавлений и 6 удалений
|
@ -186,7 +186,9 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add libc dependency if needed.
|
// Add libc dependency if needed.
|
||||||
if config.Target.Libc == "picolibc" {
|
root := goenv.Get("TINYGOROOT")
|
||||||
|
switch config.Target.Libc {
|
||||||
|
case "picolibc":
|
||||||
path, job, err := Picolibc.load(config.Triple(), config.CPU(), dir)
|
path, job, err := Picolibc.load(config.Triple(), config.CPU(), dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -198,12 +200,21 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
|
||||||
linkerDependencies = append(linkerDependencies, job)
|
linkerDependencies = append(linkerDependencies, job)
|
||||||
}
|
}
|
||||||
ldflags = append(ldflags, path)
|
ldflags = append(ldflags, path)
|
||||||
|
case "wasi-libc":
|
||||||
|
path := filepath.Join(root, "lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a")
|
||||||
|
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||||
|
return errors.New("could not find wasi-libc, perhaps you need to run `make wasi-libc`?")
|
||||||
|
}
|
||||||
|
ldflags = append(ldflags, path)
|
||||||
|
case "":
|
||||||
|
// no library specified, so nothing to do
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unknown libc: %s", config.Target.Libc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add jobs to compile extra files. These files are in C or assembly and
|
// Add jobs to compile extra files. These files are in C or assembly and
|
||||||
// contain things like the interrupt vector table and low level operations
|
// contain things like the interrupt vector table and low level operations
|
||||||
// such as stack switching.
|
// such as stack switching.
|
||||||
root := goenv.Get("TINYGOROOT")
|
|
||||||
for i, path := range config.ExtraFiles() {
|
for i, path := range config.ExtraFiles() {
|
||||||
abspath := filepath.Join(root, path)
|
abspath := filepath.Join(root, path)
|
||||||
outpath := filepath.Join(dir, "extra-"+strconv.Itoa(i)+"-"+filepath.Base(path)+".o")
|
outpath := filepath.Join(dir, "extra-"+strconv.Itoa(i)+"-"+filepath.Base(path)+".o")
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
"goarch": "arm",
|
"goarch": "arm",
|
||||||
"compiler": "clang",
|
"compiler": "clang",
|
||||||
"linker": "wasm-ld",
|
"linker": "wasm-ld",
|
||||||
|
"libc": "wasi-libc",
|
||||||
"cflags": [
|
"cflags": [
|
||||||
"--target=wasm32--wasi",
|
"--target=wasm32--wasi",
|
||||||
"--sysroot={root}/lib/wasi-libc/sysroot",
|
"--sysroot={root}/lib/wasi-libc/sysroot",
|
||||||
|
@ -14,8 +15,7 @@
|
||||||
"--allow-undefined",
|
"--allow-undefined",
|
||||||
"--stack-first",
|
"--stack-first",
|
||||||
"--export-dynamic",
|
"--export-dynamic",
|
||||||
"--no-demangle",
|
"--no-demangle"
|
||||||
"{root}/lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a"
|
|
||||||
],
|
],
|
||||||
"emulator": ["wasmtime"],
|
"emulator": ["wasmtime"],
|
||||||
"wasm-abi": "generic"
|
"wasm-abi": "generic"
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
"goarch": "wasm",
|
"goarch": "wasm",
|
||||||
"compiler": "clang",
|
"compiler": "clang",
|
||||||
"linker": "wasm-ld",
|
"linker": "wasm-ld",
|
||||||
|
"libc": "wasi-libc",
|
||||||
"cflags": [
|
"cflags": [
|
||||||
"--target=wasm32--wasi",
|
"--target=wasm32--wasi",
|
||||||
"--sysroot={root}/lib/wasi-libc/sysroot",
|
"--sysroot={root}/lib/wasi-libc/sysroot",
|
||||||
|
@ -14,8 +15,7 @@
|
||||||
"--allow-undefined",
|
"--allow-undefined",
|
||||||
"--stack-first",
|
"--stack-first",
|
||||||
"--export-all",
|
"--export-all",
|
||||||
"--no-demangle",
|
"--no-demangle"
|
||||||
"{root}/lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a"
|
|
||||||
],
|
],
|
||||||
"emulator": ["node", "targets/wasm_exec.js"],
|
"emulator": ["node", "targets/wasm_exec.js"],
|
||||||
"wasm-abi": "js"
|
"wasm-abi": "js"
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче