fix: export libc cflags for compiler-rt
fix: libc include dir fix: xtensa internal src dir fix: xtensa internal src dir fix: ignore wasm target fix: export libc cflags to global cflags fix: rtlib libc include dir fix: ignore some errors for libc fix: don's search system path for libc fix: adjust compiling options ci: add libc fix: libc cflags fix: test path fix: libc cflags fix: libc cflags
This commit is contained in:
@@ -8,12 +8,42 @@ import (
|
||||
"github.com/goplus/llgo/internal/crosscompile/compile"
|
||||
)
|
||||
|
||||
var _libcLDFlags = []string{
|
||||
"-nostdlib",
|
||||
"-ffunction-sections",
|
||||
"-fdata-sections",
|
||||
}
|
||||
|
||||
var _libcCCFlags = []string{
|
||||
"-Oz",
|
||||
"-fno-builtin",
|
||||
// freestanding tells compiler this is a baremental project
|
||||
"-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 {
|
||||
libcDir := filepath.Join(baseDir, "newlib", "libc")
|
||||
|
||||
libcIncludeDir := []string{
|
||||
"-isystem" + filepath.Join(libcDir, "include"),
|
||||
"-I" + filepath.Join(baseDir, "newlib"),
|
||||
"-I" + libcDir,
|
||||
}
|
||||
|
||||
return &compile.CompileConfig{
|
||||
Url: "https://github.com/goplus/newlib/archive/refs/tags/v0.2.0.tar.gz",
|
||||
Name: "newlib-esp32",
|
||||
Url: _newlibUrl,
|
||||
Name: "newlib-esp32",
|
||||
LibcCFlags: libcIncludeDir,
|
||||
ArchiveSrcDir: _archiveInternalSrcDir,
|
||||
Groups: []compile.CompileGroup{
|
||||
{
|
||||
OutputFileName: fmt.Sprintf("libcrt0-%s.a", target),
|
||||
@@ -30,10 +60,8 @@ func getNewlibESP32ConfigRISCV(baseDir, target string) *compile.CompileConfig {
|
||||
"-I" + filepath.Join(baseDir, "libgloss", "riscv"),
|
||||
"-I" + filepath.Join(baseDir, "libgloss", "riscv", "esp"),
|
||||
},
|
||||
LDFlags: []string{"-nostdlib"},
|
||||
CCFlags: []string{
|
||||
"-Oz",
|
||||
},
|
||||
LDFlags: _libcLDFlags,
|
||||
CCFlags: _libcCCFlags,
|
||||
},
|
||||
{
|
||||
OutputFileName: fmt.Sprintf("libgloss-%s.a", target),
|
||||
@@ -298,10 +326,8 @@ func getNewlibESP32ConfigRISCV(baseDir, target string) *compile.CompileConfig {
|
||||
"-I" + filepath.Join(baseDir, "libgloss", "riscv"),
|
||||
"-I" + filepath.Join(baseDir, "libgloss", "riscv", "esp"),
|
||||
},
|
||||
LDFlags: []string{"-nostdlib"},
|
||||
CCFlags: []string{
|
||||
"-Oz",
|
||||
},
|
||||
LDFlags: _libcLDFlags,
|
||||
CCFlags: _libcCCFlags,
|
||||
},
|
||||
{
|
||||
OutputFileName: fmt.Sprintf("libc-%s.a", target),
|
||||
@@ -1054,27 +1080,32 @@ func getNewlibESP32ConfigRISCV(baseDir, target string) *compile.CompileConfig {
|
||||
"-I" + filepath.Join(libcDir, "posix"),
|
||||
"-I" + filepath.Join(libcDir, "stdlib"),
|
||||
},
|
||||
LDFlags: []string{"-nostdlib"},
|
||||
CCFlags: []string{
|
||||
"-Oz",
|
||||
LDFlags: _libcLDFlags,
|
||||
CCFlags: withDefaultCCFlags([]string{
|
||||
"-fno-builtin",
|
||||
"-ffreestanding",
|
||||
"-Wno-implicit-function-declaration",
|
||||
"-Wno-int-conversion",
|
||||
"-Wno-unused-command-line-argument",
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
ArchiveSrcDir: "newlib-0.2.0",
|
||||
}
|
||||
}
|
||||
|
||||
func getNewlibESP32ConfigXtensa(baseDir, target string) *compile.CompileConfig {
|
||||
libcDir := filepath.Join(baseDir, "newlib", "libc")
|
||||
|
||||
libcIncludeDir := []string{
|
||||
"-I" + filepath.Join(libcDir, "include"),
|
||||
"-I" + filepath.Join(baseDir, "newlib"),
|
||||
"-I" + libcDir,
|
||||
}
|
||||
|
||||
return &compile.CompileConfig{
|
||||
Url: "https://github.com/goplus/newlib/archive/refs/tags/v0.2.0.tar.gz",
|
||||
Name: "newlib-esp32",
|
||||
Url: _newlibUrl,
|
||||
Name: "newlib-esp32",
|
||||
ArchiveSrcDir: _archiveInternalSrcDir,
|
||||
LibcCFlags: libcIncludeDir,
|
||||
Groups: []compile.CompileGroup{
|
||||
{
|
||||
OutputFileName: fmt.Sprintf("libcrt0-%s.a", target),
|
||||
@@ -1095,10 +1126,8 @@ func getNewlibESP32ConfigXtensa(baseDir, target string) *compile.CompileConfig {
|
||||
"-I" + filepath.Join(baseDir, "libgloss", "xtensa", "include"),
|
||||
"-I" + filepath.Join(baseDir, "libgloss", "xtensa", "boards", "esp32", "include"),
|
||||
},
|
||||
LDFlags: []string{"-nostdlib"},
|
||||
CCFlags: []string{
|
||||
"-Oz",
|
||||
},
|
||||
LDFlags: _libcLDFlags,
|
||||
CCFlags: _libcCCFlags,
|
||||
},
|
||||
{
|
||||
OutputFileName: fmt.Sprintf("libgloss-%s.a", target),
|
||||
@@ -1292,10 +1321,8 @@ func getNewlibESP32ConfigXtensa(baseDir, target string) *compile.CompileConfig {
|
||||
"-I" + filepath.Join(baseDir, "libgloss", "xtensa", "include"),
|
||||
"-I" + filepath.Join(baseDir, "libgloss", "xtensa", "boards", "esp32", "include"),
|
||||
},
|
||||
LDFlags: []string{"-nostdlib"},
|
||||
CCFlags: []string{
|
||||
"-Oz",
|
||||
},
|
||||
LDFlags: _libcLDFlags,
|
||||
CCFlags: _libcCCFlags,
|
||||
},
|
||||
{
|
||||
OutputFileName: fmt.Sprintf("libc-%s.a", target),
|
||||
@@ -2035,18 +2062,15 @@ func getNewlibESP32ConfigXtensa(baseDir, target string) *compile.CompileConfig {
|
||||
"-I" + filepath.Join(libcDir, "posix"),
|
||||
"-I" + filepath.Join(libcDir, "stdlib"),
|
||||
},
|
||||
LDFlags: []string{"-nostdlib"},
|
||||
CCFlags: []string{
|
||||
"-Oz",
|
||||
LDFlags: _libcLDFlags,
|
||||
CCFlags: withDefaultCCFlags([]string{
|
||||
"-fno-builtin",
|
||||
"-ffreestanding",
|
||||
"-Wno-implicit-function-declaration",
|
||||
"-Wno-int-conversion",
|
||||
"-Wno-unused-command-line-argument",
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
ArchiveSrcDir: "newlib-0.1.0",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user