feat: support libc version

This commit is contained in:
Haolan
2025-09-04 19:08:48 +08:00
parent b1d95bb73c
commit 95bd495d7b
10 changed files with 503 additions and 135 deletions

View File

@@ -21,16 +21,20 @@ var _libcCCFlags = []string{
"-ffreestanding",
}
const (
_newlibUrl = "https://github.com/goplus/newlib/archive/refs/tags/v0.2.0.tar.gz"
_archiveInternalSrcDir = "newlib-0.2.0"
)
func withDefaultCCFlags(ccflags []string) []string {
return append(ccflags, _libcCCFlags...)
}
func getNewlibESP32ConfigRISCV(baseDir, target string) *compile.CompileConfig {
func GetNewlibESP32Config() compile.LibConfig {
return compile.LibConfig{
Url: "https://github.com/goplus/newlib/archive/refs/tags/v0.3.0.tar.gz",
Name: "newlib-esp32",
Version: "v0.3.0",
ArchiveSrcDir: "newlib-0.3.0",
}
}
func getNewlibESP32ConfigRISCV(baseDir, target string) compile.CompileConfig {
libcDir := filepath.Join(baseDir, "newlib", "libc")
libcIncludeDir := []string{
@@ -39,11 +43,8 @@ func getNewlibESP32ConfigRISCV(baseDir, target string) *compile.CompileConfig {
"-I" + libcDir,
}
return &compile.CompileConfig{
Url: _newlibUrl,
Name: "newlib-esp32",
LibcCFlags: libcIncludeDir,
ArchiveSrcDir: _archiveInternalSrcDir,
return compile.CompileConfig{
ExportCFlags: libcIncludeDir,
Groups: []compile.CompileGroup{
{
OutputFileName: fmt.Sprintf("libcrt0-%s.a", target),
@@ -1092,7 +1093,7 @@ func getNewlibESP32ConfigRISCV(baseDir, target string) *compile.CompileConfig {
}
}
func getNewlibESP32ConfigXtensa(baseDir, target string) *compile.CompileConfig {
func getNewlibESP32ConfigXtensa(baseDir, target string) compile.CompileConfig {
libcDir := filepath.Join(baseDir, "newlib", "libc")
libcIncludeDir := []string{
@@ -1101,11 +1102,8 @@ func getNewlibESP32ConfigXtensa(baseDir, target string) *compile.CompileConfig {
"-I" + libcDir,
}
return &compile.CompileConfig{
Url: _newlibUrl,
Name: "newlib-esp32",
ArchiveSrcDir: _archiveInternalSrcDir,
LibcCFlags: libcIncludeDir,
return compile.CompileConfig{
ExportCFlags: libcIncludeDir,
Groups: []compile.CompileGroup{
{
OutputFileName: fmt.Sprintf("libcrt0-%s.a", target),
@@ -2075,7 +2073,7 @@ func getNewlibESP32ConfigXtensa(baseDir, target string) *compile.CompileConfig {
}
// getNewlibESP32Config returns configuration for newlib esp32
func GetNewlibESP32Config(baseDir, target, mcpu string) *compile.CompileConfig {
func GetNewlibESP32CompileConfig(baseDir, target, mcpu string) compile.CompileConfig {
if strings.Contains(target, "riscv32") {
return getNewlibESP32ConfigRISCV(baseDir, target)
}