mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-08 08:44:37 +08:00
Keep the heap census hook out of library archives
Libraries never build the census (heapCensusOf), but the runtime's weak scr_census_write reference made library archives list an external symbol outside their declared set. Declare and call it only in programs.
This commit is contained in:
@@ -225,15 +225,16 @@ static void scr_module_registry_cleanup(void) {
|
||||
* own cleanup only when the value is first materialized. That is equivalent
|
||||
* at process exit and retains the RC-audit cleanup guarantee for the values a
|
||||
* program actually observes. */
|
||||
#if defined(__linux__)
|
||||
#if defined(__linux__) && !defined(SCR_LIB)
|
||||
/* The heap census of a program built with SCRIPTC_HEAP_CENSUS
|
||||
* (heap-census.ts) writes its counters at exit, from here and from
|
||||
* scr_process_exit; every other build leaves the weak reference null. */
|
||||
* scr_process_exit; every other program leaves the weak reference null.
|
||||
* Libraries have no census, and their archives declare no such symbol. */
|
||||
extern void scr_census_write(void) __attribute__((weak));
|
||||
#endif
|
||||
|
||||
static void scr_lib_cleanup(void) {
|
||||
#if defined(__linux__)
|
||||
#if defined(__linux__) && !defined(SCR_LIB)
|
||||
if (scr_census_write != NULL) scr_census_write();
|
||||
#endif
|
||||
scr_module_registry_cleanup();
|
||||
@@ -2147,7 +2148,9 @@ void scr_process_exit(double code) {
|
||||
fflush(stdout);
|
||||
#if defined(__linux__)
|
||||
if (__llvm_profile_write_file != NULL) (void)__llvm_profile_write_file();
|
||||
#ifndef SCR_LIB
|
||||
if (scr_census_write != NULL) scr_census_write();
|
||||
#endif
|
||||
scr_detach_teardown();
|
||||
#endif
|
||||
_Exit((int)code);
|
||||
|
||||
Reference in New Issue
Block a user