segmentio/asm

undefined reference to `github.com/segmentio/asm/cpu.X86'

mettledrum opened this issue · 2 comments

When segmentio/asm v1.2.0 is vendored into a module, building a Docker image fails.

build layer in Dockerfile:

RUN CGO_ENABLED=1 GO111MODULE=off go install /cmd/main.go

error logs:

[2022-12-06 16:56:34]  INFO docker build: #10 37.51 # github.com/segmentio/<REPO>/cmd/<BINARY>
  | [2022-12-06 16:56:34]  INFO docker build: #10 37.51 /usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
  | [2022-12-06 16:56:34]  INFO docker build: #10 37.51 /usr/bin/ld: /tmp/go-link-506352844/go.o: in function `github.com/segmentio/<REPO>/vendor/github.com/segmentio/asm/bswap.swap64.abi0':
  | [2022-12-06 16:56:34]  INFO docker build: #10 37.51 /go/src/github.com/segmentio/<REPO>/vendor/github.com/segmentio/asm/bswap/swap64_amd64.s:14: undefined reference to `github.com/segmentio/asm/cpu.X86'
  | [2022-12-06 16:56:34]  INFO docker build: #10 37.51 collect2: error: ld returned 1 exit status
  | [2022-12-06 16:56:34]  INFO docker build: #10 37.51
  | [2022-12-06 16:56:35]  INFO docker build: #10 37.83 # github.com/segmentio/<REPO>/cmd/<BINARY>
  | [2022-12-06 16:56:35]  INFO docker build: #10 37.83 /usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
  | [2022-12-06 16:56:35]  INFO docker build: #10 37.83 /usr/bin/ld: /tmp/go-link-65482911/go.o: in function `github.com/segmentio/<REPO>/vendor/github.com/segmentio/asm/bswap.swap64.abi0':
  | [2022-12-06 16:56:35]  INFO docker build: #10 37.83 /go/src/github.com/segmentio/<REPO>/vendor/github.com/segmentio/asm/bswap/swap64_amd64.s:14: undefined reference to `github.com/segmentio/asm/cpu.X86'
  | [2022-12-06 16:56:35]  INFO docker build: #10 37.83 collect2: error: ld returned 1 exit status
  | [2022-12-06 16:56:35]  INFO docker build: #10 37.83

It seems like this is the line of code within segmentio/asm that's missing a reference but I'm unsure how to fix this.

Hello @mettledrum, thanks for reporting!

This looks like a duplicate of #73 maybe? TLDR this might be caused by GO111MODULE=off.

yes, taking out GO111MODULE=off avoided the error, thx