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

@@ -100,10 +100,17 @@ func withPlatformSpecifiedFiles(baseDir, target string, files []string) []string
return append(files, platformSpecifiedFiles(builtinsDir, target)...)
}
func GetCompilerRTConfig(baseDir, target string) *compile.CompileConfig {
return &compile.CompileConfig{
func GetCompilerRTConfig() compile.LibConfig {
return compile.LibConfig{
Name: "compiler-rt",
Url: "https://github.com/goplus/compiler-rt/archive/refs/tags/v0.1.0.tar.gz",
Version: "v0.1.0",
ArchiveSrcDir: "compiler-rt-0.1.0",
}
}
func GetCompilerRTCompileConfig(baseDir, target string) compile.CompileConfig {
return compile.CompileConfig{
Groups: []compile.CompileGroup{
{
OutputFileName: fmt.Sprintf("libclang_builtins-%s.a", target),
@@ -277,7 +284,8 @@ func GetCompilerRTConfig(baseDir, target string) *compile.CompileConfig {
"-Werror=return-stack-address",
"-Werror=sizeof-array-decay",
"-Werror=format-insufficient-args",
"-Wformat -std=c11",
"-Wformat",
"-std=c11",
"-fno-builtin",
"-fvisibility=hidden",
"-fomit-frame-pointer",

View File

@@ -60,7 +60,7 @@ func TestGetCompilerRTConfig(t *testing.T) {
baseDir := "/test/base"
target := "riscv32-unknown-elf"
config := GetCompilerRTConfig(baseDir, target)
config := GetCompilerRTCompileConfig(baseDir, target)
// Test groups configuration
if len(config.Groups) != 1 {
@@ -101,15 +101,8 @@ func TestGetCompilerRTConfig_DifferentTargets(t *testing.T) {
baseDir := "/test/base"
for _, target := range targets {
t.Run(target, func(t *testing.T) {
config := GetCompilerRTConfig(baseDir, target)
config := GetCompilerRTCompileConfig(baseDir, target)
// Basic validation
if config.Url == "" {
t.Error("URL should not be empty")
}
if config.ArchiveSrcDir == "" {
t.Error("ArchiveSrcDir should not be empty")
}
if len(config.Groups) == 0 {
t.Error("Should have at least one group")
}