]> Cypherpunks repositories - gostls13.git/commitdiff
misc/cgo/testso, misc/cgo/testsovar: fix for Windows
authorRuss Cox <rsc@golang.org>
Tue, 20 Apr 2021 20:22:01 +0000 (16:22 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 23 Apr 2021 21:48:41 +0000 (21:48 +0000)
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>
misc/cgo/testso/so_test.go
misc/cgo/testso/testdata/cgoso.go
misc/cgo/testsovar/so_test.go
misc/cgo/testsovar/testdata/cgoso.go

index 1c97ae9bcb25620f2c6f6788fdae66b9fe9c3de0..2023c51f113785d14482ee7a7b3556825784e7c3 100644 (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"
        }
index bba5de331212f2506e630e5c484cc1cc0aa905fc..b59b2a8e8b1541f6a2a351b8e716267a5441d13d 100644 (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);
index 1c97ae9bcb25620f2c6f6788fdae66b9fe9c3de0..2023c51f113785d14482ee7a7b3556825784e7c3 100644 (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"
        }
index 9c7f95e92ea454e68ff238aa6bf18ee2732e3a94..d9deb556da87758e579d1996439ea9cfb70cf4ea 100644 (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"