thoas / picfit

An image resizing server written in Go
http://bit.ly/1E7rSoi
MIT License
2.14k stars 177 forks source link

Compile failed with gollvm #143

Closed JX-Zhang98 closed 3 years ago

JX-Zhang98 commented 3 years ago

I attemped to compile this project with gollvm, but it failed with error:

build details Output
# github.com/thoas/picfit/cmd/picfit
src/libavcodec/aacdec_template.c:1143: error: undefined reference to 'pthread_once'
src/libavcodec/h264dec.c:400: error: undefined reference to 'pthread_once'
src/libavcodec/pthread_frame.c:675: error: undefined reference to 'pthread_join'
src/libavcodec/pthread_slice.c:116: error: undefined reference to 'pthread_join'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(system.cpp.o):system.cpp:function cv::Mutex::Mutex(): error: undefined reference to 'pthread_mutexattr_init'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(system.cpp.o):system.cpp:function cv::Mutex::Mutex(): error: undefined reference to 'pthread_mutexattr_settype'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(system.cpp.o):system.cpp:function cv::Mutex::Mutex(): error: undefined reference to 'pthread_mutexattr_destroy'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(system.cpp.o):system.cpp:function cv::Mutex::trylock(): error: undefined reference to 'pthread_mutex_trylock'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(system.cpp.o):system.cpp:function cv::TlsAbstraction::TlsAbstraction(): error: undefined reference to 'pthread_key_create'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(system.cpp.o):system.cpp:function cv::TlsAbstraction::~TlsAbstraction(): error: undefined reference to 'pthread_key_delete'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(system.cpp.o):system.cpp:function cv::TlsAbstraction::GetData() const: error: undefined reference to 'pthread_getspecific'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(system.cpp.o):system.cpp:function cv::TlsAbstraction::SetData(void*): error: undefined reference to 'pthread_setspecific'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(system.cpp.o):system.cpp:function cv::TlsStorage::TlsStorage(): error: undefined reference to 'pthread_key_create'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(system.cpp.o):system.cpp:function cv::TLSDataContainer::TLSDataContainer(): error: undefined reference to 'pthread_key_create'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(system.cpp.o):system.cpp:function cv::TLSDataContainer::release(): error: undefined reference to 'pthread_key_create'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(system.cpp.o):system.cpp:function cv::TLSDataContainer::getData() const: error: undefined reference to 'pthread_getspecific'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(system.cpp.o):system.cpp:function cv::TLSDataContainer::getData() const: error: undefined reference to 'pthread_getspecific'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(system.cpp.o):system.cpp:function cv::TLSDataContainer::getData() const: error: undefined reference to 'pthread_setspecific'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(parallel_pthreads.cpp.o):parallel_pthreads.cpp:function cv::ForThread::~ForThread(): error: undefined reference to 'pthread_join'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(parallel_pthreads.cpp.o):parallel_pthreads.cpp:function cv::ForThread::stop(): error: undefined reference to 'pthread_join'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(parallel_pthreads.cpp.o):parallel_pthreads.cpp:function cv::ThreadManager::ThreadManager(): error: undefined reference to 'pthread_mutexattr_init'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(parallel_pthreads.cpp.o):parallel_pthreads.cpp:function cv::ThreadManager::ThreadManager(): error: undefined reference to 'pthread_mutexattr_settype'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(parallel_pthreads.cpp.o):parallel_pthreads.cpp:function cv::ThreadManager::ThreadManager(): error: undefined reference to 'pthread_mutexattr_destroy'
/home/jx/workspace/batch_compile/awesome-go/picfit/vendor/github.com/discordapp/lilliput/deps/linux/lib/libopencv_core.a(parallel_pthreads.cpp.o):parallel_pthreads.cpp:function cv::ThreadManager::run(cv::Range const&, cv::ParallelLoopBody const&, double): error: undefined reference to 'pthread_mutex_trylock'
/usr/lib/gcc/x86_64-linux-gnu/8/libgcc.a(generic-morestack-thread.o):function stack_split_initialize_thread: error: undefined reference to 'pthread_setspecific'
/usr/lib/gcc/x86_64-linux-gnu/8/libgcc.a(generic-morestack-thread.o):function __wrap_pthread_create: error: undefined reference to 'pthread_once'

I'm not sure whether it is a bug for picfit because I failed to locate whrere src/libavcodec/ is It seems have some problem with pthread lib.

JX-Zhang98 commented 3 years ago
Go version info Output
go version go1.16 gollvm LLVM 13.0.0git linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN="/home/jx/workspace/gowork/bin"
GOCACHE="/home/jx/.cache/go-build"
GOENV="/home/jx/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/jx/workspace/gowork/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jx/workspace/gowork"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/home/jx/.local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/jx/.local/gollvm/tools"
GOVCS=""
GOVERSION="go1.16 gollvm LLVM 13.0.0git"
GCCGO="/home/jx/.local/gollvm/bin/llvm-goc"
AR="ar"
CC="/home/jx/workspace/llvm_area/llvm-project/build/bin/clang"
CXX="/home/jx/workspace/llvm_area/llvm-project/build/bin/clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build1322534458=/tmp/go-build -gno-record-gcc-switches -funwind-tables"

thoas commented 3 years ago

picfit does not support gollvm, if you want to add the support feel free to open a PR.