diff options
author | Ayke van Laethem <[email protected]> | 2020-04-03 21:40:39 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2020-04-09 20:23:51 +0200 |
commit | 9e453a5a291e9dabf8a9209a2f99ed0f09f8e692 (patch) | |
tree | 0213395c85718188946f520cc587284fcfdf41e3 /builder | |
parent | a08d3aa1dd47311902bffbfec97071f7b5a8a229 (diff) | |
download | tinygo-9e453a5a291e9dabf8a9209a2f99ed0f09f8e692.tar.gz tinygo-9e453a5a291e9dabf8a9209a2f99ed0f09f8e692.zip |
builder: work around a bug in ld.lld in LLVM 10
See comment in the commit for details. It works around a bug that's been
reported here: https://bugs.llvm.org/show_bug.cgi?id=45336
This is a separate commit so it can easily be reverted if/when this
patch is backported to the LLVM 10 stable branch.
Diffstat (limited to 'builder')
-rw-r--r-- | builder/sizes.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/builder/sizes.go b/builder/sizes.go index c88c9b7ba..750c4bd94 100644 --- a/builder/sizes.go +++ b/builder/sizes.go @@ -84,7 +84,18 @@ func loadProgramSize(path string) (*programSize, error) { if section.Type != elf.SHT_PROGBITS && section.Type != elf.SHT_NOBITS { continue } - if section.Type == elf.SHT_NOBITS { + if section.Name == ".stack" { + // HACK: this works around a bug in ld.lld from LLVM 10. The linker + // marks sections with no input symbols (such as is the case for the + // .stack section) as SHT_PROGBITS instead of SHT_NOBITS. While it + // doesn't affect the generated binaries (.hex and .bin), it does + // affect the reported size. + // https://bugs.llvm.org/show_bug.cgi?id=45336 + // https://reviews.llvm.org/D76981 + // It has been merged in master, but it has not (yet) been + // backported to the LLVM 10 release branch. + sumBSS += section.Size + } else if section.Type == elf.SHT_NOBITS { sumBSS += section.Size } else if section.Flags&elf.SHF_EXECINSTR != 0 { sumCode += section.Size |