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 <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19153>
This commit is contained in:
Luis Felipe Strano Moraes
2022-10-18 17:48:55 -07:00
committed by Marge Bot
parent 8de02ff980
commit eff1517cd7
2 changed files with 13 additions and 8 deletions

View File

@@ -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 <name> Specify the entry-point name.\n"
" -p, --platform <name> Specify the target platform name.\n"
" --prefix <prefix> Prefix for variable names in generated C code.\n"
" -o, --out <filename> Specify the output filename.\n"
" -i, --in <filename> Specify one input filename. Accepted multiple times.\n"
" -s, --spv <filename> 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) {

View File

@@ -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
],