Mesa (main): ac: reset LLVM command line parser

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 25 12:28:36 UTC 2022


Module: Mesa
Branch: main
Commit: 7e2874dc93acbde89b89e353bc7e9e07fe69af20
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7e2874dc93acbde89b89e353bc7e9e07fe69af20

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Wed May 18 17:49:07 2022 +0200

ac: reset LLVM command line parser

In some scenario ac_init_llvm_target may be called twice,
but the LLVM library won't have been unloaded between
the 2 calls, leading to a LLVM warning being printed.

Example pseudo-code to trigger this for radeonsi:
   gbm_create_device();
   eglInitialize();
   eglTerminate();
   gbm_device_destroy();
   gbm_create_device();
   eglInitialize();
   eglTerminate();
   gbm_device_destroy();

To avoid the warning message from LLVM, clear the command line
parser state before calling LLVMParseCommandLineOptions.

This might fix https://gitlab.freedesktop.org/mesa/mesa/-/issues/5960

This is done only on LLVM 12+ because it seems to break some apps
on LLVM 11 (there has been some work post LLVM 11 release to refactor
CommandLine.cpp, see 42f588f39c5c and the following commits).

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16587>

---

 src/amd/llvm/ac_llvm_util.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/amd/llvm/ac_llvm_util.c b/src/amd/llvm/ac_llvm_util.c
index 720f2135a22..e4688933cc9 100644
--- a/src/amd/llvm/ac_llvm_util.c
+++ b/src/amd/llvm/ac_llvm_util.c
@@ -61,6 +61,10 @@ static void ac_init_llvm_target(void)
       "-structurizecfg-skip-uniform-regions",
 #endif
    };
+
+#if LLVM_VERSION_MAJOR > 11
+   ac_reset_llvm_command_line_parser();
+#endif
    LLVMParseCommandLineOptions(ARRAY_SIZE(argv), argv, NULL);
 }
 



More information about the mesa-commit mailing list