1

executable files built by the Go compiler are not compatible on target environment as the loader expects program sections to be in specific order.

As a result, I'm trying to compile the Go source using go tool compile to generate .o files, which I want to link using the gcc/clang linker option instead of go tool link

Does the object files generated from go build are compatible to be linked with gcc/clang toolchain ?

0xFFFFFFF0
  • 65
  • 5
  • 4
    Instead of invoking gc or the linker you should try `buildmode`: Run `go help buildmode` for details. – Volker Sep 06 '21 at 13:08
  • @Volker thanks, I was able to create a static or shared library from this option. But, this includes a lot of go runtime in the built library. If I have to link this library along with other libraries built using clang, this would not resolve the symbols as the statically built library has gcc symbols: `/usr/lib/llvm-5.0/bin/ld.lld: error: undefined symbol: stderr >>> referenced by gcc_libinit.c:29` Is there a way to build go runtime without glibc symbols, so that I can use the archive without relying gcc toolchain ? – 0xFFFFFFF0 Sep 07 '21 at 08:14
  • You probably should ask this on the golang-nuts mailing list and not here. – Volker Sep 07 '21 at 08:45

0 Answers0