misc/cgo/testso, misc/cgo/testsovar: fix for Windows

At least in mingw-clang it is not permitted to just name a .dll
on the command line. You must name the corresponding import
library instead, even though the dll is used when the executable
is run.

This fixes misc/cgo/testso and misc/cgo/testsovar on windows/arm64.

Change-Id: I516b6ccba2fe3a9ee2c01e710a71850c4df8522f
Reviewed-on: https://go-review.googlesource.com/c/go/+/312046
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Russ Cox 2021-04-20 16:22:01 -04:00
parent 9cc3469106
commit a6d3dc40c4
4 changed files with 10 additions and 2 deletions

View file

@ -79,6 +79,10 @@ func TestSO(t *testing.T) {
case "windows":
ext = "dll"
args = append(args, "-DEXPORT_DLL")
// At least in mingw-clang it is not permitted to just name a .dll
// on the command line. You must name the corresponding import
// library instead, even though the dll is used when the executable is run.
args = append(args, "-Wl,-out-implib,libcgosotest.a")
case "aix":
ext = "so.1"
}

View file

@ -14,7 +14,7 @@ package cgosotest
#cgo solaris LDFLAGS: -L. -lcgosotest
#cgo netbsd LDFLAGS: -L. libcgosotest.so
#cgo darwin LDFLAGS: -L. libcgosotest.dylib
#cgo windows LDFLAGS: -L. libcgosotest.dll
#cgo windows LDFLAGS: -L. libcgosotest.a
#cgo aix LDFLAGS: -L. -l cgosotest
void init(void);

View file

@ -79,6 +79,10 @@ func TestSO(t *testing.T) {
case "windows":
ext = "dll"
args = append(args, "-DEXPORT_DLL")
// At least in mingw-clang it is not permitted to just name a .dll
// on the command line. You must name the corresponding import
// library instead, even though the dll is used when the executable is run.
args = append(args, "-Wl,-out-implib,libcgosotest.a")
case "aix":
ext = "so.1"
}

View file

@ -18,7 +18,7 @@ package cgosotest
#cgo solaris LDFLAGS: -L. -lcgosotest
#cgo netbsd LDFLAGS: -L. libcgosotest.so
#cgo darwin LDFLAGS: -L. libcgosotest.dylib
#cgo windows LDFLAGS: -L. libcgosotest.dll
#cgo windows LDFLAGS: -L. libcgosotest.a
#cgo aix LDFLAGS: -L. -l cgosotest
#include "cgoso_c.h"