https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65134
Bug ID: 65134 Summary: gccgo ignores the attribute "constructor" in a subdirectory Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: go Assignee: ian at airs dot com Reporter: e29253 at jp dot ibm.com CC: cmang at google dot com Created attachment 34813 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34813&action=edit Example to reproduce the constructor problem Gccgo ignores a C-function with the "constructor" attribute in a subdirectory. In the attached example, gc executes a C-function init() in sub.go before a Go function main(), but gccgo does not: ~/example$ export GOPATH=$(pwd) ~/example$ /usr/local/go/bin/go version go version go1.4.2 linux/amd64 ~/example$ /usr/local/go/bin/go run src/main/main.go Hello from constructor Hello from main ~/example$ export LD_LIBRARY_PATH=/usr/local/gccgo/lib64:$LD_LIBRARY_PATH ~/example$ /usr/local/gccgo/bin/go version go version gccgo (GCC) 5.0.0 20150115 (experimental) linux/amd64 ~/example$ /usr/local/gccgo/bin/go run src/main/main.go Hello from main ~/example$ It seems this difference is due to that gccgo cannot detect a function with the constructor attribute in an archived objects created in a subdirectory. Is there any workaround to avoid this problem?