aboutsummaryrefslogtreecommitdiff
path: root/misc/cgo/testcshared/cshared_test.go
diff options
context:
space:
mode:
authorCarlos Amedee <carlos@golang.org>2023-01-10 13:50:39 -0500
committerCarlos Amedee <carlos@golang.org>2023-01-10 13:50:39 -0500
commit7058c2cb4132291e1b6c9498a9a6f13a9a70ff85 (patch)
tree7701af5d953be20ade9ca141c562b3262c703716 /misc/cgo/testcshared/cshared_test.go
parentfc1ed37e824b2f87e287e1bc4597253f1b30b3b3 (diff)
parent581603cb7d02019bbf4ff508014038f3120a3dcb (diff)
downloadgo-7058c2cb4132291e1b6c9498a9a6f13a9a70ff85.tar.gz
go-7058c2cb4132291e1b6c9498a9a6f13a9a70ff85.zip
[dev.boringcrypto.go1.18] all: merge go1.18.10 into dev.boringcrypto.go1.18dev.boringcrypto.go1.18
Change-Id: I0dcc4e288cba62382f6bd06b2cf0ff843309220c
Diffstat (limited to 'misc/cgo/testcshared/cshared_test.go')
-rw-r--r--misc/cgo/testcshared/cshared_test.go60
1 files changed, 38 insertions, 22 deletions
diff --git a/misc/cgo/testcshared/cshared_test.go b/misc/cgo/testcshared/cshared_test.go
index c9e9e5fe63..1cd8c2ab4a 100644
--- a/misc/cgo/testcshared/cshared_test.go
+++ b/misc/cgo/testcshared/cshared_test.go
@@ -317,30 +317,46 @@ func createHeaders() error {
if err != nil {
return fmt.Errorf("unable to find dlltool path: %v\n%s\n", err, out)
}
- args := []string{strings.TrimSpace(string(out)), "-D", args[6], "-l", libgoname, "-d", "libgo.def"}
-
- // This is an unfortunate workaround for https://github.com/mstorsjo/llvm-mingw/issues/205 in which
- // we basically reimplement the contents of the dlltool.sh wrapper: https://git.io/JZFlU
- dlltoolContents, err := os.ReadFile(args[0])
- if err != nil {
- return fmt.Errorf("unable to read dlltool: %v\n", err)
+ dlltoolpath := strings.TrimSpace(string(out))
+ if filepath.Ext(dlltoolpath) == "" {
+ // Some compilers report slash-separated paths without extensions
+ // instead of ordinary Windows paths.
+ // Try to find the canonical name for the path.
+ if lp, err := exec.LookPath(dlltoolpath); err == nil {
+ dlltoolpath = lp
+ }
}
- if bytes.HasPrefix(dlltoolContents, []byte("#!/bin/sh")) && bytes.Contains(dlltoolContents, []byte("llvm-dlltool")) {
- base, name := filepath.Split(args[0])
- args[0] = filepath.Join(base, "llvm-dlltool")
- var machine string
- switch prefix, _, _ := strings.Cut(name, "-"); prefix {
- case "i686":
- machine = "i386"
- case "x86_64":
- machine = "i386:x86-64"
- case "armv7":
- machine = "arm"
- case "aarch64":
- machine = "arm64"
+
+ args := []string{dlltoolpath, "-D", args[6], "-l", libgoname, "-d", "libgo.def"}
+
+ if filepath.Ext(dlltoolpath) == "" {
+ // This is an unfortunate workaround for
+ // https://github.com/mstorsjo/llvm-mingw/issues/205 in which
+ // we basically reimplement the contents of the dlltool.sh
+ // wrapper: https://git.io/JZFlU.
+ // TODO(thanm): remove this workaround once we can upgrade
+ // the compilers on the windows-arm64 builder.
+ dlltoolContents, err := os.ReadFile(args[0])
+ if err != nil {
+ return fmt.Errorf("unable to read dlltool: %v\n", err)
}
- if len(machine) > 0 {
- args = append(args, "-m", machine)
+ if bytes.HasPrefix(dlltoolContents, []byte("#!/bin/sh")) && bytes.Contains(dlltoolContents, []byte("llvm-dlltool")) {
+ base, name := filepath.Split(args[0])
+ args[0] = filepath.Join(base, "llvm-dlltool")
+ var machine string
+ switch prefix, _, _ := strings.Cut(name, "-"); prefix {
+ case "i686":
+ machine = "i386"
+ case "x86_64":
+ machine = "i386:x86-64"
+ case "armv7":
+ machine = "arm"
+ case "aarch64":
+ machine = "arm64"
+ }
+ if len(machine) > 0 {
+ args = append(args, "-m", machine)
+ }
}
}