Skip to content

cmd/go: -buildmode=shared and cgo and -compiler gccgo don't work together #15885

@mwhudson

Description

@mwhudson

This combination has probably never worked correctly, but my fix for #11739 broke it harder:

$ cat $GOPATH/src/pkgconfigcgo/p.go
package pkgconfigcgo

// #cgo pkg-config: libpng
// #include <png.h>
import "C"

func V() uint32 {
    return uint32(C.png_access_version_number())
}
$ go build -buildmode=shared -compiler gccgo pkgconfigcgo
# /tmp/go-build393723771/libpkgconfigcgo.so
/opt/opensource/gopath/pkg/gccgo_linux_amd64_fPIC/libpkgconfigcgo.a: member /opt/opensource/gopath/pkg/gccgo_linux_amd64_fPIC/libpkgconfigcgo.a(_cgo_flags) in archive is not an object
collect2: error: ld returned 1 exit status

gccgo's ldShared() needs to do (at least) some of the tricks its ld() method does wrt _cgo_flags and so on.

No rush for 1.7 – it's more important to me to get a fix into gccgo in Ubuntu.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions