ac: reset LLVM command line parser
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Wed, 18 May 2022 15:49:07 +0000 (17:49 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 25 May 2022 12:03:34 +0000 (12:03 +0000)
commit7e2874dc93acbde89b89e353bc7e9e07fe69af20
treeee0c009d65ba8e9dbf0b09456ac90e719610137a
parent2172ddf2bff59f9ea9f3dfa4bcd4125905210768
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@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16587>
src/amd/llvm/ac_llvm_util.c