When using the cgo tool with the -gccgo option, calls to C.GoString, C.GoStringN, and C.GoBytes will be translated into calls to __go_byte_array_to_string and __go_string_to_byte_array. Those functions were removed when the string code was copied from Go 1.7, but we still need them for cgo. While cgo should be updated, old versions will exist for some time. So this patch adds the functions to libgo so that they are available for use by cgo. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline.
Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 241742) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -90f12ac1fa72a95e73cb88b6114fa3131c4ca8ee +069ed35ecbefd2f138ea3132a557ad23a6936a45 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/runtime/string.go =================================================================== --- libgo/go/runtime/string.go (revision 241341) +++ libgo/go/runtime/string.go (working copy) @@ -444,3 +444,20 @@ func gostringw(strw *uint16) string { b[n2] = 0 // for luck return s[:n2] } + +// These two functions are called by code generated by cgo -gccgo. + +//go:linkname __go_byte_array_to_string __go_byte_array_to_string +func __go_byte_array_to_string(p unsafe.Pointer, l int) string { + if l == 0 { + return "" + } + s, c := rawstringtmp(nil, l) + memmove(unsafe.Pointer(&c[0]), p, uintptr(l)) + return s +} + +//go:linkname __go_string_to_byte_array __go_string_to_byte_array +func __go_string_to_byte_array(s string) []byte { + return stringtoslicebyte(nil, s) +}