rules_go icon indicating copy to clipboard operation
rules_go copied to clipboard

Compiling as static pie doesn't work via bazel, but works with the go command

Open bluec0re opened this issue 1 year ago • 0 comments

What version of rules_go are you using?

0.43.0

What version of gazelle are you using?

none

What version of Bazel are you using?

From gcr.io/bazel-public/bazel:latest:

Build label: 6.4.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Oct 19 17:07:43 2023 (1697735263)
Build timestamp: 1697735263
Build timestamp as int: 1697735263

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

Linux amd64

Any other potentially useful information about your toolchain?

The toolchains installed in gcr.io/bazel-public/bazel:latest

What did you do?

Tried to migrate a static pie go binary from the native toolchain to bazel.

Minimal sample project: https://github.com/bluec0re/rules_go_linker_error

What did you expect to see?

It compiles into a static pie binary.

What did you see instead?

[...]
external/go_sdk/pkg/tool/linux_amd64/link: running /usr/bin/gcc failed: exit status 1
/usr/bin/ld.gold: --no-dynamic-linker: unknown option
/usr/bin/ld.gold: use the --help option for usage information
collect2: error: ld returned 1 exit status

link: error running subcommand external/go_sdk/pkg/tool/linux_amd64/link: exit status 2
Target //:hello failed to build
[...]

bluec0re avatar Nov 30 '23 10:11 bluec0re