Giter Club home page Giter Club logo

Comments (14)

Boyce-Lee avatar Boyce-Lee commented on May 26, 2024

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.

achille-roussel avatar achille-roussel commented on May 26, 2024

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.

Boyce-Lee avatar Boyce-Lee commented on May 26, 2024
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.

Boyce-Lee avatar Boyce-Lee commented on May 26, 2024

go 1.3/1.4/1.5 do not work

my test version:
go version go1.15.13 linux/amd64

from asm.

cristaloleg avatar cristaloleg commented on May 26, 2024

@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.

tuftedocelot avatar tuftedocelot commented on May 26, 2024

FWIW, I see the same with Go 1.18.1

from asm.

achille-roussel avatar achille-roussel commented on May 26, 2024

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.

achille-roussel avatar achille-roussel commented on May 26, 2024

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.

landryb avatar landryb commented on May 26, 2024

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.

achille-roussel avatar achille-roussel commented on May 26, 2024

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.

hhyvs111 avatar hhyvs111 commented on May 26, 2024

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.

hjweddie avatar hjweddie commented on May 26, 2024

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.

hjweddie avatar hjweddie commented on May 26, 2024

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.

582033 avatar 582033 commented on May 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.