Re: [Mesa-dev] [PATCH v5] clover: Introduce CLOVER_EXTRA_{COMPILER, LINKER}_OPTIONS

2016-09-19 Thread Francisco Jerez
Vedran Miletić  writes:

> The options specified in the CLOVER_EXTRA_COMPILER_OPTIONS shell
> variable are appended to the compiler options specified by the OpenCL
> program, if any.
> Analogously, the options specified in the CLOVER_EXTRA_LINKER_OPTIONS
> variable are appended to the linker options and the options spoecified
> in the CLOVER_EXTRA_COMPILER_OPTIONS variable.
>
> v2:
>  * rename to CLOVER_EXTRA_COMPILER_OPTIONS
>  * use debug_get_option
>  * append to linker options as well
>
> v3: code cleanups
>
> v4: separate CLOVER_EXTRA_LINKER_OPTIONS options
>
> v5:
>  * fix documentation typo
>  *use CLOVER_EXTRA_COMPILER_OPTIONS in link stage
>
> Signed-off-by: Vedran Miletić 
> Reviewed-by[v1]: Edward O'Callaghan 
> ---
>  docs/envvars.html | 13 +
>  src/gallium/state_trackers/clover/llvm/invocation.cpp | 11 ---
>  2 files changed, 21 insertions(+), 3 deletions(-)
>
> diff --git a/docs/envvars.html b/docs/envvars.html
> index cf57ca5..252b783 100644
> --- a/docs/envvars.html
> +++ b/docs/envvars.html
> @@ -235,6 +235,19 @@ Setting to "tgsi", for example, will print all the TGSI 
> shaders.
>  See src/mesa/state_tracker/st_debug.c for other options.
>  
>  
> +Clover state tracker environment variables
> +
> +
> +CLOVER_EXTRA_COMPILER_OPTIONS - allows specifying additional compiler
> +options. Specified options are appended after the options set by the 
> OpenCL
> +program in clBuildProgram and/or clCompileProgram.
> +CLOVER_EXTRA_LINKER_OPTIONS - allows specifying additional linker
> +options. Specified options are appended after the options set by the 
> OpenCL
> +linker in clBuildProgram and/or clLinkProgram and options set in the
> +CLOVER_EXTRA_COMPILER_OPTIONS variable.
> +
> +
> +
>  Softpipe driver environment variables
>  
>  SOFTPIPE_DUMP_FS - if set, the softpipe driver will print fragment 
> shaders
> diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
> b/src/gallium/state_trackers/clover/llvm/invocation.cpp
> index b5e8b52..68b9d2e 100644
> --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
> +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
> @@ -199,11 +199,13 @@ clover::llvm::compile_program(const std::string ,
>const std::string ,
>const std::string ,
>std::string _log) {
> +   const std::string all_opts = opts + " " +
> + debug_get_option("CLOVER_EXTRA_COMPILER_OPTIONS", 
> "");
> if (has_flag(debug::clc))
> -  debug::log(".cl", "// Options: " + opts + '\n' + source);
> +  debug::log(".cl", "// Options: " + all_opts + '\n' + source);
>  
> auto ctx = create_context(r_log);
> -   auto c = create_compiler_instance(target, tokenize(opts + " input.cl"),
> +   auto c = create_compiler_instance(target, tokenize(all_opts + " 
> input.cl"),
>   r_log);
> auto mod = compile(*ctx, *c, "input.cl", source, headers, target, opts,
>r_log);
> @@ -266,7 +268,10 @@ module
>  clover::llvm::link_program(const std::vector ,
> enum pipe_shader_ir ir, const std::string ,
> const std::string , std::string _log) {
> -   std::vector options = tokenize(opts + " input.cl");
> +   const std::string all_opts = opts + " " +
> + debug_get_option("CLOVER_EXTRA_COMPILER_OPTIONS", 
> "") +
> + debug_get_option("CLOVER_EXTRA_LINKER_OPTIONS", "");

Why do you concatenate the two?  I thought the reason Jan suggested
splitting this was that a bunch of compiler options are invalid as
linker options or the other way around?

> +   std::vector options = tokenize(all_opts + " input.cl");
> const bool create_library = count("-create-library", options);
> erase_if(equals("-create-library"), options);
>  
> -- 
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


signature.asc
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v5] clover: Introduce CLOVER_EXTRA_{COMPILER, LINKER}_OPTIONS

2016-09-19 Thread Vedran Miletić
The options specified in the CLOVER_EXTRA_COMPILER_OPTIONS shell
variable are appended to the compiler options specified by the OpenCL
program, if any.
Analogously, the options specified in the CLOVER_EXTRA_LINKER_OPTIONS
variable are appended to the linker options and the options spoecified
in the CLOVER_EXTRA_COMPILER_OPTIONS variable.

v2:
 * rename to CLOVER_EXTRA_COMPILER_OPTIONS
 * use debug_get_option
 * append to linker options as well

v3: code cleanups

v4: separate CLOVER_EXTRA_LINKER_OPTIONS options

v5:
 * fix documentation typo
 *use CLOVER_EXTRA_COMPILER_OPTIONS in link stage

Signed-off-by: Vedran Miletić 
Reviewed-by[v1]: Edward O'Callaghan 
---
 docs/envvars.html | 13 +
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 11 ---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/docs/envvars.html b/docs/envvars.html
index cf57ca5..252b783 100644
--- a/docs/envvars.html
+++ b/docs/envvars.html
@@ -235,6 +235,19 @@ Setting to "tgsi", for example, will print all the TGSI 
shaders.
 See src/mesa/state_tracker/st_debug.c for other options.
 
 
+Clover state tracker environment variables
+
+
+CLOVER_EXTRA_COMPILER_OPTIONS - allows specifying additional compiler
+options. Specified options are appended after the options set by the OpenCL
+program in clBuildProgram and/or clCompileProgram.
+CLOVER_EXTRA_LINKER_OPTIONS - allows specifying additional linker
+options. Specified options are appended after the options set by the OpenCL
+linker in clBuildProgram and/or clLinkProgram and options set in the
+CLOVER_EXTRA_COMPILER_OPTIONS variable.
+
+
+
 Softpipe driver environment variables
 
 SOFTPIPE_DUMP_FS - if set, the softpipe driver will print fragment shaders
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index b5e8b52..68b9d2e 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -199,11 +199,13 @@ clover::llvm::compile_program(const std::string ,
   const std::string ,
   const std::string ,
   std::string _log) {
+   const std::string all_opts = opts + " " +
+ debug_get_option("CLOVER_EXTRA_COMPILER_OPTIONS", "");
if (has_flag(debug::clc))
-  debug::log(".cl", "// Options: " + opts + '\n' + source);
+  debug::log(".cl", "// Options: " + all_opts + '\n' + source);
 
auto ctx = create_context(r_log);
-   auto c = create_compiler_instance(target, tokenize(opts + " input.cl"),
+   auto c = create_compiler_instance(target, tokenize(all_opts + " input.cl"),
  r_log);
auto mod = compile(*ctx, *c, "input.cl", source, headers, target, opts,
   r_log);
@@ -266,7 +268,10 @@ module
 clover::llvm::link_program(const std::vector ,
enum pipe_shader_ir ir, const std::string ,
const std::string , std::string _log) {
-   std::vector options = tokenize(opts + " input.cl");
+   const std::string all_opts = opts + " " +
+ debug_get_option("CLOVER_EXTRA_COMPILER_OPTIONS", "") 
+
+ debug_get_option("CLOVER_EXTRA_LINKER_OPTIONS", "");
+   std::vector options = tokenize(all_opts + " input.cl");
const bool create_library = count("-create-library", options);
erase_if(equals("-create-library"), options);
 
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev