Michael Hudson-Doyle has uploaded this change for review.
cmd/cgo: make dummy definition of wrapper for exported function match declaration
Currently, if CGO_CFLAGS enables link time optimization, building a
package that exports a Go function to C fails when compiling _cgo_main.c
i(to determine which libraries to link) because of "errors during
merging of translation units". These errors are complaining about the
fact that the definition provided for the wrapper for the to-be-exported
function in _cgo_main.c looks like this:
int _cgoexp_d1f1f4751b13_authCallbackHelper;
but the declaration in _cgo_export.c looks like this:
extern void _cgoexp_d1f1f4751b13_authCallbackHelper(void *);
So make them match. Of course none of this really matters because the
resulting executable is never even executed but this seemed the easiest
way to fix the build.
Fixes #45275
Change-Id: If1f26ebd146da86f66c3801f653633b5d0e7a746
---
M src/cmd/cgo/out.go
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go
index 8e83f02..571092c 100644
--- a/src/cmd/cgo/out.go
+++ b/src/cmd/cgo/out.go
@@ -1028,7 +1028,7 @@
fmt.Fprintf(fgo2, "//go:cgo_export_static _cgoexp%s_%s\n", cPrefix, exp.ExpName)
fmt.Fprintf(fgo2, "func _cgoexp%s_%s(a *%s) {\n", cPrefix, exp.ExpName, gotype)
- fmt.Fprintf(fm, "int _cgoexp%s_%s;\n", cPrefix, exp.ExpName)
+ fmt.Fprintf(fm, "void _cgoexp%s_%s(void *a) {}\n", cPrefix, exp.ExpName)
if gccResult != "void" {
// Write results back to frame.
To view, visit change 305290. To unsubscribe, or for help writing mail filters, visit settings.
Michael Hudson-Doyle abandoned this change.
To view, visit change 305290. To unsubscribe, or for help writing mail filters, visit settings.