Skip to content

Commit 2d40ba1

Browse files
authored
cgen: call GC_INIT in sokol_main too, when compiling with -apk (#14869)
1 parent b1a14c6 commit 2d40ba1

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

vlib/v/gen/c/cmain.v

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,23 @@ void (_vsokol_cleanup_userdata_cb)(void* user_data) {
138138
}
139139
g.writeln('// The sokol_main entry point on Android
140140
sapp_desc sokol_main(int argc, char* argv[]) {
141-
(void)argc; (void)argv;
141+
(void)argc; (void)argv;')
142142

143-
_vinit(argc, (voidptr)argv);
143+
if g.pref.gc_mode in [.boehm_full, .boehm_incr, .boehm_full_opt, .boehm_incr_opt, .boehm_leak] {
144+
g.writeln('#if defined(_VGCBOEHM)')
145+
if g.pref.gc_mode == .boehm_leak {
146+
g.writeln('\tGC_set_find_leak(1);')
147+
}
148+
g.writeln('\tGC_set_pages_executable(0);')
149+
g.writeln('\tGC_INIT();')
150+
if g.pref.gc_mode in [.boehm_incr, .boehm_incr_opt] {
151+
g.writeln('\tGC_enable_incremental();')
152+
}
153+
g.writeln('#endif')
154+
}
155+
g.writeln('\t_vinit(argc, (voidptr)argv);
144156
')
157+
145158
g.gen_c_main_profile_hook()
146159
g.writeln('\tmain__main();')
147160
if g.is_autofree {

0 commit comments

Comments
 (0)