From 71b34003ca66e57bb8bb78a94686254679d2745c Mon Sep 17 00:00:00 2001 From: Li Jie Date: Wed, 19 Mar 2025 14:31:41 +0800 Subject: [PATCH 1/3] debug: rollback unwind to don't depends llvm runtime, solve libunwind linking on homebrew linux in llgo formal --- c/debug/debug.go | 4 ++-- runtime/internal/clite/debug/debug.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/c/debug/debug.go b/c/debug/debug.go index 76260b0d..16e00eea 100644 --- a/c/debug/debug.go +++ b/c/debug/debug.go @@ -11,8 +11,8 @@ import ( ) const ( - LLGoPackage = "link: $(llvm-config --ldflags --libs); -lunwind" - LLGoFiles = "$(llvm-config --cflags): _wrap/debug.c" + LLGoPackage = "link" + LLGoFiles = "_wrap/debug.c" ) type Info struct { diff --git a/runtime/internal/clite/debug/debug.go b/runtime/internal/clite/debug/debug.go index 48a27649..10e3a41e 100644 --- a/runtime/internal/clite/debug/debug.go +++ b/runtime/internal/clite/debug/debug.go @@ -11,8 +11,8 @@ import ( ) const ( - LLGoPackage = "link: $(llvm-config --ldflags --libs); -lunwind" - LLGoFiles = "$(llvm-config --cflags): _wrap/debug.c" + LLGoPackage = "link" + LLGoFiles = "_wrap/debug.c" ) type Info struct { From 0e7157626541f58d6ef188b28e1d43c3f2872a01 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Thu, 20 Mar 2025 11:17:27 +0800 Subject: [PATCH 2/3] build: pass CFLAGS and LDFLAGS to clang --- compiler/internal/build/build.go | 4 ++-- xtool/clang/clang.go | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/compiler/internal/build/build.go b/compiler/internal/build/build.go index eda0d286..5b5f5a1f 100644 --- a/compiler/internal/build/build.go +++ b/compiler/internal/build/build.go @@ -488,7 +488,7 @@ func linkMainPkg(ctx *context, pkg *packages.Package, pkgs []*aPackage, linkArgs if verbose { fmt.Fprintln(os.Stderr, "clang", args) } - err = ctx.env.Clang().Exec(args...) + err = ctx.env.Clang().Link(args...) check(err) if IsRpathChangeEnabled() && runtime.GOOS == "darwin" { @@ -870,7 +870,7 @@ func clFile(ctx *context, args []string, cFile, expFile string, procFile func(li if verbose { fmt.Fprintln(os.Stderr, "clang", args) } - err := ctx.env.Clang().Exec(args...) + err := ctx.env.Clang().Compile(args...) check(err) procFile(llFile) } diff --git a/xtool/clang/clang.go b/xtool/clang/clang.go index cda12809..657883df 100644 --- a/xtool/clang/clang.go +++ b/xtool/clang/clang.go @@ -20,6 +20,7 @@ import ( "io" "os" "os/exec" + "strings" ) // ----------------------------------------------------------------------------- @@ -40,6 +41,32 @@ func New(app string) *Cmd { return &Cmd{app, os.Stdout, os.Stderr} } +func (p *Cmd) Compile(args ...string) error { + // Parse CFLAGS environment variable into separate arguments + cflags := strings.Fields(os.Getenv("CFLAGS")) + if len(cflags) > 0 { + // Create a new slice with capacity for all arguments + newArgs := make([]string, 0, len(cflags)+len(args)) + newArgs = append(newArgs, cflags...) + newArgs = append(newArgs, args...) + args = newArgs + } + return p.Exec(args...) +} + +func (p *Cmd) Link(args ...string) error { + // Parse LDFLAGS environment variable into separate arguments + ldflags := strings.Fields(os.Getenv("LDFLAGS")) + if len(ldflags) > 0 { + // Create a new slice with capacity for all arguments + newArgs := make([]string, 0, len(ldflags)+len(args)) + newArgs = append(newArgs, ldflags...) + newArgs = append(newArgs, args...) + args = newArgs + } + return p.Exec(args...) +} + // Exec executes a clang command. func (p *Cmd) Exec(args ...string) error { cmd := exec.Command(p.app, args...) From 8c76436d8194b6921c06dbafce8388c6bccd4083 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Thu, 20 Mar 2025 12:40:37 +0800 Subject: [PATCH 3/3] ci: limit concurrency of doc links checker --- .github/workflows/doc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 39465e00..de44047f 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -27,7 +27,7 @@ jobs: id: lychee uses: lycheeverse/lychee-action@v2 with: - args: README.md + args: --max-concurrency 3 --retry-wait-time 15 README.md remote_install: strategy: