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