<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59424>59424</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`-fstack-size-section` doesn't emit `.stack_sizes` section when using any LTO
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pirama-arumuga-nainar
</td>
</tr>
</table>
<pre>
```
# With ThinLTO (but Full LTO also skips the section the same way)
$ echo "int main() {
return 0;
}" > main.cpp
$ clang -fstack-size-section main.cpp -fuse-ld=lld -v -flto=thin
$ llvm-readelf -a a.out | grep .stack_sizes
```
vs.
```
# Without ThinLTO
$ clang -fstack-size-section main.cpp -fuse-ld=lld -v
$ llvm-readelf -a a.out | grep .stack_sizes
[28] .stack_sizes PROGBITS 0000000000000000 0009df 000009 00 L 15 0 1
None .comment .stack_sizes .symtab .shstrtab .strtab
```
There is a workaround - passing `-Wl,-mllvm,--stack-size-section` to the linker [1] but this option should be a module attribute to make this work seamlessly with LTO (similar to, for e.g., [-warn-frame-size](https://reviews.llvm.org/D103928))
[1]
```
$ clang++ -fstack-size-section main.cpp -fuse-ld=lld -flto=thin -Wl,-mllvm,--stack-size-section
$ llvm-readelf -a a.out | grep .stack_sizes
[26] .stack_sizes PROGBITS 0000000000000000 000a46 000009 00 L 13 0 1
None .comment .stack_sizes .symtab .shstrtab .strtab
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyslFGPozYQxz_N8DIyMiaQ8MDDZdNUlU69ql3pHisTBnBjbGSbjdJPX5kkt5ttqrbas6JgjD2e-fv3t_Re9YaohmILxS6Rcxisqyfl5CiZdPM495IZqYx0SWPbcw0lv_74DvgnEDl-VWHA50GZz89fEMSmmQPuZ60xvkvtLfqjmjyGgdDTIShrLn05Ep7kGUR1C7ZCOgwWQQhlAo5SGRAbEBXCenuZg-gozM4gh_w6BOsdCIGQ_7CsSA_T9BrvoKXpkXU-yMORefUnsVsOt8nIutkT0y3kO61bZC_IOh0s5LswKPMaS-uXkTmSLekOmUSZ2jkgrJ-wdzRhuuzxe9zDXxfdi_Xi0-v4o683KWPMq5ofLOMDmSNCsRUbKHZ3H3Fpv_z65cftT8-_IX_X4kDVdpfxCjlHxM-YFYjIEbNbaPzZGkLE9GDHkUy43yL15zHIBlM_-OAuvcvzsWzL__NAjlB5lHiy7iidnU2LDKdIuOkRSs6-ahBPbIxaxA77u5ZQcgx2gVMrcyQXVciiCJHpMCiPdlpE94OddYsNocTRtrMmlCE41cyBYohRHumyIKaDnuSoyXt9xlN0y9UpXo1KS4fBgnjCzjqktE9jH4otO0lnWOfkSEuSUOxAbIYQJg_5JxB7EHtHL4pOPo01pdb1IPa7jOfVYprFN295u9TyD_BdGQOxBbH9n6S9cQv-F5k_ymX5L1xe2yM85ap8j2f-ffB8p2vS1nlb5ZVMqM7KNS95uVmJZKibttxUJXFeUFe1TZXxhmRRUN4JUZa5SFQtuBCZ4FW2FuusSiXJvC3LNW_KVXfISlhxGqXS3449Ud7PVBfVSqwSLRvS_naju3rRuJl7DyuulQ-vtCRBBU3xSn903NEMrSVvQKwD0qhCdNHdkZT824V-GsjgvHhNmvMCeDI7Xd_z2qswzE0UFsT-QsjyYJOzf9AhgNgvpXgQ-6WavwIAAP__1JQANw">