-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
Description
What steps will reproduce the problem? 1. this program gccbuiltin.go package main // int f(int x) { return __builtin_popcount(x); } import "C" func main() { println(C.f(100)) } 2. go build gccbuiltin.go What is the expected output? What do you see instead? It should compile OK. But I get errors instead: command-line-arguments /tmp/go-build285777972/command-line-arguments.a(gccbuiltin.cgo2.)(.text): __popcountdi2: not defined __popcountdi2(0): not defined Notes: 0. Discussion: http://groups.google.com/group/golang-dev/t/bf56f38944524389 1. this happens on Linux, FreeBSD and Windows (It doesn't fail on Mac OS X, because libSystem includes libgcc.). 2. I use a gcc builtin to test this error, but this bug isn't caused by gcc builtin, it is caused by the general problem of gcc static linking libgcc by default. 3. We can fix this on FreeBSD and Linux quite easily, by providing -shared-libgcc to gcc. But we can't fix this on Wndows this way, because libgcc isn't bundled with Windows.