fix: symbol not found when building in baremental environment

This commit is contained in:
Haolan
2025-09-05 16:27:38 +08:00
parent 6588f36123
commit 2d1120bf69
15 changed files with 143 additions and 34 deletions

View File

@@ -0,0 +1,6 @@
//go:build baremental
package runtime
// Rethrow rethrows a panic.
func Rethrow(link *Defer) {}

View File

@@ -0,0 +1,29 @@
//go:build !baremental
package runtime
import (
c "github.com/goplus/llgo/runtime/internal/clite"
"github.com/goplus/llgo/runtime/internal/clite/debug"
"github.com/goplus/llgo/runtime/internal/clite/pthread"
)
// Rethrow rethrows a panic.
func Rethrow(link *Defer) {
if ptr := excepKey.Get(); ptr != nil {
if link == nil {
TracePanic(*(*any)(ptr))
debug.PrintStack(2)
c.Free(ptr)
c.Exit(2)
} else {
c.Siglongjmp(link.Addr, 1)
}
} else if link == nil && goexitKey.Get() != nil {
if pthread.Equal(mainThread, pthread.Self()) != 0 {
fatal("no goroutines (main called runtime.Goexit) - deadlock!")
c.Exit(2)
}
pthread.Exit(nil)
}
}

View File

@@ -20,7 +20,6 @@ import (
"unsafe"
c "github.com/goplus/llgo/runtime/internal/clite"
"github.com/goplus/llgo/runtime/internal/clite/debug"
"github.com/goplus/llgo/runtime/internal/clite/pthread"
"github.com/goplus/llgo/runtime/internal/clite/setjmp"
)
@@ -57,26 +56,6 @@ func Panic(v any) {
Rethrow((*Defer)(c.GoDeferData()))
}
// Rethrow rethrows a panic.
func Rethrow(link *Defer) {
if ptr := excepKey.Get(); ptr != nil {
if link == nil {
TracePanic(*(*any)(ptr))
debug.PrintStack(2)
c.Free(ptr)
c.Exit(2)
} else {
c.Siglongjmp(link.Addr, 1)
}
} else if link == nil && goexitKey.Get() != nil {
if pthread.Equal(mainThread, pthread.Self()) != 0 {
fatal("no goroutines (main called runtime.Goexit) - deadlock!")
c.Exit(2)
}
pthread.Exit(nil)
}
}
var (
excepKey pthread.Key
goexitKey pthread.Key