Closed LasseChi closed 3 years ago
What's your go version? And could you please show your go env
output?
I think that it's not related to mindoc itself. Maybe https://github.com/golang/go/issues/31293 could help you. Hopefully, you cound update your go version/ glibc version and try again.
note https://github.com/golang/go/issues/31336 linked to above issues, it seems quite similar to the situation you've occured.
我的go版本是1.16.3,env 如下:
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/lasse/.cache/go-build"
GOENV="/home/lasse/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/lasse/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/lasse/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.3"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build470420323=/tmp/go-build -gno-record-gcc-switches"
GCC信息如下:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.8.5/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
gcc version 4.8.5 (GCC)
$ ld -v
GNU ld version 2.20.51.0.2-5.48.el6 20100205
It seems that you've actually met the same problem in https://github.com/golang/go/issues/31336. This is not problem about mindoc, even nothing about Go. It's mainly related to your C compiler toolchains. Because mindoc supports sqlite3 database, we requires CGO when compiling, so we need to compile some C codes. And when that has error, the build could failed.
The issue link I provided to you may help you to solve this problem. Note that I confidently believe that what you've met is actually the same with what described in that golang issue, even the CentOS version and ld version are the same. And I think that update glibc, gcc could solve your problem.
Here is my env, I met no problem when compiling:
~ ⌚ 21:20:27
$ glibc-version.sh
GNU libc version: 2.33
release: release
~ ⌚ 21:20:35
$ ldd --version
ldd (GNU libc) 2.33
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
~ ⌚ 21:21:13
$ ld -v
GNU ld (GNU Binutils) 2.36.1
~ ⌚ 21:22:18
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC)
Hope that this can help you. Issue keeps open
try to upgrade your glibc, you can download it from https://ftp.gnu.org/gnu/glibc/
CentOS 6.7 was released at 2015, Centos 6 was end of life at November 30, 2020. use new version of Centos(eg: 7,8) or other Linux distribution(eh: ubuntu) is recommend.
谢谢两位的解答,确实是应为gcc和glibc版本的问题,目前已经解决。
问题已经解决
谢谢两位的解答,确实是应为gcc和glibc版本的问题,目前已经解决。
我是这么解决的 yum install glibc-static-2.17-326.el7_9.x86_64 yum install binutils
请按照一下格式提交issue,谢谢!
你当前使用的是哪个版本的 MinDoc(
godoc_linux_amd64 version
)? 通过git 克隆最新的版本(4月7日克隆)你当前使用的是什么操作系统? CentOS 6.1 和 CentOS 6.7
你是如何操作的? 按照README.md中的安装步骤操作的,当执行go build -ldflags "-w"命令时报错了
你期望得到什么结果? 执行成功
当前遇到的是什么结果? 执行后出现如下报错:
/usr/bin/ld: Please report this bug.
collect2: error: ld returned 1 exit status