From eff1517cd7b07450bc75fed03e13dfd621fa299f Mon Sep 17 00:00:00 2001 From: Luis Felipe Strano Moraes Date: Tue, 18 Oct 2022 17:48:55 -0700 Subject: [PATCH] anv: added proper handling for input argument in intel_clc That was previously listed on the getopt_long struct but not actually being used. This makes intel_clc argument processing easier as now all of its arguments are handled with getopt and anything after the special argument '--' is passed along to clang to form the final build command. Thanks to Dylan Baker for help with changes to the meson file. Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/compiler/intel_clc.c | 13 +++++++------ src/intel/vulkan/grl/meson.build | 8 ++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/intel/compiler/intel_clc.c b/src/intel/compiler/intel_clc.c index d6ed077616c..4a56eef2df1 100644 --- a/src/intel/compiler/intel_clc.c +++ b/src/intel/compiler/intel_clc.c @@ -258,13 +258,14 @@ static void print_usage(char *exec_name, FILE *f) { fprintf(f, -"Usage: %s [options] -- [clang args | input file]\n" +"Usage: %s [options] -- [clang args]\n" "Options:\n" " -h --help Print this help.\n" " -e, --entrypoint Specify the entry-point name.\n" " -p, --platform Specify the target platform name.\n" " --prefix Prefix for variable names in generated C code.\n" " -o, --out Specify the output filename.\n" +" -i, --in Specify one input filename. Accepted multiple times.\n" " -s, --spv Specify the output filename for spirv.\n" " -v, --verbose Print more information during compilation.\n" , exec_name); @@ -319,7 +320,7 @@ int main(int argc, char **argv) util_dynarray_init(&spirv_ptr_objs, mem_ctx); int ch; - while ((ch = getopt_long(argc, argv, "he:p:s:o:v", long_options, NULL)) != -1) + while ((ch = getopt_long(argc, argv, "he:p:s:i:o:v", long_options, NULL)) != -1) { switch (ch) { @@ -335,6 +336,9 @@ int main(int argc, char **argv) case 'o': outfile = optarg; break; + case 'i': + util_dynarray_append(&input_files, char *, optarg); + break; case 's': spv_outfile = optarg; break; @@ -352,10 +356,7 @@ int main(int argc, char **argv) } for (int i = optind; i < argc; i++) { - if (argv[i][0] == '-') - util_dynarray_append(&clang_args, char *, argv[i]); - else - util_dynarray_append(&input_files, char *, argv[i]); + util_dynarray_append(&clang_args, char *, argv[i]); } if (util_dynarray_num_elements(&input_files, char *) == 0) { diff --git a/src/intel/vulkan/grl/meson.build b/src/intel/vulkan/grl/meson.build index 8a67e75a365..979414c07c1 100644 --- a/src/intel/vulkan/grl/meson.build +++ b/src/intel/vulkan/grl/meson.build @@ -122,6 +122,10 @@ foreach t : [['125', 'gfx125', 'dg2']] input_args += [ lib_file ] endforeach endif + prepended_input_args = [] + foreach input_arg : input_args + prepended_input_args += ['--in', input_arg] + endforeach outfile = kernel_prefix + '.h' grl_compiled_cl_kernels += custom_target( outfile, @@ -129,12 +133,12 @@ foreach t : [['125', 'gfx125', 'dg2']] output : outfile, command : [ prog_intel_clc, '-p', platform, '--prefix', kernel_prefix, - '-e', entrypoint, input_args, '-o', '@OUTPUT@', '--', + '-e', entrypoint, prepended_input_args, '-o', '@OUTPUT@', '--', '-cl-std=cl2.0', '-D__OPENCL_VERSION__=200', '-DMAX_HW_SIMD_WIDTH=16', '-DMAX_WORKGROUP_SIZE=16', '-I' + join_paths(meson.current_source_dir(), 'gpu'), '-I' + join_paths(meson.current_source_dir(), 'include'), - '-include' + 'opencl-c.h', # added to bypass build failure from clang15 + '-include', 'opencl-c.h', # added to bypass build failure from clang15 # without modifying grl source code, remove # if fixed there ],