@@ -323,30 +323,46 @@ func createHeaders() error {
323
323
if err != nil {
324
324
return fmt .Errorf ("unable to find dlltool path: %v\n %s\n " , err , out )
325
325
}
326
- args := []string {strings .TrimSpace (string (out )), "-D" , args [6 ], "-l" , libgoname , "-d" , "libgo.def" }
327
-
328
- // This is an unfortunate workaround for https://github.com/mstorsjo/llvm-mingw/issues/205 in which
329
- // we basically reimplement the contents of the dlltool.sh wrapper: https://git.io/JZFlU
330
- dlltoolContents , err := os .ReadFile (args [0 ])
331
- if err != nil {
332
- return fmt .Errorf ("unable to read dlltool: %v\n " , err )
326
+ dlltoolpath := strings .TrimSpace (string (out ))
327
+ if filepath .Ext (dlltoolpath ) == "" {
328
+ // Some compilers report slash-separated paths without extensions
329
+ // instead of ordinary Windows paths.
330
+ // Try to find the canonical name for the path.
331
+ if lp , err := exec .LookPath (dlltoolpath ); err == nil {
332
+ dlltoolpath = lp
333
+ }
333
334
}
334
- if bytes . HasPrefix ( dlltoolContents , [] byte ( "#!/bin/sh" )) && bytes . Contains ( dlltoolContents , [] byte ( "llvm-dlltool" )) {
335
- base , name := filepath . Split ( args [0 ])
336
- args [ 0 ] = filepath . Join ( base , "llvm-dlltool" )
337
- var machine string
338
- switch prefix , _ , _ := strings . Cut ( name , "-" ); prefix {
339
- case "i686" :
340
- machine = "i386"
341
- case "x86_64" :
342
- machine = "i386:x86-64"
343
- case "armv7" :
344
- machine = "arm"
345
- case "aarch64" :
346
- machine = "arm64"
335
+
336
+ args := [] string { dlltoolpath , "-D" , args [6 ], "-l" , libgoname , "-d" , "libgo.def" }
337
+
338
+ if filepath . Ext ( dlltoolpath ) == "" {
339
+ // This is an unfortunate workaround for
340
+ // https://github.com/mstorsjo/llvm-mingw/issues/205 in which
341
+ // we basically reimplement the contents of the dlltool.sh
342
+ // wrapper: https://git.io/JZFlU.
343
+ // TODO(thanm): remove this workaround once we can upgrade
344
+ // the compilers on the windows-arm64 builder.
345
+ dlltoolContents , err := os . ReadFile ( args [ 0 ])
346
+ if err != nil {
347
+ return fmt . Errorf ( "unable to read dlltool: %v \n " , err )
347
348
}
348
- if len (machine ) > 0 {
349
- args = append (args , "-m" , machine )
349
+ if bytes .HasPrefix (dlltoolContents , []byte ("#!/bin/sh" )) && bytes .Contains (dlltoolContents , []byte ("llvm-dlltool" )) {
350
+ base , name := filepath .Split (args [0 ])
351
+ args [0 ] = filepath .Join (base , "llvm-dlltool" )
352
+ var machine string
353
+ switch prefix , _ , _ := strings .Cut (name , "-" ); prefix {
354
+ case "i686" :
355
+ machine = "i386"
356
+ case "x86_64" :
357
+ machine = "i386:x86-64"
358
+ case "armv7" :
359
+ machine = "arm"
360
+ case "aarch64" :
361
+ machine = "arm64"
362
+ }
363
+ if len (machine ) > 0 {
364
+ args = append (args , "-m" , machine )
365
+ }
350
366
}
351
367
}
352
368
0 commit comments