Go 1.15 arrives with smaller binary sizes

New version of Google-built language brings compiler, runtime, and linker improvements

Go 1.15 arrives with smaller binary sizes
seraficus / Getty Images

Go 1.15, the latest version of Google’s popular open source, statically typed, compiled language, was published as a production release on August 11. Among the new capabilities is an enhanced compiler that produces smaller binary sizes. The runtime and linker also have been improved.

Typical binary sizes in Go 1.15 are reduced by about five percent compared to Go 1.14. This reduction is achieved by eliminating certain types of garbage collection metadata and more-aggressively eliminating unused type metadata.

In another compiler improvement, the toolchain now mitigates Intel CPU erratum SKX102 on GOARCH=amd64 by aligning functions to 32-byte boundaries and padding jump instructions. Although this padding increases binary sizes, this increase is more than compensated for by the release’s binary size improvements. Additionally, Go 1.15 adds a -spectre flag to the compiler and the assembler to enable Spectre CPU vulnerability mitigations, though the Go team advises that these should almost never be needed.

The compiler in Go 1.15 also now rejects //go: compiler directives that have no meaning for the declarations they are applied to, reporting a “misplaced compiler directive” error. These misspelled directives were broken previously, but were silently ignored by the compiler.

Instructions for downloading the Go 1.15 beta can be found at golang.org. Other improvements in Go 1.15, based on release notes, include:

  • The compiler’s -json optimization logging now reports large copies as greater than or equal to 128 bytes, and provides explanations of escape analysis decisions.
  • For the runtime, allocation of small objects now performs better at high counts and has lower worst-case latency. Further, non-blocking receives on closed channels now perform as well as non-blocking receives on open channels.
  • Substantial improvements have been made to the Go linker, reducing linker resource usage. For a representative set of large Go programs, linking was 20 percent faster and used 30 percent less memory on average, for ELF-based operating systems on AMD64 architectures, with more-modest improvements for other architecture/OS improvements. Key to the better linker performance are a newly redesigned object file format and a revamping of internal phases to boost concurrency. 
  • With the Go command, the GOPROXY environment now supports skipping proxies that return errors. Proxy URLs now can be separated with commas or pipe characters. Also, various flag parsing issues in go test and go vet have been fixed.
  • The core library now includes a package, time/tzdata, that permits embedding the time zone database into a program.
  • The vet tool now warns about conversions of the form string (x) where x has an integer type other than rune or byte. The vet tool also now warns about type assertions from one interface type to another interface type when the type assertion will always fail. 
  • Deprecated legacy behavior of treating the CommonName field on X.509 certificates as a host name when there are no Subject Alternative Names present is now disabled by default. 

Copyright © 2020 IDG Communications, Inc.