Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gollvm: can't find some C std pthread_xxx functions #45424

@JX-Zhang98

Description

@JX-Zhang98

What version of Go are you using (go version)?

$ go version
go version go1.16 gollvm LLVM 13.0.0git linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="off"
GOARCH="amd64"
GOBIN="/home/jxzhang/workspace/gowork/bin"
GOCACHE="/home/jxzhang/.cache/go-build"
GOENV="/home/jxzhang/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/jxzhang/workspace/gowork/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jxzhang/workspace/gowork"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/home/jxzhang/.local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/jxzhang/.local/gollvm/tools"
GOVCS=""
GOVERSION="go1.16 gollvm LLVM 13.0.0git"
GCCGO="/home/jxzhang/.local/gollvm/bin/llvm-goc"
AR="ar"
CC="/home/jxzhang/workspace/llvm_area/llvm-project/build/bin/clang"
CXX="/home/jxzhang/workspace/llvm_area/llvm-project/build/bin/clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4207555597=/tmp/go-build -gno-record-gcc-switches -funwind-tables"

What did you do?

I wrote a cgo demo which call pthread std functions and tried to compile it with gollvm
Here is a link on play.golang- https://play.golang.org/p/PiaY0AIGprl
Though the code can't run on play.golang for some reason...

What did you expect to see?

Compile succeed with gollvm

What did you see instead?

An error caused by an undefined reference occured

ccode.c:11: error: undefined reference to 'pthread_join'

In addition to this function, there are some other functions that also have this error:
pthread_once, pthread_mutexattr_init, pthread_mutexattr_settype, pthread_key_create, pthread_getspecific, pthread_mutexattr_destroy ...

Some extra observations

These functions above seems different between pthread_create which can be referenced normally

jx $  nm /home/jx/.local/gollvm/lib64/libgo.so.13git | grep pthread_create           
00000000010831e0 t __wrap_pthread_create
                 w pthread_create
jx $ nm /home/jx/.local/gollvm/lib64/libgo.so.13git | grep pthread_join
jx $ nm /home/jx/.local/gollvm/lib64/libgo.so.13git | grep pthread_once  
                 w pthread_once

Metadata

Metadata

Assignees

Labels

NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions