From f36098d704199dcb9a9a5e3a41d3393ee4f543f7 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 11 Jun 2025 19:43:38 +0800 Subject: [PATCH] internal:link by LLGoFile to find libunwind --- internal/crosscompile/cosscompile.go | 6 ------ runtime/internal/clite/debug/debug.go | 2 +- runtime/internal/clite/os/os_other.go | 2 +- xtool/env/llvm/llvm.go | 10 +--------- 4 files changed, 3 insertions(+), 17 deletions(-) diff --git a/internal/crosscompile/cosscompile.go b/internal/crosscompile/cosscompile.go index cc4b15c6..8865aba6 100644 --- a/internal/crosscompile/cosscompile.go +++ b/internal/crosscompile/cosscompile.go @@ -6,11 +6,9 @@ import ( "os" "path/filepath" "runtime" - "strings" "github.com/goplus/llgo/internal/env" "github.com/goplus/llgo/internal/xtool/llvm" - envllvm "github.com/goplus/llgo/xtool/env/llvm" ) type Export struct { @@ -68,10 +66,6 @@ func Use(goos, goarch string, wasiThreads, changeRpath bool) (export Export, err "-latomic", "-lpthread", // libpthread is built-in since glibc 2.34 (2021-08-01); we need to support earlier versions. ) - llvmEnv := envllvm.New("") - if cflags := llvmEnv.Cflags(); cflags != "" { - export.CFLAGS = append(export.CFLAGS, strings.Fields(cflags)...) - } } return } diff --git a/runtime/internal/clite/debug/debug.go b/runtime/internal/clite/debug/debug.go index 2a02b718..5aa793f2 100644 --- a/runtime/internal/clite/debug/debug.go +++ b/runtime/internal/clite/debug/debug.go @@ -9,7 +9,7 @@ import ( ) const ( - LLGoFiles = "_wrap/debug.cpp" + LLGoFiles = "$(llvm-config --cflags): _wrap/debug.cpp" ) type Info struct { diff --git a/runtime/internal/clite/os/os_other.go b/runtime/internal/clite/os/os_other.go index 55bf6132..e07e04a6 100644 --- a/runtime/internal/clite/os/os_other.go +++ b/runtime/internal/clite/os/os_other.go @@ -25,7 +25,7 @@ import ( ) const ( - LLGoFiles = "_os/os.c" + LLGoFiles = "_os/os.cpp" LLGoPackage = "link" ) diff --git a/xtool/env/llvm/llvm.go b/xtool/env/llvm/llvm.go index e1a18abd..a34757c9 100644 --- a/xtool/env/llvm/llvm.go +++ b/xtool/env/llvm/llvm.go @@ -50,7 +50,6 @@ func defaultLLVMConfigBin() string { // Env represents an LLVM installation. type Env struct { binDir string - cflags string } // New creates a new [Env] instance. @@ -63,12 +62,7 @@ func New(llvmConfigBin string) *Env { // executables are assumed to be in PATH. binDir, _ := exec.Command(llvmConfigBin, "--bindir").Output() - cflags, _ := exec.Command(llvmConfigBin, "--cflags").Output() - - e := &Env{ - binDir: strings.TrimSpace(string(binDir)), - cflags: strings.TrimSpace(string(cflags)), - } + e := &Env{binDir: strings.TrimSpace(string(binDir))} return e } @@ -76,8 +70,6 @@ func New(llvmConfigBin string) *Env { // means LLVM executables are assumed to be in PATH. func (e *Env) BinDir() string { return e.binDir } -func (e *Env) Cflags() string { return e.cflags } - // Clang returns a new [clang.Cmd] instance. func (e *Env) Clang() *clang.Cmd { bin := filepath.Join(e.BinDir(), "clang++")