Skip to content

Commit dbca451

Browse files
committed
Add comment explaining -Os
1 parent 33054dd commit dbca451

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Tools/jit/_targets.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ async def _compile(
137137
f"-I{CPYTHON / 'Include' / 'internal' / 'mimalloc'}",
138138
f"-I{CPYTHON / 'Python'}",
139139
f"-I{CPYTHON / 'Tools' / 'jit'}",
140+
# -O2 and -O3 include some optimizations that make sense for
141+
# standalone functions, but not for snippets of code that are going
142+
# to be laid out end-to-end (like ours)... common examples include
143+
# passes like tail-duplication, or aligning jump targets with nops.
144+
# -Os is equivalent to -O2 with many of these problematic passes
145+
# disabled. Based on manual review, for *our* purposes it usually
146+
# generates better code than -O2 (and -O2 usually generates better
147+
# code than -O3). As a nice benefit, it uses less memory too:
140148
"-Os",
141149
"-S",
142150
# Shorten full absolute file paths in the generated code (like the

0 commit comments

Comments
 (0)