Files
tinygo/builder
deadprogram 98b3c27c76 builder: fix SIGSEGV when stripping duplicate function definitions
The previous approach of erasing basic blocks one-by-one from
duplicate function definitions could crash with a segfault. When
a function has complex control flow (branches, switches, PHI nodes),
deleting a basic block that is still referenced by instructions in
other blocks of the same function causes use-after-free in LLVM.

LLVM's C++ Function::deleteBody() avoids this by calling
dropAllReferences() on all blocks first, but that API is not
exposed in the Go LLVM bindings.

Fix this by using a completely different approach: instead of
manually deleting the function body, set the duplicate function's
linkage to LinkOnceODRLinkage. This tells the LLVM linker that the
definition can be merged with another copy, causing it to prefer
the already-linked ExternalLinkage definition in the destination
module. The result is the same (the runtime's definition wins) but
without any unsafe block manipulation.
2026-04-11 12:38:36 +01:00
..
2025-10-03 15:46:25 +02:00
2025-11-24 12:11:47 +01:00
2025-06-13 14:42:23 +02:00
2025-09-17 05:28:06 -04:00
2025-09-17 05:28:06 -04:00
2023-02-26 19:22:10 +01:00
2025-09-17 05:28:06 -04:00
2026-04-11 12:38:36 +01:00
2025-11-24 12:11:47 +01:00
2024-09-24 17:42:30 +01:00
2025-06-13 14:42:23 +02:00
2025-06-13 14:42:23 +02:00
2025-06-13 14:42:23 +02:00
2025-06-13 14:42:23 +02:00
2024-12-19 15:08:37 +01:00
2025-06-13 14:42:23 +02:00
2025-06-13 14:42:23 +02:00