radv/r600/clover: Getting libelf to be optional

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18503>
This commit is contained in:
Yonggang Luo 2022-09-20 23:10:22 +08:00 committed by Marge Bot
parent 3f18709f1f
commit c74595ead3
10 changed files with 23 additions and 32 deletions

View file

@ -613,7 +613,6 @@ debian-mingw32-x86_64:
GALLIUM_ST: > GALLIUM_ST: >
-D gallium-opencl=icd -D gallium-opencl=icd
-D gallium-rusticl=false -D gallium-rusticl=false
-D opencl-native=false
-D opencl-spirv=true -D opencl-spirv=true
-D microsoft-clc=enabled -D microsoft-clc=enabled
-D static-libclc=all -D static-libclc=all

View file

@ -51,6 +51,9 @@ meson `
-Dgallium-drivers="swrast,d3d12,zink" ` -Dgallium-drivers="swrast,d3d12,zink" `
-Dshared-glapi=enabled ` -Dshared-glapi=enabled `
-Dgles2=enabled ` -Dgles2=enabled `
-Dgallium-opencl=icd `
-Dgallium-rusticl=false `
-Dopencl-spirv=true `
-Dmicrosoft-clc=enabled ` -Dmicrosoft-clc=enabled `
-Dstatic-libclc=all ` -Dstatic-libclc=all `
-Dspirv-to-dxil=true ` -Dspirv-to-dxil=true `

View file

@ -1903,17 +1903,12 @@ if host_machine.system() == 'windows'
dep_version = cpp.find_library('version') dep_version = cpp.find_library('version')
endif endif
with_opencl_native = _opencl != 'disabled' and get_option('opencl-native')
if (with_amd_vk or with_gallium_radeonsi or
(with_gallium_opencl and with_opencl_native) or
(with_gallium_r600 and with_llvm))
dep_elf = dependency('libelf', required : false) dep_elf = dependency('libelf', required : false)
if not with_platform_windows and not dep_elf.found() if not with_platform_windows and not dep_elf.found()
dep_elf = cc.find_library('elf') dep_elf = cc.find_library('elf')
endif endif
else if dep_elf.found()
dep_elf = null_dep pre_args += '-DUSE_LIBELF'
endif endif
dep_glvnd = null_dep dep_glvnd = null_dep

View file

@ -181,12 +181,6 @@ option(
value : false, value : false,
description : 'build gallium "clover" OpenCL frontend with SPIR-V binary support.', description : 'build gallium "clover" OpenCL frontend with SPIR-V binary support.',
) )
option(
'opencl-native',
type : 'boolean',
value : true,
description : 'build gallium "clover" OpenCL frontend with native LLVM codegen support.',
)
option( option(
'static-libclc', 'static-libclc',
type : 'array', type : 'array',

View file

@ -965,7 +965,7 @@ static void ac_sqtt_dump_spm(const struct ac_spm_trace_data *spm_trace,
fseek(output, file_offset, SEEK_SET); fseek(output, file_offset, SEEK_SET);
} }
#ifndef _WIN32 #if defined(USE_LIBELF)
static void ac_sqtt_dump_data(struct radeon_info *rad_info, static void ac_sqtt_dump_data(struct radeon_info *rad_info,
struct ac_thread_trace *thread_trace, struct ac_thread_trace *thread_trace,
const struct ac_spm_trace_data *spm_trace, const struct ac_spm_trace_data *spm_trace,
@ -1158,7 +1158,7 @@ int ac_dump_rgp_capture(struct radeon_info *info,
struct ac_thread_trace *thread_trace, struct ac_thread_trace *thread_trace,
const struct ac_spm_trace_data *spm_trace) const struct ac_spm_trace_data *spm_trace)
{ {
#ifdef _WIN32 #if !defined(USE_LIBELF)
return -1; return -1;
#else #else
char filename[2048]; char filename[2048];

View file

@ -102,7 +102,7 @@ amd_common_files = files(
'ac_perfcounter.h', 'ac_perfcounter.h',
) )
if not with_platform_windows if dep_elf.found()
amd_common_files += files( amd_common_files += files(
'ac_rtld.c', 'ac_rtld.c',
'ac_rtld.h', 'ac_rtld.h',

View file

@ -41,7 +41,7 @@
#include "util/debug.h" #include "util/debug.h"
#include "ac_binary.h" #include "ac_binary.h"
#include "ac_nir.h" #include "ac_nir.h"
#ifndef _WIN32 #if defined(USE_LIBELF)
#include "ac_rtld.h" #include "ac_rtld.h"
#endif #endif
#include "aco_interface.h" #include "aco_interface.h"
@ -1955,7 +1955,7 @@ radv_postprocess_config(const struct radv_device *device, const struct ac_shader
} }
} }
#ifndef _WIN32 #if defined(USE_LIBELF)
static bool static bool
radv_open_rtld_binary(struct radv_device *device, const struct radv_shader *shader, radv_open_rtld_binary(struct radv_device *device, const struct radv_shader *shader,
const struct radv_shader_binary *binary, struct ac_rtld_binary *rtld_binary) const struct radv_shader_binary *binary, struct ac_rtld_binary *rtld_binary)
@ -2006,7 +2006,7 @@ radv_shader_binary_upload(struct radv_device *device, const struct radv_shader_b
struct radv_shader *shader, void *dest_ptr) struct radv_shader *shader, void *dest_ptr)
{ {
if (binary->type == RADV_BINARY_TYPE_RTLD) { if (binary->type == RADV_BINARY_TYPE_RTLD) {
#ifdef _WIN32 #if !defined(USE_LIBELF)
return false; return false;
#else #else
struct ac_rtld_binary rtld_binary = {0}; struct ac_rtld_binary rtld_binary = {0};
@ -2059,7 +2059,7 @@ radv_shader_create(struct radv_device *device, struct radv_shader_binary *binary
shader->binary = binary; shader->binary = binary;
if (binary->type == RADV_BINARY_TYPE_RTLD) { if (binary->type == RADV_BINARY_TYPE_RTLD) {
#ifdef _WIN32 #if !defined(USE_LIBELF)
free(shader); free(shader);
return NULL; return NULL;
#else #else
@ -2110,7 +2110,7 @@ radv_shader_create(struct radv_device *device, struct radv_shader_binary *binary
} }
if (binary->type == RADV_BINARY_TYPE_RTLD) { if (binary->type == RADV_BINARY_TYPE_RTLD) {
#ifdef _WIN32 #if !defined(USE_LIBELF)
free(shader); free(shader);
return NULL; return NULL;
#else #else

View file

@ -190,7 +190,11 @@ egd_tables_h = custom_target(
r600_c_args = [] r600_c_args = []
if with_gallium_opencl if with_gallium_opencl
if dep_elf.found()
r600_c_args += '-DHAVE_OPENCL' r600_c_args += '-DHAVE_OPENCL'
else
warning('r600 requires libelf to support opencl.')
endif
endif endif
r600_cpp_args = [] r600_cpp_args = []

View file

@ -40,7 +40,7 @@ using clover::build_error;
using namespace clover::llvm; using namespace clover::llvm;
using ::llvm::TargetMachine; using ::llvm::TargetMachine;
#ifdef HAVE_CLOVER_NATIVE #if defined(USE_LIBELF)
#include <libelf.h> #include <libelf.h>
#include <gelf.h> #include <gelf.h>

View file

@ -44,10 +44,6 @@ if with_opencl_icd
clover_cpp_args += '-DHAVE_CLOVER_ICD' clover_cpp_args += '-DHAVE_CLOVER_ICD'
endif endif
if with_opencl_native
clover_spirv_cpp_args += '-DHAVE_CLOVER_NATIVE'
endif
if with_opencl_spirv if with_opencl_spirv
clover_spirv_cpp_args += '-DHAVE_CLOVER_SPIRV' clover_spirv_cpp_args += '-DHAVE_CLOVER_SPIRV'
endif endif