From 60a3f0667f7bffcc1667396f3aa1fc891dcba3a0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 31 Jan 2023 07:30:51 -0500 Subject: [PATCH] radeonsi: call ac_init_llvm_once before any util_queue initialization The winsys uses util_queue, which calls atexit, so do it before the winsys is created. Cc: stable Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_pipe.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index ea1f00e..e753a45 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -148,8 +148,6 @@ bool si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compil (sscreen->debug_flags & DBG(CHECK_IR) ? AC_TM_CHECK_IR : 0) | (create_low_opt_compiler ? AC_TM_CREATE_LOW_OPT : 0); - ac_init_llvm_once(); - if (!ac_init_llvm_compiler(compiler, sscreen->info.family, tm_options)) return false; @@ -1490,6 +1488,14 @@ struct pipe_screen *radeonsi_screen_create(int fd, const struct pipe_screen_conf if (!version) return NULL; + /* LLVM must be initialized before util_queue because both u_queue and LLVM call atexit, + * and LLVM must call it first because its atexit handler executes C++ destructors, + * which must be done after our compiler threads using LLVM in u_queue are finished + * by their atexit handler. Since atexit handlers are called in the reverse order, + * LLVM must be initialized first, followed by u_queue. + */ + ac_init_llvm_once(); + driParseConfigFiles(config->options, config->options_info, 0, "radeonsi", NULL, NULL, NULL, 0, NULL, 0); -- 2.7.4