Comments (14)
err msg: undefined reference to `github.com/segmentio/asm/cpu.X86';
I guess that go vendor mode changes the file path of the repo, which make the asm code "BTL $0x08, github·com∕segmentio∕asm∕cpu·X86+0(SB)" error
from asm.
Hey @Boyce-Lee, thanks for reporting.
We've seen this error as well when using older versions of Go; do you mind sharing details about your go version and environment? (maybe the output of go version
and go env
).
from asm.
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/tmp/.config-c8q0snp3nk6uslgt0ku0/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOOS="linux"
GOPATH="/compile_path"
GOPROXY="https://goproxy.byted.org"
GOROOT="/usr/local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build569257926=/tmp/go-build -gno-record-gcc-switches"
from asm.
go 1.3/1.4/1.5 do not work
my test version:
go version go1.15.13 linux/amd64
from asm.
@Boyce-Lee Go 1.15.13 is an old release, are there any limitation to use newer Go 1.17 or even 1.18 release?
from asm.
FWIW, I see the same with Go 1.18.1
from asm.
I just tried this and did not observe any issues:
package main
import "github.com/segmentio/asm/mem"
func main() {
src := [1]byte{42}
dst := [1]byte{}
mem.Copy(dst[:], src[:])
}
$ go mod init test-asm
go: creating new go.mod: module test-asm
go: to add module requirements and sums:
go mod tidy
$ go mod tidy
go: finding module for package github.com/segmentio/asm/mem
go: found github.com/segmentio/asm/mem in github.com/segmentio/asm v1.2.0
$ go mod vendor
$ cat vendor/modules.txt
# github.com/segmentio/asm v1.2.0
## explicit; go 1.18
github.com/segmentio/asm/cpu
github.com/segmentio/asm/cpu/arm
github.com/segmentio/asm/cpu/arm64
github.com/segmentio/asm/cpu/cpuid
github.com/segmentio/asm/cpu/x86
github.com/segmentio/asm/mem
# golang.org/x/sys v0.0.0-20220412211240-33da011f77ad
## explicit; go 1.17
golang.org/x/sys/cpu
Do you happen to have a reproducible test case that demonstrates the problem on Go 1.18?
from asm.
Regarding the original issue, the latest version of the project now requires Go 1.17+, there were changes to the build tool that add maintenance overhead to maintain backward compatibility with older Go versions. Version 1.1.5 is the last one supporting Go 1.16, older versions of Go were never supported.
from asm.
fwiw this causes a build failure on OpenBSD/amd64 using go 1.18.1 when building grafana 8.5 and a vendored source tree (which includes segmentio/asm 1.1.0 & 1.1.1 afaict).
/usr/local/go/pkg/tool/openbsd_amd64/link: running cc failed: exit status 1
ld: error: undefined symbol: github.com/segmentio/asm/cpu.X86
>>> referenced by valid_amd64.s:16 (/usr/obj/ports/grafana-8.5.2/go/src/github.com/grafana/grafana/vendor/github.com/segmentio/asm/ascii/valid_amd64.s:16)
>>> /usr/obj/ports/grafana-8.5.2/build-amd64/go-link-2094309761/go.o:(github.com/grafana/grafana/vendor/github.com/segmentio/asm/ascii.ValidString.abi0)
>>> referenced by valid_print_amd64.s:15 (/usr/obj/ports/grafana-8.5.2/go/src/github.com/grafana/grafana/vendor/github.com/segmentio/asm/ascii/valid_print_amd64.s:15)
>>> /usr/obj/ports/grafana-8.5.2/build-amd64/go-link-2094309761/go.o:(github.com/grafana/grafana/vendor/github.com/segmentio/asm/ascii.ValidPrintString.abi0)
from asm.
This looks like a linker issue, likely the build pipeline behaves slightly differently on OpenBSD and it looks like the symbols from the asm/cpu
package are stripped out (maybe they don't have any references in the Go code), which breaks when they are linked from the assembly files.
I tried on a linux/amd64 and did not observe this behavior:
$ go version
go version go1.18.1 linux/amd64
$ cat go.mod
module test-asm
go 1.18
require github.com/segmentio/asm v1.1.1
require golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
The test program I shared above vendors and builds fine.
I also tried building Grafana on the same platform and it succeeded (running make
from the repo, go vendor
worked as well).
from asm.
i got same error
github.com/segmentio/asm/ascii.ValidString: relocation target github.com/segmentio/asm/cpu.X86 not defined
github.com/segmentio/asm/ascii.ValidPrintString: relocation target github.com/segmentio/asm/cpu.X86 not defined
how to fix ?
from asm.
i got same error too
github.com/segmentio/asm/bswap.swap64: relocation target github.com/segmentio/asm/cpu.X86 not defined
go version
go version go1.19.2 linux/amd64
go env
GO111MODULE="off"
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/builds/aquarius/assetsmgr/.go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/builds/aquarius/assetsmgr/.go"
GOPRIVATE=""
GOPROXY="[https://proxy.golang.org,direct](https://proxy.golang.org%2Cdirect/)"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
GOWORK=""
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 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2728460220=/tmp/go-build -gno-record-gcc-switches"
from asm.
i got same error too
github.com/segmentio/asm/bswap.swap64: relocation target github.com/segmentio/asm/cpu.X86 not defined
go version
go version go1.19.2 linux/amd64
go env
GO111MODULE="off" GOARCH="amd64" GOBIN="" GOCACHE="/root/.cache/go-build" GOENV="/root/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/builds/aquarius/assetsmgr/.go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/builds/aquarius/assetsmgr/.go" GOPRIVATE="" GOPROXY="[https://proxy.golang.org,direct](https://proxy.golang.org%2Cdirect/)" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.19.2" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" GOWORK="" 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 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2728460220=/tmp/go-build -gno-record-gcc-switches"
if I enable go mod, problem fixed.
from asm.
https://github.com/segmentio/asm
go build -tags purego ...
This is mainly useful to compare the impact of using the assembly optimized versions instead of the simpler Go-only implementations.
from asm.
Related Issues (14)
- Add documentation
- use x/sys/cpu HOT 1
- base64 decode error HOT 3
- "checkptr: pointer arithmetic result points to invalid allocation" on ARM HOT 2
- Try manually assigning registers HOT 3
- Faster tail block loading code far from page boundary
- Assembly version for small strings
- ARM64 work would lead to Apple Silicon support?
- add mem.Count function
- Performance comparison between assembly and cgo
- undefined reference to `github.com/segmentio/asm/cpu.X86' HOT 2
- which version of the avo?
- Granting more permissive license to integrate upstream HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asm.