aboutsummaryrefslogtreecommitdiffhomepage
path: root/builder/picolibc.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2020-01-15 15:59:51 +0100
committerRon Evans <[email protected]>2020-03-22 17:14:59 +0100
commitf316ebc23b025e497931cfe420ec143f1a217b57 (patch)
tree62099034937787559599a42a6adbd820417df7b3 /builder/picolibc.go
parent9ec426e25e6738be6e09e0239445d1ca558cbf57 (diff)
downloadtinygo-f316ebc23b025e497931cfe420ec143f1a217b57.tar.gz
tinygo-f316ebc23b025e497931cfe420ec143f1a217b57.zip
all: include picolibc for bare metal targets
This is necessary for better CGo support on bare metal. Existing libraries expect to be able to include parts of libc and expect to be able to link to those symbols. Because with this all targets have a working libc, it is now possible to add tests to check that a libc in fact works basically. Not all parts of picolibc are included, such as the math or stdio parts. These should be added later, when needed. This commit also avoids the need for the custom memcpy/memset/memcmp symbols that are sometimes emitted by LLVM. The C library will take care of that.
Diffstat (limited to 'builder/picolibc.go')
-rw-r--r--builder/picolibc.go127
1 files changed, 127 insertions, 0 deletions
diff --git a/builder/picolibc.go b/builder/picolibc.go
new file mode 100644
index 000000000..31e2f0530
--- /dev/null
+++ b/builder/picolibc.go
@@ -0,0 +1,127 @@
+package builder
+
+import (
+ "path/filepath"
+
+ "github.com/tinygo-org/tinygo/goenv"
+)
+
+// Picolibc is a C library for bare metal embedded devices. It was originally
+// based on newlib.
+var Picolibc = Library{
+ name: "picolibc",
+ cflags: func() []string {
+ picolibcDir := filepath.Join(goenv.Get("TINYGOROOT"), "lib/picolibc/newlib/libc")
+ return []string{"-Werror", "-Wall", "-std=gnu11", "-D_COMPILING_NEWLIB", "-fshort-enums", "--sysroot=" + picolibcDir, "-I" + picolibcDir + "/tinystdio", "-I" + goenv.Get("TINYGOROOT") + "/lib/picolibc-include"}
+ },
+ sourceDir: "lib/picolibc/newlib/libc",
+ sources: func(target string) []string {
+ return picolibcSources
+ },
+}
+
+var picolibcSources = []string{
+ "string/bcmp.c",
+ "string/bcopy.c",
+ "string/bzero.c",
+ "string/explicit_bzero.c",
+ "string/ffsl.c",
+ "string/ffsll.c",
+ "string/fls.c",
+ "string/flsl.c",
+ "string/flsll.c",
+ "string/gnu_basename.c",
+ "string/index.c",
+ "string/memccpy.c",
+ "string/memchr.c",
+ "string/memcmp.c",
+ "string/memcpy.c",
+ "string/memmem.c",
+ "string/memmove.c",
+ "string/mempcpy.c",
+ "string/memrchr.c",
+ "string/memset.c",
+ "string/rawmemchr.c",
+ "string/rindex.c",
+ "string/stpcpy.c",
+ "string/stpncpy.c",
+ "string/strcasecmp.c",
+ "string/strcasecmp_l.c",
+ "string/strcasestr.c",
+ "string/strcat.c",
+ "string/strchr.c",
+ "string/strchrnul.c",
+ "string/strcmp.c",
+ "string/strcoll.c",
+ "string/strcoll_l.c",
+ "string/strcpy.c",
+ "string/strcspn.c",
+ "string/strdup.c",
+ "string/strerror.c",
+ "string/strerror_r.c",
+ "string/strlcat.c",
+ "string/strlcpy.c",
+ "string/strlen.c",
+ "string/strlwr.c",
+ "string/strncasecmp.c",
+ "string/strncasecmp_l.c",
+ "string/strncat.c",
+ "string/strncmp.c",
+ "string/strncpy.c",
+ "string/strndup.c",
+ "string/strnlen.c",
+ "string/strnstr.c",
+ "string/strpbrk.c",
+ "string/strrchr.c",
+ "string/strsep.c",
+ "string/strsignal.c",
+ "string/strspn.c",
+ "string/strstr.c",
+ "string/strtok.c",
+ "string/strtok_r.c",
+ "string/strupr.c",
+ "string/strverscmp.c",
+ "string/strxfrm.c",
+ "string/strxfrm_l.c",
+ "string/swab.c",
+ "string/timingsafe_bcmp.c",
+ "string/timingsafe_memcmp.c",
+ "string/u_strerr.c",
+ "string/wcpcpy.c",
+ "string/wcpncpy.c",
+ "string/wcscasecmp.c",
+ "string/wcscasecmp_l.c",
+ "string/wcscat.c",
+ "string/wcschr.c",
+ "string/wcscmp.c",
+ "string/wcscoll.c",
+ "string/wcscoll_l.c",
+ "string/wcscpy.c",
+ "string/wcscspn.c",
+ "string/wcsdup.c",
+ "string/wcslcat.c",
+ "string/wcslcpy.c",
+ "string/wcslen.c",
+ "string/wcsncasecmp.c",
+ "string/wcsncasecmp_l.c",
+ "string/wcsncat.c",
+ "string/wcsncmp.c",
+ "string/wcsncpy.c",
+ "string/wcsnlen.c",
+ "string/wcspbrk.c",
+ "string/wcsrchr.c",
+ "string/wcsspn.c",
+ "string/wcsstr.c",
+ "string/wcstok.c",
+ "string/wcswidth.c",
+ "string/wcsxfrm.c",
+ "string/wcsxfrm_l.c",
+ "string/wcwidth.c",
+ "string/wmemchr.c",
+ "string/wmemcmp.c",
+ "string/wmemcpy.c",
+ "string/wmemmove.c",
+ "string/wmempcpy.c",
+ "string/wmemset.c",
+ "string/xpg_strerror_r.c",
+}