mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-09-14 15:03:27 -04:00
https://github.com/lightpanda-io/browser/pull/3271 introduce an orderfile so that hot sections of code were grouped together in the binary, resulting in more efficient loading. But, it excluded v8 functions because v8 is compiled with `-fno-unique-section-names` so each section gets the same name. Because of this the orderfile can't target specific "hot" or "cold" functions. As a follow up to 3271, I thought we'd be able to re-compile v8 without that flag, but: 1 - The flag isn't directly exposed by v8, so we'd need to change v8's own build BUILD.gn in our build process 2 - It would make the .a file ~ 40MB larger (though the final lightpanda binary would stay the same size 3 - If we wanted to created two .a files (one with -fno-unique-section-names and one without), it would require a full rebuild (for both x86-64 and arm). I didn't love those compromises, so I asked Claude if the sections names could be generated in a separate file and then that could be used when generating out lightpanda.ld. What claude came up with was a small Zig script (mark_hot_sections.zig) which is now run as part of the build. It takes the v8.a file (which still has `-fno-unique-section-names`), it takes a text list of hot functions, and it re-generates v8.a with a special .text.hot and .rodata.hot sections. lightpanda.ld can include these. This PR depends on https://github.com/lightpanda-io/zig-v8-fork/pull/202 but 202 doesn't require a v8 rebuild. It merely allows prebuilt_v8_path to be a lazypath, which we need because the prebuilt_v8_path that we pass is now generated from this build script.