Message ID | 20151210175207.GF3534@virgil.suse.cz |
---|---|
State | New |
Headers | show |
On Thu, Dec 10, 2015 at 06:52:07PM +0100, Martin Jambor wrote: > Good catch. I have modified this code so that it never leaves any > holes in offload_names[i]. > > > names[i] is null-terminated, so it looks like you're deliberately > > allowing anything that starts with "hsa" here, but: > > Right, and that was probably a mistake, I have changed the check to > simple strcmp. LGTM (and thanks for Richard for reviewing that). > 2015-12-09 Martin Jambor <mjambor@suse.cz> > > * lto-wrapper.c (compile_images_for_offload_targets): Do not leave > holes in offload_names. Use strcmp instead strncmp. > * doc/install.texi (--with-hsa-runtime): Fix typo. > --- > gcc/doc/install.texi | 2 +- > gcc/lto-wrapper.c | 8 +++++--- > 2 files changed, 6 insertions(+), 4 deletions(-) > > diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi > index afd891c..a85a063 100644 > --- a/gcc/doc/install.texi > +++ b/gcc/doc/install.texi > @@ -1993,7 +1993,7 @@ compiler will emit the accelerator code, no path should be specified. > > If you configure GCC with HSA offloading but do not have the HSA > run-time library installed in a standard location then you can > -explicitely specify the directory where they are installed. The > +explicitly specify the directory where they are installed. The > @option{--with-hsa-runtime=@/@var{hsainstalldir}} option is a > shorthand for > @option{--with-hsa-runtime-lib=@/@var{hsainstalldir}/lib} and > diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c > index 5609207..5b58fd6 100644 > --- a/gcc/lto-wrapper.c > +++ b/gcc/lto-wrapper.c > @@ -736,6 +736,7 @@ compile_images_for_offload_targets (unsigned in_argc, char *in_argv[], > return; > unsigned num_targets = parse_env_var (target_names, &names, NULL); > > + int next_name_entry = 0; > const char *compiler_path = getenv ("COMPILER_PATH"); > if (!compiler_path) > goto out; > @@ -747,16 +748,17 @@ compile_images_for_offload_targets (unsigned in_argc, char *in_argv[], > { > /* HSA does not use LTO-like streaming and a different compiler, skip > it. */ > - if (strncmp(names[i], "hsa", 3) == 0) > + if (strcmp (names[i], "hsa") == 0) > continue; > > - offload_names[i] > + offload_names[next_name_entry] > = compile_offload_image (names[i], compiler_path, in_argc, in_argv, > compiler_opts, compiler_opt_count, > linker_opts, linker_opt_count); > - if (!offload_names[i]) > + if (!offload_names[next_name_entry]) > fatal_error (input_location, > "problem with building target image for %s\n", names[i]); > + next_name_entry++; > } > > out: > -- > 2.6.3 Jakub
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index afd891c..a85a063 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -1993,7 +1993,7 @@ compiler will emit the accelerator code, no path should be specified. If you configure GCC with HSA offloading but do not have the HSA run-time library installed in a standard location then you can -explicitely specify the directory where they are installed. The +explicitly specify the directory where they are installed. The @option{--with-hsa-runtime=@/@var{hsainstalldir}} option is a shorthand for @option{--with-hsa-runtime-lib=@/@var{hsainstalldir}/lib} and diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c index 5609207..5b58fd6 100644 --- a/gcc/lto-wrapper.c +++ b/gcc/lto-wrapper.c @@ -736,6 +736,7 @@ compile_images_for_offload_targets (unsigned in_argc, char *in_argv[], return; unsigned num_targets = parse_env_var (target_names, &names, NULL); + int next_name_entry = 0; const char *compiler_path = getenv ("COMPILER_PATH"); if (!compiler_path) goto out; @@ -747,16 +748,17 @@ compile_images_for_offload_targets (unsigned in_argc, char *in_argv[], { /* HSA does not use LTO-like streaming and a different compiler, skip it. */ - if (strncmp(names[i], "hsa", 3) == 0) + if (strcmp (names[i], "hsa") == 0) continue; - offload_names[i] + offload_names[next_name_entry] = compile_offload_image (names[i], compiler_path, in_argc, in_argv, compiler_opts, compiler_opt_count, linker_opts, linker_opt_count); - if (!offload_names[i]) + if (!offload_names[next_name_entry]) fatal_error (input_location, "problem with building target image for %s\n", names[i]); + next_name_entry++; } out: