Closed
Description
With the following code:
package main
/*
#include <stdlib.h>
typedef void (*destructor)(void*);
static void my_func(destructor d, char *p) {
d(p);
}
*/
import "C"
func main() {
C.my_func(C.destructor(C.free), C.CString("test"))
}
I get the following error:
$ go build cgo_bug.go
# command-line-arguments
ld: illegal text-relocation to '_free' in /usr/lib/libpthread.dylib from 'main.init' in /var/folders/07/ks1g8j_n40v01c_gc7bzx_z00000gn/T//go-link-gyr5vG/go.o for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
/usr/local/opt/go/libexec/pkg/tool/darwin_amd64/6l: running clang failed: unsuccessful exit status 0x100
$ go version
go version default darwin/amd64