Skip to content

Commit

Permalink
Merge pull request goplus#597 from aofei/build
Browse files Browse the repository at this point in the history
build: fix `sigsetjmp` issues and ensure required libs on Linux
  • Loading branch information
xushiwei authored Jul 29, 2024
2 parents eab26de + e7d72b6 commit 23bfaf1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
3 changes: 0 additions & 3 deletions c/setjmp/setjmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ func Longjmp(env *JmpBuf, val c.Int)

// -----------------------------------------------------------------------------

//go:linkname Sigsetjmp C.sigsetjmp
func Sigsetjmp(env *SigjmpBuf, savemask c.Int) c.Int

//go:linkname Siglongjmp C.siglongjmp
func Siglongjmp(env *SigjmpBuf, val c.Int)

Expand Down
12 changes: 12 additions & 0 deletions c/setjmp/setjmp_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build linux

package setjmp

import (
_ "unsafe"

"github.com/goplus/llgo/c"
)

//go:linkname Sigsetjmp C.__sigsetjmp
func Sigsetjmp(env *SigjmpBuf, savemask c.Int) c.Int
12 changes: 12 additions & 0 deletions c/setjmp/setjmp_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build !linux

package setjmp

import (
_ "unsafe"

"github.com/goplus/llgo/c"
)

//go:linkname Sigsetjmp C.sigsetjmp
func Sigsetjmp(env *SigjmpBuf, savemask c.Int) c.Int
2 changes: 2 additions & 0 deletions internal/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ func linkMainPkg(ctx *context, pkg *packages.Package, pkgs []*aPackage, llFiles
"-rpath", "$ORIGIN",
"-rpath", "$ORIGIN/../lib",
"-Xlinker", "--gc-sections",
"-lm",
"-latomic",
"-lpthread", // libpthread is built-in since glibc 2.34 (2021-08-01); we need to support earlier versions.
)
}
Expand Down

0 comments on commit 23bfaf1

Please sign in to comment.