Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
linux: Improve gdb startup time for debug builds from over 4 minutes …
…to 35s. This change contains two parts, for full-symbol (symbol_level=2, default) and reduced-symbol (symbol_level=1) debug builds. It has no effect on release builds. 1.) For symbol_level=2, pass -Wl,--gdb-index to the linker. This lets the linker write an index that lets it load binaries much faster. gdb startup time for target chrome from goes from 60s to 10s and time from `run` in gdb to the program actually starting from 270s to 45s. In return, this slows down linking a bit, but for target chrome in a debug build, it increases link time from 37s to 42s, which is better than making people who want to use gdb wait several minutes every time they start gdb. There's some history here: We used to pass -Wl,--gdb-index long ago, and then removed it in https://codereview.chromium.org/335903002/, with the recommendation that people who want to use gdb could run build/gdb-add-index. But running `gdb-add-index chrome` takes 73s nowadays, a lot more than the 5s that gold needs. (Back then, gdb-add-index was faster, and gold, due to us not yet defaulting to component builds in debug builds, was slower. Also, people were on an older default Ubuntu and used an older gdb version.) People who don't use gdb should use symbol_level=1 for their builds anyhow (and bots do too), so this small regression in link time shouldn't affect them. Remove the explicit gdb_index gn arg now that this has a good default. 2) For symbol_level=1, make this mode actually work again after the gn swtich. In symbol_level=1 builds, gn would pass `-g1 -gsplit-dwarf` to clang (*). Surprisingly, -gsplit-dwarf implies -g2 with clang, so the -g1 gets overriden by -g2 immediately. Before this, symbol_level=1 in debug builds would produce full debug info. Since all bots set symbol_level=1, this might help with build speed on debug bots. For people who set this locally, it'll also speed up gdb startup time for target chrome from 39s to 13s and time from `run` in gdb to the program actually starting from 255s to 35s. *: clang always writes stack debug info to both .o and .dwo files, and lets the linker link them into the executable, so -g1 -gsplit-dwarf would make no sense. This was used as justification to make -gsplit-dwarf imply -g2, as it otherwise wouldn't have an effect. BUG=374952 Review-Url: https://codereview.chromium.org/2770933009 Cr-Commit-Position: refs/heads/master@{#459790}
- Loading branch information