diff --git a/go/tools/builders/link.go b/go/tools/builders/link.go index 1240e3933e..6727a7fe0c 100644 --- a/go/tools/builders/link.go +++ b/go/tools/builders/link.go @@ -25,6 +25,7 @@ import ( "log" "os" "path/filepath" + "runtime" "strings" ) @@ -49,6 +50,16 @@ func run(args []string) error { return err } + // On Windows, take the absolute path of the output file and main file. + // This is needed on Windows because the relative path is frequently too long. + // os.Open on Windows converts absolute paths to some other path format with + // longer length limits. Absolute paths do not work on macOS for .dylib + // outputs because they get baked in as the "install path". + if runtime.GOOS != "darwin" { + *outFile = abs(*outFile) + } + *main = abs(*main) + // If we were given any stamp value files, read and parse them stampmap := map[string]string{} for _, stampfile := range stamps {