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

race: building with -race fails with linker reference errors #57849

Closed
shoenig opened this issue Jan 17, 2023 · 6 comments
Closed

race: building with -race fails with linker reference errors #57849

shoenig opened this issue Jan 17, 2023 · 6 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@shoenig
Copy link
Contributor

shoenig commented Jan 17, 2023

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

➜ go version 
go version go1.20rc3 linux/amd64

Does this issue reproduce with the latest release?

Yes 1.20rc3

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

go env Output
➜ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/opt/bin"
GOCACHE="/home/shoenig/.cache/go-build"
GOENV="/home/shoenig/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/shoenig/.go/pkg/mod"
GONOPROXY="github.com/hashicorp"
GONOSUMDB="github.com/hashicorp"
GOOS="linux"
GOPATH="/home/shoenig/.go"
GOPRIVATE="github.com/hashicorp"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/google/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/google/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20rc3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3747904411=/tmp/go-build -gno-record-gcc-switches"

When compiling with -tags=race,ui compiler crashes with linker errors

➜ go install -tags=race,ui
# github.com/hashicorp/nomad
/opt/google/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.(*mspan).setUserArenaChunkToFault':
/opt/google/go/src/runtime/race.go:451: undefined reference to `__tsan_free'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.mallocgc':
/opt/google/go/src/runtime/race.go:446: undefined reference to `__tsan_malloc'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.runfinq':
/opt/google/go/src/runtime/race.go:575: undefined reference to `__tsan_finalizer_goroutine'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.(*sweepLocked).sweep':
/opt/google/go/src/runtime/race.go:451: undefined reference to `__tsan_free'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.goexit1':
/opt/google/go/src/runtime/proc.go:3618: undefined reference to `__tsan_go_end'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.gfget':
/opt/google/go/src/runtime/race.go:446: undefined reference to `__tsan_malloc'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.(*p).init':
/opt/google/go/src/runtime/race.go:424: undefined reference to `__tsan_proc_create'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.(*p).destroy':
/opt/google/go/src/runtime/proc.go:4925: undefined reference to `__tsan_go_end'
/usr/bin/ld: /opt/google/go/src/runtime/proc.go:4930: undefined reference to `__tsan_proc_destroy'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.RaceDisable':
/opt/google/go/src/runtime/race.go:72: undefined reference to `__tsan_go_ignore_sync_begin'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.RaceEnable':
/opt/google/go/src/runtime/race.go:84: undefined reference to `__tsan_go_ignore_sync_end'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.raceinit':
/opt/google/go/src/runtime/race.go:368: undefined reference to `__tsan_init'
/usr/bin/ld: /opt/google/go/src/runtime/race.go:397: undefined reference to `__tsan_map_shadow'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.racefini':
/opt/google/go/src/runtime/lockrank_off.go:22: undefined reference to `__tsan_fini'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.racemapshadow':
/opt/google/go/src/runtime/race.go:441: undefined reference to `__tsan_map_shadow'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.racegostart':
/opt/google/go/src/runtime/race.go:465: undefined reference to `__tsan_go_start'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.raceacquireg':
/opt/google/go/src/runtime/race.go:523: undefined reference to `__tsan_acquire'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.raceacquirectx':
/opt/google/go/src/runtime/race.go:531: undefined reference to `__tsan_acquire'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.racereleaseg':
/opt/google/go/src/runtime/race.go:544: undefined reference to `__tsan_release'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.racereleaseacquireg':
/opt/google/go/src/runtime/race.go:557: undefined reference to `__tsan_release_acquire'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.racereleasemergeg':
/opt/google/go/src/runtime/race.go:570: undefined reference to `__tsan_release_merge'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.stackalloc':
/opt/google/go/src/runtime/race.go:446: undefined reference to `__tsan_malloc'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `racefuncenter':
/opt/google/go/src/runtime/race_amd64.s:182: undefined reference to `__tsan_func_enter'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `racecallatomic':
/opt/google/go/src/runtime/race_amd64.s:359: undefined reference to `__tsan_go_ignore_sync_begin'
/usr/bin/ld: /opt/google/go/src/runtime/race_amd64.s:370: undefined reference to `__tsan_go_ignore_sync_end'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.raceread':
/opt/google/go/src/runtime/race_amd64.s:51: undefined reference to `__tsan_read'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.racereadpc.abi0':
/opt/google/go/src/runtime/race_amd64.s:66: undefined reference to `__tsan_read_pc'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.racewrite':
/opt/google/go/src/runtime/race_amd64.s:77: undefined reference to `__tsan_write'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.racewritepc.abi0':
/opt/google/go/src/runtime/race_amd64.s:92: undefined reference to `__tsan_write_pc'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.racereadrange':
/opt/google/go/src/runtime/race_amd64.s:104: undefined reference to `__tsan_read_range'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.racereadrangepc1.abi0':
/opt/google/go/src/runtime/race_amd64.s:119: undefined reference to `__tsan_read_range'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.racewriterange':
/opt/google/go/src/runtime/race_amd64.s:131: undefined reference to `__tsan_write_range'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.racewriterangepc1.abi0':
/opt/google/go/src/runtime/race_amd64.s:146: undefined reference to `__tsan_write_range'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `runtime.racefuncexit.abi0':
/opt/google/go/src/runtime/race_amd64.s:193: undefined reference to `__tsan_func_exit'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `sync/atomic.StoreInt32.abi0':
/opt/google/go/src/runtime/race_amd64.s:230: undefined reference to `__tsan_go_atomic32_store'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `sync/atomic.StoreInt64.abi0':
/opt/google/go/src/runtime/race_amd64.s:236: undefined reference to `__tsan_go_atomic64_store'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `sync/atomic.SwapInt64.abi0':
/opt/google/go/src/runtime/race_amd64.s:261: undefined reference to `__tsan_go_atomic64_exchange'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `sync/atomic.AddInt32.abi0':
/opt/google/go/src/runtime/race_amd64.s:280: undefined reference to `__tsan_go_atomic32_fetch_add'
/usr/bin/ld: /tmp/go-link-1571782042/go.o: in function `sync/atomic.CompareAndSwapInt64.abi0':
/opt/google/go/src/runtime/race_amd64.s:315: undefined reference to `__tsan_go_atomic64_compare_exchange'
collect2: error: ld returned 1 exit status
@cuonglm
Copy link
Member

cuonglm commented Jan 17, 2023

Does go install -race -tags=ui works?

@ianlancetaylor
Copy link
Member

What version of gcc are you using?

@ianlancetaylor ianlancetaylor changed the title command/compile: compilation fails with linker reference errors race: building with -race fails with linker reference errors Jan 17, 2023
@bcmills bcmills added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. compiler/runtime Issues related to the Go compiler and/or runtime. labels Jan 17, 2023
@shoenig
Copy link
Contributor Author

shoenig commented Jan 17, 2023

Does go install -race -tags=ui works?

Ah yes, that seems to work

nomad on main 
➜ go install -race -tags=ui

nomad 23son main 
➜ echo $?
0

What version of gcc are you using?

➜ gcc --version 
gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
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.

@ianlancetaylor ianlancetaylor added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jan 17, 2023
@ianlancetaylor ianlancetaylor added this to the Backlog milestone Jan 17, 2023
@ianlancetaylor
Copy link
Member

Do you know whether this works with the 1.19 release? Thanks.

@shoenig
Copy link
Contributor Author

shoenig commented Jan 17, 2023

It doesn't; nearly the same output - I realize this is just a case of holding it wrong, feel free to close unless maybe spilling out linker errors is undesirable

 go version 
go version go1.19.5 linux/amd64
go install -tags=race,ui
# github.com/hashicorp/nomad
/opt/google/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/bin/ld: /tmp/go-link-3609081561/go.o: in function `runtime.mallocgc':
/opt/google/go/src/runtime/race.go:446: undefined reference to `__tsan_malloc'
/bin/ld: /tmp/go-link-3609081561/go.o: in function `runtime.runfinq':
/opt/google/go/src/runtime/race.go:575: undefined reference to `__tsan_finalizer_goroutine'

@ianlancetaylor
Copy link
Member

Oh, I see. You shouldn't use -tags=race. If you want to build with the race detector, you should use plain -race.

Closing because this isn't a bug.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2023
@golang golang locked and limited conversation to collaborators Jan 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants