diff --git a/packages/runtime/src/scr_lib.c b/packages/runtime/src/scr_lib.c index df36f063e2..ad42a5824c 100644 --- a/packages/runtime/src/scr_lib.c +++ b/packages/runtime/src/scr_lib.c @@ -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);