Skip to content

Cross-platform Go build fails using pants package #21113

Open
@agoblet

Description

@agoblet

Describe the bug
When running pants package on a go_binary target with the GOOS or GOARCH environment set to a different OS or arch, the command fails. Running go build directly with these environment variables works fine. The environment variables have been configured in pants.toml as follows:

[golang]
subprocess_env_vars = [
  "LANG",
  "LC_CTYPE",
  "LC_ALL",
  "PATH",
  "GOOS",
  "GOARCH"
]

Below are the outputs for running with a different GOOS and different GOARCH, respectively:

different GOARCH (amd64 running on an arm64 device):

❯ GOARCH=amd64 pants package ::
13:22:31.18 [ERROR] Completed: Compile with Go - runtime - runtime failed (exit code 1).
/usr/local/go/src/runtime/asm_amd64.s:262: unrecognized instruction "get_tls"
/usr/local/go/src/runtime/asm_amd64.s:263: expected end of operand, found (
/usr/local/go/src/runtime/asm_amd64.s:270: unrecognized instruction "get_tls"
/usr/local/go/src/runtime/asm_amd64.s:272: expected end of operand, found (
/usr/local/go/src/runtime/asm_amd64.s:410: unrecognized instruction "get_tls"
/usr/local/go/src/runtime/asm_amd64.s:411: expected end of operand, found (
/usr/local/go/src/runtime/asm_amd64.s:453: unrecognized instruction "get_tls"
/usr/local/go/src/runtime/asm_amd64.s:454: expected end of operand, found (
/usr/local/go/src/runtime/asm_amd64.s:480: unrecognized instruction "get_tls"
/usr/local/go/src/runtime/asm_amd64.s:481: expected end of operand, found (
/usr/local/go/src/runtime/asm_amd64.s:502: expected end of operand, found (
asm: too many errors


/usr/local/go/src/runtime/sys_darwin_amd64.s:177: unrecognized instruction "get_tls"
/usr/local/go/src/runtime/sys_darwin_amd64.s:178: expected end of operand, found (
/usr/local/go/src/runtime/sys_darwin_amd64.s:229: unrecognized instruction "get_tls"
/usr/local/go/src/runtime/sys_darwin_amd64.s:230: expected end of operand, found (
asm: assembly of /usr/local/go/src/runtime/sys_darwin_amd64.s failed

13:22:31.18 [ERROR] 1 Exception encountered:

Engine traceback:
  in `package` goal

Exception: Failed to compile main:

/usr/local/go/src/runtime/asm_amd64.s:262: unrecognized instruction "get_tls"
/usr/local/go/src/runtime/asm_amd64.s:263: expected end of operand, found (
/usr/local/go/src/runtime/asm_amd64.s:270: unrecognized instruction "get_tls"
/usr/local/go/src/runtime/asm_amd64.s:272: expected end of operand, found (
/usr/local/go/src/runtime/asm_amd64.s:410: unrecognized instruction "get_tls"
/usr/local/go/src/runtime/asm_amd64.s:411: expected end of operand, found (
/usr/local/go/src/runtime/asm_amd64.s:453: unrecognized instruction "get_tls"
/usr/local/go/src/runtime/asm_amd64.s:454: expected end of operand, found (
/usr/local/go/src/runtime/asm_amd64.s:480: unrecognized instruction "get_tls"
/usr/local/go/src/runtime/asm_amd64.s:481: expected end of operand, found (
/usr/local/go/src/runtime/asm_amd64.s:502: expected end of operand, found (
asm: too many errors


/usr/local/go/src/runtime/sys_darwin_amd64.s:177: unrecognized instruction "get_tls"
/usr/local/go/src/runtime/sys_darwin_amd64.s:178: expected end of operand, found (
/usr/local/go/src/runtime/sys_darwin_amd64.s:229: unrecognized instruction "get_tls"
/usr/local/go/src/runtime/sys_darwin_amd64.s:230: expected end of operand, found (
asm: assembly of /usr/local/go/src/runtime/sys_darwin_amd64.s failed

different GOOS (linux running on a darwin device):

❯ GOOS=linux pants package ::
13:15:39.88 [ERROR] 1 Exception encountered:

Engine traceback:
  in `package` goal

ProcessExecutionFailure: Process 'Link Go binary: ./package_analyzer' failed with exit code 1.
stdout:

stderr:
runtime.rt0_go: relocation target runtime.tlsinit not defined



Use `--keep-sandboxes=on_failure` to preserve the process chroot for inspection.

Pants version
2.21.0 (+ Go version 1.22.3)

OS
MacOS (M3), did not test on Linux

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions