mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 11:07:46 +00:00
wasm: specify wasi-libc in code, not in the JSON target file
This brings a bit more consistency to libc configuration. It seems better to me to set the header flags all in the same place, instead of some in Go code and some in JSON target files (depending on the target).
This commit is contained in:
committed by
Ron Evans
parent
de6f831983
commit
39ff13fd1a
+11
-1
@@ -204,7 +204,8 @@ func (c *Config) CFlags() []string {
|
||||
for _, flag := range c.Target.CFlags {
|
||||
cflags = append(cflags, strings.ReplaceAll(flag, "{root}", goenv.Get("TINYGOROOT")))
|
||||
}
|
||||
if c.Target.Libc == "picolibc" {
|
||||
switch c.Target.Libc {
|
||||
case "picolibc":
|
||||
root := goenv.Get("TINYGOROOT")
|
||||
picolibcDir := filepath.Join(root, "lib", "picolibc", "newlib", "libc")
|
||||
cflags = append(cflags,
|
||||
@@ -213,6 +214,15 @@ func (c *Config) CFlags() []string {
|
||||
"-Xclang", "-internal-isystem", "-Xclang", filepath.Join(picolibcDir, "tinystdio"),
|
||||
)
|
||||
cflags = append(cflags, "-I"+filepath.Join(root, "lib/picolibc-include"))
|
||||
case "wasi-libc":
|
||||
root := goenv.Get("TINYGOROOT")
|
||||
cflags = append(cflags, "--sysroot="+root+"/lib/wasi-libc/sysroot")
|
||||
case "":
|
||||
// No libc specified, nothing to add.
|
||||
default:
|
||||
// Incorrect configuration. This could be handled in a better way, but
|
||||
// usually this will be found by developers (not by TinyGo users).
|
||||
panic("unknown libc: " + c.Target.Libc)
|
||||
}
|
||||
// Always emit debug information. It is optionally stripped at link time.
|
||||
cflags = append(cflags, "-g")
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
"goarch": "arm",
|
||||
"linker": "wasm-ld",
|
||||
"libc": "wasi-libc",
|
||||
"cflags": [
|
||||
"--sysroot={root}/lib/wasi-libc/sysroot"
|
||||
],
|
||||
"ldflags": [
|
||||
"--allow-undefined",
|
||||
"--stack-first",
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
"goarch": "wasm",
|
||||
"linker": "wasm-ld",
|
||||
"libc": "wasi-libc",
|
||||
"cflags": [
|
||||
"--sysroot={root}/lib/wasi-libc/sysroot"
|
||||
],
|
||||
"ldflags": [
|
||||
"--allow-undefined",
|
||||
"--stack-first",
|
||||
|
||||
Reference in New Issue
Block a user