package libc import ( "fmt" "path/filepath" "github.com/goplus/llgo/internal/crosscompile/compile" ) // GetPicolibcConfig returns the configuration for downloading and building picolibc func GetPicolibcConfig() compile.LibConfig { return compile.LibConfig{ Name: "picolibc", Version: "v0.1.0", Url: "https://github.com/goplus/picolibc/archive/refs/heads/main.zip", ResourceSubDir: "picolibc-main", } } // GetPicolibcCompileConfig returns configuration for picolibc func GetPicolibcCompileConfig(baseDir, target string) compile.CompileConfig { return compile.CompileConfig{ ExportCFlags: []string{ "-I" + baseDir, "-isystem" + filepath.Join(baseDir, "newlib", "libc", "include"), }, Groups: []compile.CompileGroup{ { OutputFileName: fmt.Sprintf("libc-%s.a", target), Files: []string{ filepath.Join(baseDir, "newlib", "libc", "string", "bcmp.c"), filepath.Join(baseDir, "newlib", "libc", "string", "bcopy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "bzero.c"), filepath.Join(baseDir, "newlib", "libc", "string", "explicit_bzero.c"), filepath.Join(baseDir, "newlib", "libc", "string", "ffsl.c"), filepath.Join(baseDir, "newlib", "libc", "string", "ffsll.c"), filepath.Join(baseDir, "newlib", "libc", "string", "fls.c"), filepath.Join(baseDir, "newlib", "libc", "string", "flsl.c"), filepath.Join(baseDir, "newlib", "libc", "string", "flsll.c"), filepath.Join(baseDir, "newlib", "libc", "string", "gnu_basename.c"), filepath.Join(baseDir, "newlib", "libc", "string", "index.c"), filepath.Join(baseDir, "newlib", "libc", "string", "memccpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "memchr.c"), filepath.Join(baseDir, "newlib", "libc", "string", "memcmp.c"), filepath.Join(baseDir, "newlib", "libc", "string", "memcpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "memmem.c"), filepath.Join(baseDir, "newlib", "libc", "string", "memmove.c"), filepath.Join(baseDir, "newlib", "libc", "string", "mempcpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "memrchr.c"), filepath.Join(baseDir, "newlib", "libc", "string", "memset.c"), filepath.Join(baseDir, "newlib", "libc", "string", "rawmemchr.c"), filepath.Join(baseDir, "newlib", "libc", "string", "rindex.c"), filepath.Join(baseDir, "newlib", "libc", "string", "stpcpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "stpncpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strcasecmp.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strcasecmp_l.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strcasestr.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strcat.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strchr.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strchrnul.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strcmp.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strcoll.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strcoll_l.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strcpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strcspn.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strerror_r.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strlcat.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strlcpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strlen.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strlwr.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strncasecmp.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strncasecmp_l.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strncat.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strncmp.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strncpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strndup.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strnlen.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strnstr.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strpbrk.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strrchr.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strsep.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strsignal.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strspn.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strstr.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strtok.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strtok_r.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strupr.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strverscmp.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strxfrm.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strxfrm_l.c"), filepath.Join(baseDir, "newlib", "libc", "string", "swab.c"), filepath.Join(baseDir, "newlib", "libc", "string", "timingsafe_bcmp.c"), filepath.Join(baseDir, "newlib", "libc", "string", "timingsafe_memcmp.c"), filepath.Join(baseDir, "newlib", "libc", "string", "strerror.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcpcpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcpncpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcscasecmp.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcscasecmp_l.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcscat.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcschr.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcscmp.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcscoll.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcscoll_l.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcscpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcscspn.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcsdup.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcslcat.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcslcpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcslen.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcsncasecmp.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcsncasecmp_l.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcsncat.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcsncmp.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcsncpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcsnlen.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcspbrk.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcsrchr.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcsspn.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcsstr.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcstok.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcswidth.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcsxfrm.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcsxfrm_l.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wcwidth.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wmemchr.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wmemcmp.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wmemcpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wmemmove.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wmempcpy.c"), filepath.Join(baseDir, "newlib", "libc", "string", "wmemset.c"), filepath.Join(baseDir, "newlib", "libc", "string", "xpg_strerror_r.c"), filepath.Join(baseDir, "newlib", "libc", "stdlib", "nano-calloc.c"), filepath.Join(baseDir, "newlib", "libc", "stdlib", "nano-malloc.c"), filepath.Join(baseDir, "newlib", "libc", "stdlib", "nano-pvalloc.c"), filepath.Join(baseDir, "newlib", "libc", "stdlib", "nano-realloc.c"), filepath.Join(baseDir, "newlib", "libc", "stdlib", "nano-valloc.c"), filepath.Join(baseDir, "newlib", "libc", "stdlib", "rand.c"), filepath.Join(baseDir, "newlib", "libc", "stdlib", "srand.c"), filepath.Join(baseDir, "newlib", "libc", "stdlib", "nano-free.c"), filepath.Join(baseDir, "newlib", "libc", "tinystdio", "printf.c"), filepath.Join(baseDir, "newlib", "libc", "tinystdio", "putchar.c"), filepath.Join(baseDir, "newlib", "libc", "tinystdio", "puts.c"), }, CFlags: []string{ "-D_COMPILING_NEWLIB", "-D_HAVE_ALIAS_ATTRIBUTE", "-DTINY_STDIO", "-DPOSIX_IO", "-DFORMAT_DEFAULT_INTEGER", "-D_IEEE_LIBM", "-D__OBSOLETE_MATH_FLOAT=1", "-D__OBSOLETE_MATH_DOUBLE=0", "-D_WANT_IO_C99_FORMATS", "-nostdlib", "-I" + baseDir, "-isystem" + filepath.Join(baseDir, "newlib", "libc", "include"), "-I" + filepath.Join(baseDir, "newlib", "libm", "common"), "-I" + filepath.Join(baseDir, "newlib", "libc", "locale"), "-I" + filepath.Join(baseDir, "newlib", "libc", "tinystdio"), }, LDFlags: _libcLDFlags, CCFlags: _libcCCFlags, }, }, } }