Open pmur opened 1 year ago
I suppose that cmd/go shouldn't crash, but why is the .go_export
section missing? It should always be generated by gccgo. Is something removing it?
Change https://go.dev/cl/503496 mentions this issue: cmd/go: check for errors reading gccgo package list
It seems to be getting lost when linking the shared library. It exists in the input archive depBase.a
, but is not in the resulting shared library, when the following runs:
/opt/at15.0/bin/gccgo -o $WORK/b004/libtestshared-depBase.so "-Wl,-(" -Wl,--whole-archive /tmp/shared_test3084291572/gopath/pkg/gccgo_linux_ppc64le_fPIC/testshared/depBase.a -Wl,--no-whole-archive "-Wl,-)" -Wl,--build-id=0x38416f4b645851384a4f5a346e564948596539682f38416f4b645851384a4f5a346e56494859653968 -zdefs -shared -nostdlib -lgo -lgcc_s -lgcc -lc -fPIC
What linker are you using?
In the above case GNU ld (GNU Binutils) 2.37.20220122
.
Hrm, I suspect the issue is the .go_export
section has the exclude flag set.
Looking at the output of gccgo
, I see:
.section .go_export,"ae",@progbits
Poking around the gccgo code, I wonder if the macro TARGET_AIX
is not evaluating as expected.
I do see, in gcc/config/rs6000/linux64.h:
#undef TARGET_AIX
#define TARGET_AIX TARGET_64BIT
That dates back to 2023 and looks like a problem here. There is similar code in freebsd64.h.
Perhaps we can change the code in go-backend.cc to test OBJECT_FORMAT_COFF rather than TARGET_AIX. Want to give that a try?
I posted a couple of patches to gcc to update the usage of TARGET_AIX
to TARGET_AIX_OS
. This seems to preserve the original intent, while fixing this bug. I also updated the usage in a couple other places.
Change https://go.dev/cl/504095 mentions this issue: cmd/cgo/internal/testshared: disable gccgo tests on PPC64
Change https://go.dev/cl/503495 mentions this issue: cmd/cgo/internal/testshared: strip newline from gccgo -dumpversion
What version of Go are you using (
go version
)?I have observed this using the fedora 36 system gcc and gccgo. It also happens using IBM's advance-toolchain 15 and newer.
What did you do?
cmd/go crashes because it assumes
.go_export
section is present within the shared library built by gccgo, but it is missing.