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:
2
.github/actions/setup-deps/action.yml
vendored
2
.github/actions/setup-deps/action.yml
vendored
@@ -34,7 +34,7 @@ runs:
|
|||||||
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${{inputs.llvm-version}} main" | sudo tee /etc/apt/sources.list.d/llvm.list
|
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${{inputs.llvm-version}} main" | sudo tee /etc/apt/sources.list.d/llvm.list
|
||||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y llvm-${{inputs.llvm-version}}-dev clang-${{inputs.llvm-version}} libclang-${{inputs.llvm-version}}-dev lld-${{inputs.llvm-version}} libunwind-${{inputs.llvm-version}}-dev libc++-${{inputs.llvm-version}}-dev pkg-config libgc-dev libssl-dev zlib1g-dev libffi-dev libcjson-dev libuv1-dev
|
sudo apt-get install -y llvm-${{inputs.llvm-version}}-dev clang-${{inputs.llvm-version}} libclang-${{inputs.llvm-version}}-dev lld-${{inputs.llvm-version}} libunwind-${{inputs.llvm-version}}-dev libc-dev libc++-${{inputs.llvm-version}}-dev pkg-config libgc-dev libssl-dev zlib1g-dev libffi-dev libcjson-dev libuv1-dev
|
||||||
echo "PATH=/usr/lib/llvm-${{inputs.llvm-version}}/bin:$PATH" >> $GITHUB_ENV
|
echo "PATH=/usr/lib/llvm-${{inputs.llvm-version}}/bin:$PATH" >> $GITHUB_ENV
|
||||||
|
|
||||||
# Install optional deps for demos.
|
# Install optional deps for demos.
|
||||||
|
|||||||
@@ -11,6 +11,14 @@ import (
|
|||||||
"github.com/goplus/llgo/internal/clang"
|
"github.com/goplus/llgo/internal/clang"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type CompileOptions struct {
|
||||||
|
CC string // Compiler to use
|
||||||
|
Linker string
|
||||||
|
CCFLAGS []string
|
||||||
|
CFLAGS []string
|
||||||
|
LDFLAGS []string
|
||||||
|
}
|
||||||
|
|
||||||
type CompileGroup struct {
|
type CompileGroup struct {
|
||||||
OutputFileName string
|
OutputFileName string
|
||||||
Files []string // List of source files to compile
|
Files []string // List of source files to compile
|
||||||
@@ -25,7 +33,9 @@ func (g CompileGroup) IsCompiled(outputDir string) bool {
|
|||||||
return !os.IsNotExist(err)
|
return !os.IsNotExist(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g CompileGroup) Compile(outputDir, cc, linkerName string, extraCCFlags, extraLDFlags []string) (err error) {
|
func (g CompileGroup) Compile(
|
||||||
|
outputDir string, options CompileOptions,
|
||||||
|
) (err error) {
|
||||||
if g.IsCompiled(outputDir) {
|
if g.IsCompiled(outputDir) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -35,15 +45,17 @@ func (g CompileGroup) Compile(outputDir, cc, linkerName string, extraCCFlags, ex
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(tmpCompileDir)
|
defer os.RemoveAll(tmpCompileDir)
|
||||||
|
|
||||||
compileLDFlags := append(slices.Clone(extraLDFlags), g.LDFlags...)
|
compileLDFlags := append(slices.Clone(options.LDFLAGS), g.LDFlags...)
|
||||||
compileCCFlags := append(slices.Clone(extraCCFlags), g.CCFlags...)
|
compileCCFlags := append(slices.Clone(options.CCFLAGS), g.CCFlags...)
|
||||||
cfg := clang.NewConfig(cc, compileCCFlags, g.CFlags, compileLDFlags, linkerName)
|
compileCFFlags := append(slices.Clone(options.CFLAGS), g.CFlags...)
|
||||||
|
|
||||||
|
cfg := clang.NewConfig(options.CC, compileCCFlags, compileCFFlags, compileLDFlags, options.Linker)
|
||||||
|
|
||||||
var objFiles []string
|
var objFiles []string
|
||||||
|
|
||||||
compiler := clang.NewCompiler(cfg)
|
compiler := clang.NewCompiler(cfg)
|
||||||
|
|
||||||
compiler.Verbose = false
|
compiler.Verbose = true
|
||||||
|
|
||||||
archive := filepath.Join(outputDir, g.OutputFileName)
|
archive := filepath.Join(outputDir, g.OutputFileName)
|
||||||
fmt.Fprintf(os.Stderr, "Start to compile group %s to %s...\n", g.OutputFileName, archive)
|
fmt.Fprintf(os.Stderr, "Start to compile group %s to %s...\n", g.OutputFileName, archive)
|
||||||
@@ -70,7 +82,7 @@ func (g CompileGroup) Compile(outputDir, cc, linkerName string, extraCCFlags, ex
|
|||||||
args := []string{"rcs", archive}
|
args := []string{"rcs", archive}
|
||||||
args = append(args, objFiles...)
|
args = append(args, objFiles...)
|
||||||
|
|
||||||
ccDir := filepath.Dir(cc)
|
ccDir := filepath.Dir(options.CC)
|
||||||
llvmAr := filepath.Join(ccDir, "llvm-ar")
|
llvmAr := filepath.Join(ccDir, "llvm-ar")
|
||||||
|
|
||||||
cmd := exec.Command(llvmAr, args...)
|
cmd := exec.Command(llvmAr, args...)
|
||||||
@@ -87,13 +99,5 @@ type CompileConfig struct {
|
|||||||
Name string // compile name (e.g., "picolibc", "musl", "glibc")
|
Name string // compile name (e.g., "picolibc", "musl", "glibc")
|
||||||
Groups []CompileGroup
|
Groups []CompileGroup
|
||||||
ArchiveSrcDir string
|
ArchiveSrcDir string
|
||||||
}
|
LibcCFlags []string
|
||||||
|
|
||||||
func (c CompileConfig) IsCompiled(outputDir string) bool {
|
|
||||||
for _, group := range c.Groups {
|
|
||||||
if !group.IsCompiled(outputDir) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package compile
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -18,12 +19,12 @@ func TestIsCompile(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.IsCompiled(".") || cfg.Groups[0].IsCompiled(".") {
|
if cfg.Groups[0].IsCompiled(".") {
|
||||||
t.Errorf("unexpected result: should false")
|
t.Errorf("unexpected result: should false")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run("IsCompile Exists", func(t *testing.T) {
|
t.Run("IsCompile Exists", func(t *testing.T) {
|
||||||
tmpFile, err := os.CreateTemp(".", "test*.a")
|
tmpFile, err := os.CreateTemp("", "test*.a")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
@@ -37,7 +38,7 @@ func TestIsCompile(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cfg.IsCompiled(".") && !cfg.Groups[0].IsCompiled(".") {
|
if cfg.Groups[0].IsCompiled(filepath.Dir(tmpFile.Name())) {
|
||||||
t.Errorf("unexpected result: should true")
|
t.Errorf("unexpected result: should true")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -54,7 +55,10 @@ func TestCompile(t *testing.T) {
|
|||||||
group := CompileGroup{
|
group := CompileGroup{
|
||||||
OutputFileName: tmpFile.Name(),
|
OutputFileName: tmpFile.Name(),
|
||||||
}
|
}
|
||||||
err = group.Compile(".", "clang", "lld", nil, nil)
|
err = group.Compile(".", CompileOptions{
|
||||||
|
CC: "clang",
|
||||||
|
Linker: "lld",
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected result: should nil")
|
t.Errorf("unexpected result: should nil")
|
||||||
}
|
}
|
||||||
@@ -74,7 +78,10 @@ func TestCompile(t *testing.T) {
|
|||||||
group := CompileGroup{
|
group := CompileGroup{
|
||||||
OutputFileName: "nop.a",
|
OutputFileName: "nop.a",
|
||||||
}
|
}
|
||||||
err = group.Compile(".", "clang", "lld", nil, nil)
|
err = group.Compile(".", CompileOptions{
|
||||||
|
CC: "clang",
|
||||||
|
Linker: "lld",
|
||||||
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("unexpected result: should not nil")
|
t.Errorf("unexpected result: should not nil")
|
||||||
}
|
}
|
||||||
@@ -104,11 +111,18 @@ func TestCompile(t *testing.T) {
|
|||||||
OutputFileName: "nop.a",
|
OutputFileName: "nop.a",
|
||||||
Files: []string{tmpFile.Name()},
|
Files: []string{tmpFile.Name()},
|
||||||
}
|
}
|
||||||
err = group.Compile(".", "clang", "lld", []string{"-nostdinc"}, nil)
|
err = group.Compile(".", CompileOptions{
|
||||||
|
CC: "clang",
|
||||||
|
Linker: "lld",
|
||||||
|
CCFLAGS: []string{"-nostdinc"},
|
||||||
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("unexpected result: should not nil")
|
t.Errorf("unexpected result: should not nil")
|
||||||
}
|
}
|
||||||
err = group.Compile(".", "clang", "lld", nil, nil)
|
err = group.Compile(".", CompileOptions{
|
||||||
|
CC: "clang",
|
||||||
|
Linker: "lld",
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected result: should not nil")
|
t.Errorf("unexpected result: should not nil")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,42 @@ import (
|
|||||||
"github.com/goplus/llgo/internal/crosscompile/compile"
|
"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 {
|
func getNewlibESP32ConfigRISCV(baseDir, target string) *compile.CompileConfig {
|
||||||
libcDir := filepath.Join(baseDir, "newlib", "libc")
|
libcDir := filepath.Join(baseDir, "newlib", "libc")
|
||||||
|
|
||||||
|
libcIncludeDir := []string{
|
||||||
|
"-isystem" + filepath.Join(libcDir, "include"),
|
||||||
|
"-I" + filepath.Join(baseDir, "newlib"),
|
||||||
|
"-I" + libcDir,
|
||||||
|
}
|
||||||
|
|
||||||
return &compile.CompileConfig{
|
return &compile.CompileConfig{
|
||||||
Url: "https://github.com/goplus/newlib/archive/refs/tags/v0.2.0.tar.gz",
|
Url: _newlibUrl,
|
||||||
Name: "newlib-esp32",
|
Name: "newlib-esp32",
|
||||||
|
LibcCFlags: libcIncludeDir,
|
||||||
|
ArchiveSrcDir: _archiveInternalSrcDir,
|
||||||
Groups: []compile.CompileGroup{
|
Groups: []compile.CompileGroup{
|
||||||
{
|
{
|
||||||
OutputFileName: fmt.Sprintf("libcrt0-%s.a", target),
|
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"),
|
||||||
"-I" + filepath.Join(baseDir, "libgloss", "riscv", "esp"),
|
"-I" + filepath.Join(baseDir, "libgloss", "riscv", "esp"),
|
||||||
},
|
},
|
||||||
LDFlags: []string{"-nostdlib"},
|
LDFlags: _libcLDFlags,
|
||||||
CCFlags: []string{
|
CCFlags: _libcCCFlags,
|
||||||
"-Oz",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
OutputFileName: fmt.Sprintf("libgloss-%s.a", target),
|
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"),
|
||||||
"-I" + filepath.Join(baseDir, "libgloss", "riscv", "esp"),
|
"-I" + filepath.Join(baseDir, "libgloss", "riscv", "esp"),
|
||||||
},
|
},
|
||||||
LDFlags: []string{"-nostdlib"},
|
LDFlags: _libcLDFlags,
|
||||||
CCFlags: []string{
|
CCFlags: _libcCCFlags,
|
||||||
"-Oz",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
OutputFileName: fmt.Sprintf("libc-%s.a", target),
|
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, "posix"),
|
||||||
"-I" + filepath.Join(libcDir, "stdlib"),
|
"-I" + filepath.Join(libcDir, "stdlib"),
|
||||||
},
|
},
|
||||||
LDFlags: []string{"-nostdlib"},
|
LDFlags: _libcLDFlags,
|
||||||
CCFlags: []string{
|
CCFlags: withDefaultCCFlags([]string{
|
||||||
"-Oz",
|
|
||||||
"-fno-builtin",
|
"-fno-builtin",
|
||||||
"-ffreestanding",
|
|
||||||
"-Wno-implicit-function-declaration",
|
"-Wno-implicit-function-declaration",
|
||||||
"-Wno-int-conversion",
|
"-Wno-int-conversion",
|
||||||
"-Wno-unused-command-line-argument",
|
"-Wno-unused-command-line-argument",
|
||||||
},
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ArchiveSrcDir: "newlib-0.2.0",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getNewlibESP32ConfigXtensa(baseDir, target string) *compile.CompileConfig {
|
func getNewlibESP32ConfigXtensa(baseDir, target string) *compile.CompileConfig {
|
||||||
libcDir := filepath.Join(baseDir, "newlib", "libc")
|
libcDir := filepath.Join(baseDir, "newlib", "libc")
|
||||||
|
|
||||||
|
libcIncludeDir := []string{
|
||||||
|
"-I" + filepath.Join(libcDir, "include"),
|
||||||
|
"-I" + filepath.Join(baseDir, "newlib"),
|
||||||
|
"-I" + libcDir,
|
||||||
|
}
|
||||||
|
|
||||||
return &compile.CompileConfig{
|
return &compile.CompileConfig{
|
||||||
Url: "https://github.com/goplus/newlib/archive/refs/tags/v0.2.0.tar.gz",
|
Url: _newlibUrl,
|
||||||
Name: "newlib-esp32",
|
Name: "newlib-esp32",
|
||||||
|
ArchiveSrcDir: _archiveInternalSrcDir,
|
||||||
|
LibcCFlags: libcIncludeDir,
|
||||||
Groups: []compile.CompileGroup{
|
Groups: []compile.CompileGroup{
|
||||||
{
|
{
|
||||||
OutputFileName: fmt.Sprintf("libcrt0-%s.a", target),
|
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", "include"),
|
||||||
"-I" + filepath.Join(baseDir, "libgloss", "xtensa", "boards", "esp32", "include"),
|
"-I" + filepath.Join(baseDir, "libgloss", "xtensa", "boards", "esp32", "include"),
|
||||||
},
|
},
|
||||||
LDFlags: []string{"-nostdlib"},
|
LDFlags: _libcLDFlags,
|
||||||
CCFlags: []string{
|
CCFlags: _libcCCFlags,
|
||||||
"-Oz",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
OutputFileName: fmt.Sprintf("libgloss-%s.a", target),
|
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", "include"),
|
||||||
"-I" + filepath.Join(baseDir, "libgloss", "xtensa", "boards", "esp32", "include"),
|
"-I" + filepath.Join(baseDir, "libgloss", "xtensa", "boards", "esp32", "include"),
|
||||||
},
|
},
|
||||||
LDFlags: []string{"-nostdlib"},
|
LDFlags: _libcLDFlags,
|
||||||
CCFlags: []string{
|
CCFlags: _libcCCFlags,
|
||||||
"-Oz",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
OutputFileName: fmt.Sprintf("libc-%s.a", target),
|
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, "posix"),
|
||||||
"-I" + filepath.Join(libcDir, "stdlib"),
|
"-I" + filepath.Join(libcDir, "stdlib"),
|
||||||
},
|
},
|
||||||
LDFlags: []string{"-nostdlib"},
|
LDFlags: _libcLDFlags,
|
||||||
CCFlags: []string{
|
CCFlags: withDefaultCCFlags([]string{
|
||||||
"-Oz",
|
|
||||||
"-fno-builtin",
|
"-fno-builtin",
|
||||||
"-ffreestanding",
|
|
||||||
"-Wno-implicit-function-declaration",
|
"-Wno-implicit-function-declaration",
|
||||||
"-Wno-int-conversion",
|
"-Wno-int-conversion",
|
||||||
"-Wno-unused-command-line-argument",
|
"-Wno-unused-command-line-argument",
|
||||||
},
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ArchiveSrcDir: "newlib-0.1.0",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,131 +9,132 @@ import (
|
|||||||
|
|
||||||
// getPicolibcConfig returns configuration for picolibc
|
// getPicolibcConfig returns configuration for picolibc
|
||||||
func GetPicolibcConfig(baseDir, target string) *compile.CompileConfig {
|
func GetPicolibcConfig(baseDir, target string) *compile.CompileConfig {
|
||||||
libcIncludeDir := filepath.Join(baseDir, "libc", "include")
|
|
||||||
libmIncludeDir := filepath.Join(baseDir, "libm", "common")
|
|
||||||
localeIncludeDir := filepath.Join(baseDir, "libc", "locale")
|
|
||||||
|
|
||||||
return &compile.CompileConfig{
|
return &compile.CompileConfig{
|
||||||
Url: "https://github.com/goplus/picolibc/archive/refs/heads/main.zip",
|
Url: "https://github.com/goplus/picolibc/archive/refs/heads/main.zip",
|
||||||
Name: "picolibc",
|
Name: "picolibc",
|
||||||
|
LibcCFlags: []string{
|
||||||
|
"-I" + baseDir,
|
||||||
|
"-isystem" + filepath.Join(baseDir, "newlib", "libc", "include"),
|
||||||
|
},
|
||||||
|
|
||||||
Groups: []compile.CompileGroup{
|
Groups: []compile.CompileGroup{
|
||||||
{
|
{
|
||||||
OutputFileName: fmt.Sprintf("libc-%s.a", target),
|
OutputFileName: fmt.Sprintf("libc-%s.a", target),
|
||||||
Files: []string{
|
Files: []string{
|
||||||
filepath.Join(baseDir, "libc", "string", "bcmp.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "bcmp.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "bcopy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "bcopy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "bzero.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "bzero.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "explicit_bzero.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "explicit_bzero.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "ffsl.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "ffsl.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "ffsll.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "ffsll.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "fls.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "fls.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "flsl.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "flsl.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "flsll.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "flsll.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "gnu_basename.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "gnu_basename.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "index.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "index.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "memccpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "memccpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "memchr.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "memchr.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "memcmp.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "memcmp.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "memcpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "memcpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "memmem.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "memmem.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "memmove.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "memmove.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "mempcpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "mempcpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "memrchr.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "memrchr.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "memset.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "memset.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "rawmemchr.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "rawmemchr.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "rindex.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "rindex.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "stpcpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "stpcpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "stpncpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "stpncpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strcasecmp.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strcasecmp.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strcasecmp_l.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strcasecmp_l.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strcasestr.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strcasestr.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strcat.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strcat.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strchr.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strchr.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strchrnul.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strchrnul.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strcmp.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strcmp.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strcoll.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strcoll.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strcoll_l.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strcoll_l.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strcpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strcpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strcspn.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strcspn.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strerror_r.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strerror_r.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strlcat.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strlcat.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strlcpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strlcpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strlen.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strlen.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strlwr.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strlwr.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strncasecmp.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strncasecmp.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strncasecmp_l.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strncasecmp_l.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strncat.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strncat.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strncmp.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strncmp.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strncpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strncpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strndup.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strndup.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strnlen.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strnlen.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strnstr.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strnstr.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strpbrk.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strpbrk.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strrchr.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strrchr.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strsep.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strsep.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strsignal.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strsignal.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strspn.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strspn.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strstr.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strstr.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strtok.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strtok.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strtok_r.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strtok_r.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strupr.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strupr.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strverscmp.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strverscmp.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strxfrm.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strxfrm.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strxfrm_l.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strxfrm_l.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "swab.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "swab.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "timingsafe_bcmp.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "timingsafe_bcmp.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "timingsafe_memcmp.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "timingsafe_memcmp.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "strerror.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "strerror.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcpcpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcpcpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcpncpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcpncpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcscasecmp.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcscasecmp.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcscasecmp_l.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcscasecmp_l.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcscat.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcscat.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcschr.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcschr.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcscmp.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcscmp.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcscoll.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcscoll.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcscoll_l.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcscoll_l.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcscpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcscpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcscspn.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcscspn.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcsdup.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcsdup.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcslcat.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcslcat.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcslcpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcslcpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcslen.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcslen.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcsncasecmp.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcsncasecmp.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcsncasecmp_l.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcsncasecmp_l.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcsncat.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcsncat.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcsncmp.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcsncmp.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcsncpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcsncpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcsnlen.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcsnlen.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcspbrk.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcspbrk.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcsrchr.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcsrchr.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcsspn.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcsspn.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcsstr.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcsstr.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcstok.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcstok.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcswidth.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcswidth.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcsxfrm.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcsxfrm.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcsxfrm_l.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcsxfrm_l.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wcwidth.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wcwidth.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wmemchr.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wmemchr.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wmemcmp.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wmemcmp.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wmemcpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wmemcpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wmemmove.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wmemmove.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wmempcpy.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wmempcpy.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "wmemset.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "wmemset.c"),
|
||||||
filepath.Join(baseDir, "libc", "string", "xpg_strerror_r.c"),
|
filepath.Join(baseDir, "newlib", "libc", "string", "xpg_strerror_r.c"),
|
||||||
|
|
||||||
filepath.Join(baseDir, "libc", "stdlib", "nano-calloc.c"),
|
filepath.Join(baseDir, "newlib", "libc", "stdlib", "nano-calloc.c"),
|
||||||
filepath.Join(baseDir, "libc", "stdlib", "nano-malloc.c"),
|
filepath.Join(baseDir, "newlib", "libc", "stdlib", "nano-malloc.c"),
|
||||||
filepath.Join(baseDir, "libc", "stdlib", "nano-pvalloc.c"),
|
filepath.Join(baseDir, "newlib", "libc", "stdlib", "nano-pvalloc.c"),
|
||||||
filepath.Join(baseDir, "libc", "stdlib", "nano-realloc.c"),
|
filepath.Join(baseDir, "newlib", "libc", "stdlib", "nano-realloc.c"),
|
||||||
filepath.Join(baseDir, "libc", "stdlib", "nano-valloc.c"),
|
filepath.Join(baseDir, "newlib", "libc", "stdlib", "nano-valloc.c"),
|
||||||
filepath.Join(baseDir, "libc", "stdlib", "rand.c"),
|
filepath.Join(baseDir, "newlib", "libc", "stdlib", "rand.c"),
|
||||||
filepath.Join(baseDir, "libc", "stdlib", "srand.c"),
|
filepath.Join(baseDir, "newlib", "libc", "stdlib", "srand.c"),
|
||||||
filepath.Join(baseDir, "libc", "stdlib", "nano-free.c"),
|
filepath.Join(baseDir, "newlib", "libc", "stdlib", "nano-free.c"),
|
||||||
|
|
||||||
filepath.Join(baseDir, "libc", "tinystdio", "printf.c"),
|
filepath.Join(baseDir, "newlib", "libc", "tinystdio", "printf.c"),
|
||||||
filepath.Join(baseDir, "libc", "tinystdio", "putchar.c"),
|
filepath.Join(baseDir, "newlib", "libc", "tinystdio", "putchar.c"),
|
||||||
filepath.Join(baseDir, "libc", "tinystdio", "puts.c"),
|
filepath.Join(baseDir, "newlib", "libc", "tinystdio", "puts.c"),
|
||||||
},
|
},
|
||||||
CFlags: []string{
|
CFlags: []string{
|
||||||
"-D_COMPILING_NEWLIB",
|
"-D_COMPILING_NEWLIB",
|
||||||
@@ -146,18 +147,17 @@ func GetPicolibcConfig(baseDir, target string) *compile.CompileConfig {
|
|||||||
"-D__OBSOLETE_MATH_DOUBLE=0",
|
"-D__OBSOLETE_MATH_DOUBLE=0",
|
||||||
"-D_WANT_IO_C99_FORMATS",
|
"-D_WANT_IO_C99_FORMATS",
|
||||||
"-nostdlib",
|
"-nostdlib",
|
||||||
"-isystem" + libcIncludeDir,
|
|
||||||
"-I" + libmIncludeDir,
|
|
||||||
"-I" + localeIncludeDir,
|
|
||||||
"-I" + baseDir,
|
"-I" + baseDir,
|
||||||
"-I" + filepath.Join(baseDir, "libc", "tinystdio"),
|
"-isystem" + filepath.Join(baseDir, "newlib", "libc", "include"),
|
||||||
},
|
"-I" + filepath.Join(baseDir, "newlib", "libm", "common"),
|
||||||
LDFlags: []string{"-nostdlib"},
|
"-I" + filepath.Join(baseDir, "newlib", "libc", "locale"),
|
||||||
CCFlags: []string{
|
|
||||||
"-Oz",
|
"-I" + filepath.Join(baseDir, "newlib", "libc", "tinystdio"),
|
||||||
},
|
},
|
||||||
|
LDFlags: _libcLDFlags,
|
||||||
|
CCFlags: _libcCCFlags,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ArchiveSrcDir: filepath.Join("picolibc-main", "newlib"),
|
ArchiveSrcDir: "picolibc-main",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ func platformSpecifiedFiles(builtinsDir, target string) []string {
|
|||||||
filepath.Join(builtinsDir, "riscv", "fp_mode.c"),
|
filepath.Join(builtinsDir, "riscv", "fp_mode.c"),
|
||||||
filepath.Join(builtinsDir, "riscv", "save.S"),
|
filepath.Join(builtinsDir, "riscv", "save.S"),
|
||||||
filepath.Join(builtinsDir, "riscv", "restore.S"),
|
filepath.Join(builtinsDir, "riscv", "restore.S"),
|
||||||
|
filepath.Join(builtinsDir, "atomic.c"),
|
||||||
}
|
}
|
||||||
case strings.Contains(target, "riscv64"):
|
case strings.Contains(target, "riscv64"):
|
||||||
return []string{
|
return []string{
|
||||||
@@ -45,6 +46,7 @@ func platformSpecifiedFiles(builtinsDir, target string) []string {
|
|||||||
filepath.Join(builtinsDir, "trunctfdf2.c"),
|
filepath.Join(builtinsDir, "trunctfdf2.c"),
|
||||||
filepath.Join(builtinsDir, "trunctfhf2.c"),
|
filepath.Join(builtinsDir, "trunctfhf2.c"),
|
||||||
filepath.Join(builtinsDir, "trunctfsf2.c"),
|
filepath.Join(builtinsDir, "trunctfsf2.c"),
|
||||||
|
filepath.Join(builtinsDir, "atomic.c"),
|
||||||
}
|
}
|
||||||
case strings.Contains(target, "arm"):
|
case strings.Contains(target, "arm"):
|
||||||
return []string{
|
return []string{
|
||||||
@@ -87,6 +89,7 @@ func platformSpecifiedFiles(builtinsDir, target string) []string {
|
|||||||
case target == "xtensa":
|
case target == "xtensa":
|
||||||
return []string{
|
return []string{
|
||||||
filepath.Join(builtinsDir, "xtensa", "ieee754_sqrtf.S"),
|
filepath.Join(builtinsDir, "xtensa", "ieee754_sqrtf.S"),
|
||||||
|
filepath.Join(builtinsDir, "atomic.c"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -252,7 +255,6 @@ func GetCompilerRTConfig(baseDir, target string) *compile.CompileConfig {
|
|||||||
filepath.Join(baseDir, "lib", "builtins", "trunctfdf2.c"),
|
filepath.Join(baseDir, "lib", "builtins", "trunctfdf2.c"),
|
||||||
filepath.Join(baseDir, "lib", "builtins", "trunctfhf2.c"),
|
filepath.Join(baseDir, "lib", "builtins", "trunctfhf2.c"),
|
||||||
filepath.Join(baseDir, "lib", "builtins", "trunctfsf2.c"),
|
filepath.Join(baseDir, "lib", "builtins", "trunctfsf2.c"),
|
||||||
filepath.Join(baseDir, "lib", "builtins", "atomic.c"),
|
|
||||||
}),
|
}),
|
||||||
CFlags: []string{
|
CFlags: []string{
|
||||||
"-DNDEBUG",
|
"-DNDEBUG",
|
||||||
|
|||||||
@@ -223,8 +223,7 @@ func ldFlagsFromFileName(fileName string) string {
|
|||||||
|
|
||||||
func getOrCompileWithConfig(
|
func getOrCompileWithConfig(
|
||||||
compileConfig *compile.CompileConfig,
|
compileConfig *compile.CompileConfig,
|
||||||
outputDir, cc, linkerName string,
|
outputDir string, options compile.CompileOptions,
|
||||||
exportCCFlags, exportLDFlags []string,
|
|
||||||
) (ldflags []string, err error) {
|
) (ldflags []string, err error) {
|
||||||
if err = checkDownloadAndExtractLib(
|
if err = checkDownloadAndExtractLib(
|
||||||
compileConfig.Url, outputDir,
|
compileConfig.Url, outputDir,
|
||||||
@@ -235,7 +234,7 @@ func getOrCompileWithConfig(
|
|||||||
ldflags = append(ldflags, "-nostdlib", "-L"+outputDir)
|
ldflags = append(ldflags, "-nostdlib", "-L"+outputDir)
|
||||||
|
|
||||||
for _, group := range compileConfig.Groups {
|
for _, group := range compileConfig.Groups {
|
||||||
err = group.Compile(outputDir, cc, linkerName, exportCCFlags, exportLDFlags)
|
err = group.Compile(outputDir, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -606,6 +605,8 @@ func useTarget(targetName string) (export Export, err error) {
|
|||||||
}
|
}
|
||||||
ldflags = append(ldflags, "-L", env.LLGoROOT()) // search targets/*.ld
|
ldflags = append(ldflags, "-L", env.LLGoROOT()) // search targets/*.ld
|
||||||
|
|
||||||
|
var libcIncludeDir []string
|
||||||
|
|
||||||
if config.Libc != "" {
|
if config.Libc != "" {
|
||||||
var libcLDFlags []string
|
var libcLDFlags []string
|
||||||
var compileConfig *compile.CompileConfig
|
var compileConfig *compile.CompileConfig
|
||||||
@@ -616,12 +617,19 @@ func useTarget(targetName string) (export Export, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
libcLDFlags, err = getOrCompileWithConfig(compileConfig, outputDir, export.CC, export.Linker, ccflags, ldflags)
|
libcLDFlags, err = getOrCompileWithConfig(compileConfig, outputDir, compile.CompileOptions{
|
||||||
|
CC: export.CC,
|
||||||
|
Linker: export.Linker,
|
||||||
|
CCFLAGS: ccflags,
|
||||||
|
LDFLAGS: ldflags,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
cflags = append(cflags, compileConfig.LibcCFlags...)
|
||||||
ldflags = append(ldflags, libcLDFlags...)
|
ldflags = append(ldflags, libcLDFlags...)
|
||||||
|
|
||||||
|
libcIncludeDir = compileConfig.LibcCFlags
|
||||||
export.Libc = config.Libc
|
export.Libc = config.Libc
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,7 +643,13 @@ func useTarget(targetName string) (export Export, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rtLibLDFlags, err = getOrCompileWithConfig(compileConfig, outputDir, export.CC, export.Linker, ccflags, ldflags)
|
rtLibLDFlags, err = getOrCompileWithConfig(compileConfig, outputDir, compile.CompileOptions{
|
||||||
|
CC: export.CC,
|
||||||
|
Linker: export.Linker,
|
||||||
|
CCFLAGS: ccflags,
|
||||||
|
LDFLAGS: ldflags,
|
||||||
|
CFLAGS: libcIncludeDir,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -654,7 +668,7 @@ func useTarget(targetName string) (export Export, err error) {
|
|||||||
// Use extends the original Use function to support target-based configuration
|
// Use extends the original Use function to support target-based configuration
|
||||||
// If targetName is provided, it takes precedence over goos/goarch
|
// If targetName is provided, it takes precedence over goos/goarch
|
||||||
func Use(goos, goarch string, wasiThreads bool, targetName string) (export Export, err error) {
|
func Use(goos, goarch string, wasiThreads bool, targetName string) (export Export, err error) {
|
||||||
if targetName != "" {
|
if targetName != "" && !strings.HasPrefix(targetName, "wasm") && !strings.HasPrefix(targetName, "wasi") {
|
||||||
return useTarget(targetName)
|
return useTarget(targetName)
|
||||||
}
|
}
|
||||||
return use(goos, goarch, wasiThreads)
|
return use(goos, goarch, wasiThreads)
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ func TestDownloadAndExtractArchiveUnsupportedFormat(t *testing.T) {
|
|||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
destDir := filepath.Join(tempDir, "extracted")
|
destDir := filepath.Join(tempDir, "extracted")
|
||||||
|
|
||||||
err := downloadAndExtractArchive(server.URL+"/test.zip", destDir, "Test Archive")
|
err := downloadAndExtractArchive(server.URL+"/test.7z", destDir, "Test Archive")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("Expected error for unsupported format, got nil")
|
t.Error("Expected error for unsupported format, got nil")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user