Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: cannot build with -buildmode=shared -linkshared -race #19290

Closed
WGH- opened this issue Feb 25, 2017 · 5 comments

Comments

Projects
None yet
4 participants
@WGH-
Copy link

commented Feb 25, 2017

Please answer these questions before submitting your issue. Thanks!

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

Tried two versions:
go version go1.8 linux/amd64
go version go1.7.5 linux/amd64

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

Correspondingly,

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/wgh/go"
GORACE=""
GOROOT="/tmp/go"
GOTOOLDIR="/tmp/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build648294653=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/wgh/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
CC="x86_64-pc-linux-gnu-gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build130055262=/tmp/go-build -gno-record-gcc-switches"
CXX="x86_64-pc-linux-gnu-g++"
CGO_ENABLED="1"

What did you do?

$ GOROOT=$PWD ./bin/go install -buildmode=shared -linkshared -race -a -pkgdir /tmp/foo2 std 
go install -buildmode=shared -linkshared -race -a -pkgdir /tmp/lol  std

What did you expect to see?

$ echo $?
0

What did you see instead?

$ GOROOT=$PWD ./bin/go install -buildmode=shared -linkshared -race -a -pkgdir /tmp/foo2 std 
# /tmp/go-build147169751/libstd.so
runtime.RaceSemacquire·f: missing section for relocation target runtime.RaceSemacquire
runtime.RaceSemrelease·f: missing section for relocation target runtime.RaceSemrelease
runtime.RaceSemacquire·f: reloc 1 to non-elf symbol runtime.RaceSemacquire (outer=runtime.RaceSemacquire) 0
runtime.RaceSemrelease·f: reloc 1 to non-elf symbol runtime.RaceSemrelease (outer=runtime.RaceSemrelease) 0
runtime.RaceSemacquire·f: undefined: "runtime.RaceSemacquire"
runtime.RaceSemrelease·f: undefined: "runtime.RaceSemrelease"
$ go install -buildmode=shared -linkshared -race -a -pkgdir /tmp/lol  std
# /tmp/go-build962711117/libstd.so
runtime.RaceSemacquire·f: runtime.RaceSemacquire: not defined
runtime.RaceSemrelease·f: runtime.RaceSemrelease: not defined
runtime.RaceSemacquire·f: undefined: runtime.RaceSemacquire
runtime.RaceSemrelease·f: undefined: runtime.RaceSemrelease

@quentinmit quentinmit changed the title Unable to build shared std libraries with -race runtime: cannot build with -buildmode=shared -linkshared -race Feb 27, 2017

@quentinmit quentinmit added the NeedsFix label Feb 27, 2017

@quentinmit quentinmit added this to the Go1.9Maybe milestone Feb 27, 2017

@quentinmit

This comment has been minimized.

Copy link
Contributor

commented Feb 27, 2017

I'm not sure -race is expected to work with -buildmode=shared for any package.

/cc @aclements @dvyukov

@dvyukov

This comment has been minimized.

Copy link
Member

commented Feb 27, 2017

I don't think that we ever tested this. Race detector was implemented before shared support.
I don't know how shared works. But I would expect it should be reasonably easily fixable, because all the symbols must be there if everything is built with -race. Maybe we need to add some -u symbol flags to the linker...
@ianlancetaylor

@dvyukov

This comment has been minimized.

Copy link
Member

commented Feb 27, 2017

Running with -x:

$ go install -buildmode=shared -linkshared -race -pkgdir /tmp/foo -v -x std 
WORK=/tmp/go-build200871863
cd .
go/pkg/tool/linux_amd64/link -o $WORK/libstd.so -L $WORK -L /tmp/foo -installsuffix race_dynlink -buildmode=shared -race -linkshared -w -extld=gcc archive/tar=/tmp/foo/archive/tar.a archive/zip=/tmp/foo/archive/zip.a bufio=/tmp/foo/bufio.a bytes=/tmp/foo/bytes.a compress/bzip2=/tmp/foo/compress/bzip2.a compress/flate=/tmp/foo/compress/flate.a compress/gzip=/tmp/foo/compress/gzip.a compress/lzw=/tmp/foo/compress/lzw.a compress/zlib=/tmp/foo/compress/zlib.a container/heap=/tmp/foo/container/heap.a container/list=/tmp/foo/container/list.a container/ring=/tmp/foo/container/ring.a context=/tmp/foo/context.a crypto=/tmp/foo/crypto.a crypto/aes=/tmp/foo/crypto/aes.a crypto/cipher=/tmp/foo/crypto/cipher.a crypto/des=/tmp/foo/crypto/des.a crypto/dsa=/tmp/foo/crypto/dsa.a crypto/ecdsa=/tmp/foo/crypto/ecdsa.a crypto/elliptic=/tmp/foo/crypto/elliptic.a crypto/hmac=/tmp/foo/crypto/hmac.a crypto/internal/cipherhw=/tmp/foo/crypto/internal/cipherhw.a crypto/md5=/tmp/foo/crypto/md5.a crypto/rand=/tmp/foo/crypto/rand.a crypto/rc4=/tmp/foo/crypto/rc4.a crypto/rsa=/tmp/foo/crypto/rsa.a crypto/sha1=/tmp/foo/crypto/sha1.a crypto/sha256=/tmp/foo/crypto/sha256.a crypto/sha512=/tmp/foo/crypto/sha512.a crypto/subtle=/tmp/foo/crypto/subtle.a crypto/tls=/tmp/foo/crypto/tls.a crypto/x509=/tmp/foo/crypto/x509.a crypto/x509/pkix=/tmp/foo/crypto/x509/pkix.a database/sql=/tmp/foo/database/sql.a database/sql/driver=/tmp/foo/database/sql/driver.a debug/dwarf=/tmp/foo/debug/dwarf.a debug/elf=/tmp/foo/debug/elf.a debug/gosym=/tmp/foo/debug/gosym.a debug/macho=/tmp/foo/debug/macho.a debug/pe=/tmp/foo/debug/pe.a debug/plan9obj=/tmp/foo/debug/plan9obj.a encoding=/tmp/foo/encoding.a encoding/ascii85=/tmp/foo/encoding/ascii85.a encoding/asn1=/tmp/foo/encoding/asn1.a encoding/base32=/tmp/foo/encoding/base32.a encoding/base64=/tmp/foo/encoding/base64.a encoding/binary=/tmp/foo/encoding/binary.a encoding/csv=/tmp/foo/encoding/csv.a encoding/gob=/tmp/foo/encoding/gob.a encoding/hex=/tmp/foo/encoding/hex.a encoding/json=/tmp/foo/encoding/json.a encoding/pem=/tmp/foo/encoding/pem.a encoding/xml=/tmp/foo/encoding/xml.a errors=/tmp/foo/errors.a expvar=/tmp/foo/expvar.a flag=/tmp/foo/flag.a fmt=/tmp/foo/fmt.a go/ast=/tmp/foo/go/ast.a go/build=/tmp/foo/go/build.a go/constant=/tmp/foo/go/constant.a go/doc=/tmp/foo/go/doc.a go/format=/tmp/foo/go/format.a go/importer=/tmp/foo/go/importer.a go/internal/gccgoimporter=/tmp/foo/go/internal/gccgoimporter.a go/internal/gcimporter=/tmp/foo/go/internal/gcimporter.a go/parser=/tmp/foo/go/parser.a go/printer=/tmp/foo/go/printer.a go/scanner=/tmp/foo/go/scanner.a go/token=/tmp/foo/go/token.a go/types=/tmp/foo/go/types.a hash=/tmp/foo/hash.a hash/adler32=/tmp/foo/hash/adler32.a hash/crc32=/tmp/foo/hash/crc32.a hash/crc64=/tmp/foo/hash/crc64.a hash/fnv=/tmp/foo/hash/fnv.a html=/tmp/foo/html.a html/template=/tmp/foo/html/template.a image=/tmp/foo/image.a image/color=/tmp/foo/image/color.a image/color/palette=/tmp/foo/image/color/palette.a image/draw=/tmp/foo/image/draw.a image/gif=/tmp/foo/image/gif.a image/internal/imageutil=/tmp/foo/image/internal/imageutil.a image/jpeg=/tmp/foo/image/jpeg.a image/png=/tmp/foo/image/png.a index/suffixarray=/tmp/foo/index/suffixarray.a internal/nettrace=/tmp/foo/internal/nettrace.a internal/poll=/tmp/foo/internal/poll.a internal/race=/tmp/foo/internal/race.a internal/singleflight=/tmp/foo/internal/singleflight.a internal/syscall/unix=/tmp/foo/internal/syscall/unix.a internal/syscall/windows=/tmp/foo/internal/syscall/windows.a internal/syscall/windows/registry=/tmp/foo/internal/syscall/windows/registry.a internal/syscall/windows/sysdll=/tmp/foo/internal/syscall/windows/sysdll.a internal/testenv=/tmp/foo/internal/testenv.a internal/trace=/tmp/foo/internal/trace.a io=/tmp/foo/io.a io/ioutil=/tmp/foo/io/ioutil.a log=/tmp/foo/log.a log/syslog=/tmp/foo/log/syslog.a math=/tmp/foo/math.a math/big=/tmp/foo/math/big.a math/bits=/tmp/foo/math/bits.a math/cmplx=/tmp/foo/math/cmplx.a math/rand=/tmp/foo/math/rand.a mime=/tmp/foo/mime.a mime/multipart=/tmp/foo/mime/multipart.a mime/quotedprintable=/tmp/foo/mime/quotedprintable.a net=/tmp/foo/net.a net/http=/tmp/foo/net/http.a net/http/cgi=/tmp/foo/net/http/cgi.a net/http/cookiejar=/tmp/foo/net/http/cookiejar.a net/http/fcgi=/tmp/foo/net/http/fcgi.a net/http/httptest=/tmp/foo/net/http/httptest.a net/http/httptrace=/tmp/foo/net/http/httptrace.a net/http/httputil=/tmp/foo/net/http/httputil.a net/http/internal=/tmp/foo/net/http/internal.a net/http/pprof=/tmp/foo/net/http/pprof.a net/internal/socktest=/tmp/foo/net/internal/socktest.a net/mail=/tmp/foo/net/mail.a net/rpc=/tmp/foo/net/rpc.a net/rpc/jsonrpc=/tmp/foo/net/rpc/jsonrpc.a net/smtp=/tmp/foo/net/smtp.a net/textproto=/tmp/foo/net/textproto.a net/url=/tmp/foo/net/url.a os=/tmp/foo/os.a os/exec=/tmp/foo/os/exec.a os/signal=/tmp/foo/os/signal.a os/user=/tmp/foo/os/user.a path=/tmp/foo/path.a path/filepath=/tmp/foo/path/filepath.a plugin=/tmp/foo/plugin.a reflect=/tmp/foo/reflect.a regexp=/tmp/foo/regexp.a regexp/syntax=/tmp/foo/regexp/syntax.a runtime=/tmp/foo/runtime.a runtime/cgo=/tmp/foo/runtime/cgo.a runtime/debug=/tmp/foo/runtime/debug.a runtime/internal/atomic=/tmp/foo/runtime/internal/atomic.a runtime/internal/sys=/tmp/foo/runtime/internal/sys.a runtime/pprof=/tmp/foo/runtime/pprof.a runtime/pprof/internal/profile=/tmp/foo/runtime/pprof/internal/profile.a runtime/race=/tmp/foo/runtime/race.a runtime/trace=/tmp/foo/runtime/trace.a sort=/tmp/foo/sort.a strconv=/tmp/foo/strconv.a strings=/tmp/foo/strings.a sync=/tmp/foo/sync.a sync/atomic=/tmp/foo/sync/atomic.a syscall=/tmp/foo/syscall.a testing=/tmp/foo/testing.a testing/internal/testdeps=/tmp/foo/testing/internal/testdeps.a testing/iotest=/tmp/foo/testing/iotest.a testing/quick=/tmp/foo/testing/quick.a text/scanner=/tmp/foo/text/scanner.a text/tabwriter=/tmp/foo/text/tabwriter.a text/template=/tmp/foo/text/template.a text/template/parse=/tmp/foo/text/template/parse.a time=/tmp/foo/time.a unicode=/tmp/foo/unicode.a unicode/utf16=/tmp/foo/unicode/utf16.a unicode/utf8=/tmp/foo/unicode/utf8.a vendor/golang_org/x/crypto/chacha20poly1305=/tmp/foo/vendor/golang_org/x/crypto/chacha20poly1305.a vendor/golang_org/x/crypto/chacha20poly1305/internal/chacha20=/tmp/foo/vendor/golang_org/x/crypto/chacha20poly1305/internal/chacha20.a vendor/golang_org/x/crypto/curve25519=/tmp/foo/vendor/golang_org/x/crypto/curve25519.a vendor/golang_org/x/crypto/poly1305=/tmp/foo/vendor/golang_org/x/crypto/poly1305.a vendor/golang_org/x/net/http2/hpack=/tmp/foo/vendor/golang_org/x/net/http2/hpack.a vendor/golang_org/x/net/idna=/tmp/foo/vendor/golang_org/x/net/idna.a vendor/golang_org/x/net/lex/httplex=/tmp/foo/vendor/golang_org/x/net/lex/httplex.a vendor/golang_org/x/text/transform=/tmp/foo/vendor/golang_org/x/text/transform.a vendor/golang_org/x/text/unicode/norm=/tmp/foo/vendor/golang_org/x/text/unicode/norm.a vendor/golang_org/x/text/width=/tmp/foo/vendor/golang_org/x/text/width.a
# /tmp/go-build200871863/libstd.so
runtime.RaceSemacquire·f: missing section for relocation target runtime.RaceSemacquire
runtime.RaceSemrelease·f: missing section for relocation target runtime.RaceSemrelease
runtime.RaceSemacquire·f: reloc 1 to non-elf symbol runtime.RaceSemacquire (outer=runtime.RaceSemacquire) 0
runtime.RaceSemrelease·f: reloc 1 to non-elf symbol runtime.RaceSemrelease (outer=runtime.RaceSemrelease) 0
runtime.RaceSemacquire·f: undefined: "runtime.RaceSemacquire"
runtime.RaceSemrelease·f: undefined: "runtime.RaceSemrelease"
$ go tool nm /tmp/foo/runtime.a | grep RaceSemacquire
         U %22%22.RaceSemacquire
   fbafd R %22%22.RaceSemacquire.args_stackmap
  10c1fb R %22%22.RaceSemacquire·f
@dvyukov

This comment has been minimized.

Copy link
Member

commented Feb 27, 2017

@gopherbot

This comment has been minimized.

Copy link

commented Feb 27, 2017

CL https://golang.org/cl/37448 mentions this issue.

@gopherbot gopherbot closed this in ba6e577 Feb 27, 2017

@golang golang locked and limited conversation to collaborators Feb 27, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.