Skip to content

Commit 60ccc9e

Browse files
aykevldeadprogram
authored andcommitted
machine: don't inline RTT WriteByte everywhere
With `-opt=2`, WriteByte gets inlined everywhere a println statement exists. This blows up binary size for very little gain. In my case, the binary size roughly doubled. Instead, don't inline it so that the binary size remains somewhat reasonable. This might slow down WriteByte a tiny bit, but likely not by any significant amount.
1 parent 7e3f603 commit 60ccc9e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/machine/serial-rtt.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ func (b *rttBuffer) buffered() int {
123123
return int((writeOffset - readOffset) % rttBufferSizeDown)
124124
}
125125

126+
// Write a single byte to the RTT output buffer.
127+
//
128+
// This method is set to not be inlined, to avoid blowing up binary size as a
129+
// result of inlining writeByte everywhere a println exists.
130+
//
131+
//go:noinline
126132
func (s *rttSerial) WriteByte(b byte) error {
127133
s.buffersUp[0].writeByte(b)
128134
return nil

0 commit comments

Comments
 (0)