hermetic_cc_toolchain icon indicating copy to clipboard operation
hermetic_cc_toolchain copied to clipboard

ARM external linker must be gold (issue #15696), but is not: zig ld 0.11.0

Open farcop opened this issue 2 years ago • 12 comments

After upgrade on https://github.com/uber/hermetic_cc_toolchain/releases/tag/v2.1.2 On linux/amd64 VM I get error when trying to build go_binary.

2023/09/30 07:07:20 ARM external linker must be gold (issue #15696), but is not: zig ld 0.11.0
link: error running subcommand external/go_sdk/pkg/tool/linux_amd64/link: exit status 1

https://github.com/golang/go/issues/15696

Rolled back to the 2.0.0 to workaround this issue.

farcop avatar Sep 30 '23 08:09 farcop

Tested with

register_toolchains(
    "@zig_sdk//toolchain:linux_amd64_gnu.2.31",
    "@zig_sdk//toolchain:linux_arm64_gnu.2.31",
)

and with 2.34.

Debug output:

ERROR: /home/kublr/kublr/cluster-controller/BUILD.bazel:27:10: GoLink cluster-controller/cluster-controller failed: (Exit 1): linux-sandbox failed: error executing command 
  (cd /home/kublr/.cache/bazel/_bazel_kublr/69fb4c52c15303cc4e23e5352527edec/sandbox/linux-sandbox/1/execroot/kublr && \
  exec env - \
    CGO_ENABLED=1 \
    GOARCH=arm64 \
    GOEXPERIMENT=nocoverageredesign \
    GOOS=linux \
    GOPATH='' \
    GOROOT=bazel-out/k8-fastbuild-ST-29c7f66a8f11/bin/external/io_bazel_rules_go/stdlib_ \
    GOROOT_FINAL=GOROOT \
    PATH=external/zig_sdk/tools:external/zig_sdk/tools/aarch64-linux-gnu.2.34:/bin:/usr/bin \
    TMPDIR=/tmp \
  /home/kublr/.cache/bazel/_bazel_kublr/install/a09dbb90c658248f08f9aa0eba11997d/linux-sandbox -t 15 -w /home/kublr/.cache/bazel/_bazel_kublr/69fb4c52c15303cc4e23e5352527edec/sandbox/linux-sandbox/1/execroot/kublr -w /tmp -w /dev/shm -S /home/kublr/.cache/bazel/_bazel_kublr/69fb4c52c15303cc4e23e5352527edec/sandbox/linux-sandbox/1/stats.out -D -- bazel-out/k8-opt-exec-2B5CBBC6-ST-e846b08c7501/bin/external/go_sdk/builder_reset/builder '-param=bazel-out/k8-fastbuild-ST-49c02b6fcfac/bin/cluster-controller/cluster-controller-0.params' -- -extld external/zig_sdk/tools/aarch64-linux-gnu.2.34/c++ -X 'src.kublr.io/kublr/common/pkg/version.version=1.28.0-alpha.0' '-buildid=redacted' -s -w -extldflags '-fno-lto -fsanitize-undefined-strip-path-components=-1')

farcop avatar Oct 02 '23 12:10 farcop

Which Go/Zig version do you use with this? Can this be reproduced with tests of hermetic_cc_toolchain?

motiejus avatar Oct 10 '23 08:10 motiejus

@motiejus go 1.20 zig is default toolchain version in v2.1.2

which test I should run?

farcop avatar Oct 10 '23 11:10 farcop

@motiejus go 1.20 zig is default toolchain version in v2.1.2

which test I should run?

The point is we need to be able to reproduce the failure. Your report does not include a test case, so let's come up with one.

We have a bunch of tests in hermetic_cc_toolchain, which are currently green. Perhaps it would be easy to change one that reproduces this failure?

motiejus avatar Oct 10 '23 12:10 motiejus

I can only confirm that error is in multi architecture image transformation written just like https://github.com/bazel-contrib/rules_oci/blob/main/examples/multi_arch/BUILD.bazel#L19-L26 I cant publish whole code example but the same code works well with 2.0.0 release of hermetic_cc_toolchain.

farcop avatar Oct 24 '23 09:10 farcop

I've just added a test to reproduce this failure in https://github.com/uber/hermetic_cc_toolchain/pull/129

lbcjbb avatar Oct 27 '23 14:10 lbcjbb

@lbcjbb Thank you. Much appreciated.

farcop avatar Oct 27 '23 14:10 farcop

https://github.com/uber/hermetic_cc_toolchain/pull/129/commits/56c4e1ecf39f8e4be53fe9f7ecfc715cd9d7409e should fix this issue now.

lbcjbb avatar Oct 27 '23 21:10 lbcjbb

I think this is due to a hack in Go linker.

Either this or this will fix it. I would prefer patching Go linker with one of these patches and report the success or failure on https://github.com/golang/go/issues/22040, instead of putting another hack on hermetic_cc_toolchain to cheat Go linker.

linzhp avatar Nov 30 '23 15:11 linzhp