ac/llvm: handle static/shared llvm init separately

Having a single init function works as expected for shared llvm, but
when using a static llvm only one llvm will get initialized.

This commit introduces 2 separate init function:
- shared llvm = single public init function
- static llvm = one init function for each module using llvm

Fixes: 50d20dc055 ("ac/llvm: export ac_init_llvm_once in targets")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3376
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6253>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2020-08-10 10:16:39 +02:00 committed by Marge Bot
parent 916110e17f
commit b7c04b1790
11 changed files with 28 additions and 9 deletions

View File

@ -97,7 +97,7 @@ endif
define mesa-build-with-llvm
$(if $(filter $(MESA_ANDROID_MAJOR_VERSION), 4 5 6 7), \
$(warning Unsupported LLVM version in Android $(MESA_ANDROID_MAJOR_VERSION)),) \
$(eval LOCAL_CFLAGS += -DLLVM_AVAILABLE -DMESA_LLVM_VERSION_STRING=\"3.9\") \
$(eval LOCAL_CFLAGS += -DLLVM_AVAILABLE -DLLVM_IS_SHARED=1 -DMESA_LLVM_VERSION_STRING=\"3.9\") \
$(eval LOCAL_SHARED_LIBRARIES += libLLVM)
endef

View File

@ -1513,6 +1513,7 @@ endif
if with_llvm
pre_args += '-DLLVM_AVAILABLE'
pre_args += '-DMESA_LLVM_VERSION_STRING="@0@"'.format(dep_llvm.version())
pre_args += '-DLLVM_IS_SHARED=@0@'.format(_shared_llvm.to_int())
# LLVM can be built without rtti, turning off rtti changes the ABI of C++
# programs, so we need to build all C++ code in mesa without rtti as well to

View File

@ -78,12 +78,29 @@ static void ac_init_llvm_target()
LLVMParseCommandLineOptions(ARRAY_SIZE(argv), argv, NULL);
}
PUBLIC void ac_init_llvm_once(void)
PUBLIC void ac_init_shared_llvm_once(void)
{
static once_flag ac_init_llvm_target_once_flag = ONCE_FLAG_INIT;
call_once(&ac_init_llvm_target_once_flag, ac_init_llvm_target);
}
#if !LLVM_IS_SHARED
static once_flag ac_init_static_llvm_target_once_flag = ONCE_FLAG_INIT;
static void ac_init_static_llvm_once(void)
{
call_once(&ac_init_static_llvm_target_once_flag, ac_init_llvm_target);
}
#endif
void ac_init_llvm_once(void)
{
#if LLVM_IS_SHARED
ac_init_shared_llvm_once();
#else
ac_init_static_llvm_once();
#endif
}
static LLVMTargetRef ac_get_llvm_target(const char *triple)
{
LLVMTargetRef target = NULL;

View File

@ -131,6 +131,7 @@ ac_count_scratch_private_memory(LLVMValueRef function);
LLVMTargetLibraryInfoRef ac_create_target_library_info(const char *triple);
void ac_dispose_target_library_info(LLVMTargetLibraryInfoRef library_info);
void ac_init_shared_llvm_once(void); /* Do not use directly, use ac_init_llvm_once */
void ac_init_llvm_once(void);

View File

@ -176,7 +176,7 @@ if with_symbols_check
args : [
'--lib', libvulkan_radeon,
'--symbols-file', vulkan_icd_symbols,
'--ignore-symbol', 'ac_init_llvm_once',
'--ignore-symbol', 'ac_init_shared_llvm_once',
symbols_check_args,
],
suite : ['amd'],

View File

@ -2,5 +2,5 @@
nouveau_drm_screen_create;
radeon_drm_winsys_create;
amdgpu_winsys_create;
ac_init_llvm_once;
ac_init_shared_llvm_once;
};

View File

@ -6,7 +6,7 @@
radeon_drm_winsys_create;
amdgpu_winsys_create;
fd_drm_screen_create;
ac_init_llvm_once;
ac_init_shared_llvm_once;
local:
*;
};

View File

@ -7,7 +7,7 @@
# due to LLVM being initialized multiple times.
radeon_drm_winsys_create;
amdgpu_winsys_create;
ac_init_llvm_once;
ac_init_shared_llvm_once;
local:
*;
};

View File

@ -7,7 +7,7 @@
# due to LLVM being initialized multiple times.
radeon_drm_winsys_create;
amdgpu_winsys_create;
ac_init_llvm_once;
ac_init_shared_llvm_once;
local:
*;
};

View File

@ -6,7 +6,7 @@
# due to LLVM being initialized multiple times.
radeon_drm_winsys_create;
amdgpu_winsys_create;
ac_init_llvm_once;
ac_init_shared_llvm_once;
local:
*;
};

View File

@ -4,7 +4,7 @@
nouveau_drm_screen_create;
radeon_drm_winsys_create;
amdgpu_winsys_create;
ac_init_llvm_once;
ac_init_shared_llvm_once;
local:
*;
};