[Mesa-dev] Meson links with duplicate symbols

2020-03-06 Thread Jose Fonseca
While reviewing my colleagues efforts to consume Meson for Windows I stumbled 
across two issues.

First is that even though we added the "WARNING: Scons support is in the 
process of being deprecated on on windows platforms (including mingw). If you 
haven't already please try using meson for windows builds. Be sure to report 
any issues you run into" to scons, we didn't update mesa/docs/install.html with 
instructions on how to build Meson w/ Mingw for windows, so it's not obvious to 
a newbie how to do it.  It took me quite a while to reverse engineer the stuff 
in .gitlab-ci/... till I figured out the way to do it.  I think that adding 
example command lines would go a long way.

Second and most important is that Meson is actually linking with duplicate 
symbols.  This was being hidden because meson doesn't use whole linking for 
everything, whereas SCons does.  It's easy to repro:

$ git diff
diff --git a/src/gallium/targets/libgl-gdi/meson.build 
b/src/gallium/targets/libgl-gdi/meson.build
index cd4e02d1fa9..fb8a42439c8 100644
--- a/src/gallium/targets/libgl-gdi/meson.build
+++ b/src/gallium/targets/libgl-gdi/meson.build
@@ -33,10 +33,8 @@ libopengl32 = shared_library(
   include_directories : [
 inc_common, inc_wgl, inc_gallium_winsys_sw, inc_gallium_drivers,
   ],
-  link_whole : [libwgl],
-  link_with : [
-libgallium, libglsl, libmesa_gallium, libwsgdi, libglapi_static, libglapi
-  ],
+  link_whole : [libwgl, libgallium, libglsl, libmesa_gallium, libwsgdi, 
libglapi_static, libglapi],
+  link_with : [],
   dependencies : [
 dep_ws2_32, idep_nir, idep_mesautil, driver_swrast, driver_swr,
   ],
$ meson --cross .gitlab-ci/x86_64-w64-mingw32 . build/meson-windows-x86_64-debug
$ ninja -C build/meson-windows-x86_64-debug/
ninja: Entering directory `build/meson-windows-x86_64-debug/'
[2/2] Linking target src/gallium/targets/libgl-gdi/opengl32.dll.
FAILED: src/gallium/targets/libgl-gdi/opengl32.dll
x86_64-w64-mingw32-g++  -o src/gallium/targets/libgl-gdi/opengl32.dll 
'src/gallium/targets/libgl-gdi/c96d1e6@@opengl32@sha/libgl_gdi.c.obj' 
-Wl,--allow-shlib-undefined -shared 
../../src/gallium/targets/libgl-gdi/../../state_trackers/wgl/opengl32.def 
-Wl,--start-group -Wl,--out-implib=src/gallium/targets/libgl-gdi/opengl32.dll.a 
-Wl,--whole-archive src/gallium/state_trackers/wgl/libwgl.a 
src/gallium/auxiliary/libgallium.a src/compiler/glsl/libglsl.a 
src/mesa/libmesa_gallium.a src/gallium/winsys/sw/gdi/libwsgdi.a 
src/mapi/glapi/libglapi_static.a -Wl,--no-whole-archive -Wl,--nxcompat 
-Wl,--dynamicbase -static-libgcc -static-libstdc++ src/compiler/nir/libnir.a 
src/compiler/libcompiler.a src/util/libmesa_util.a 
src/util/format/libmesa_format.a subprojects/zlib-1.2.11/libz.dll.a 
src/gallium/drivers/softpipe/libsoftpipe.a src/compiler/glsl/glcpp/libglcpp.a 
src/mesa/libmesa_common.a src/mesa/libmesa_sse41.a -lws2_32 -pthread -lm 
-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid 
-lcomdlg32 -ladvapi32 -Wl,--end-group
src/mesa/libmesa_common.a(main_shaderapi.c.obj): In function 
`_mesa_get_shader_include_cursor':
/home/jfonseca/work/vmware/opengl/mesa/build/meson-windows-x86_64-debug/../../src/mesa/main/shaderapi.c:3185:
 multiple definition of `_mesa_get_shader_include_cursor'
src/compiler/glsl/glcpp/libglcpp.a(pp_standalone_scaffolding.c.obj):/home/jfonseca/work/vmware/opengl/mesa/build/meson-windows-x86_64-debug/../../src/compiler/glsl/glcpp/pp_standalone_scaffolding.c:49:
 first defined here
src/mesa/libmesa_common.a(main_shaderapi.c.obj): In function 
`_mesa_set_shader_include_cursor':
/home/jfonseca/work/vmware/opengl/mesa/build/meson-windows-x86_64-debug/../../src/mesa/main/shaderapi.c:3191:
 multiple definition of `_mesa_set_shader_include_cursor'
src/compiler/glsl/glcpp/libglcpp.a(pp_standalone_scaffolding.c.obj):/home/jfonseca/work/vmware/opengl/mesa/build/meson-windows-x86_64-debug/../../src/compiler/glsl/glcpp/pp_standalone_scaffolding.c:57:
 first defined here
src/mesa/libmesa_common.a(main_shaderapi.c.obj): In function 
`_mesa_lookup_shader_include':
/home/jfonseca/work/vmware/opengl/mesa/build/meson-windows-x86_64-debug/../../src/mesa/main/shaderapi.c:3404:
 multiple definition of `_mesa_lookup_shader_include'
src/compiler/glsl/glcpp/libglcpp.a(pp_standalone_scaffolding.c.obj):/home/jfonseca/work/vmware/opengl/mesa/build/meson-windows-x86_64-debug/../../src/compiler/glsl/glcpp/pp_standalone_scaffolding.c:41:
 first defined here
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

I think this is wrong.  We shouldn't be relying on carefully crafting the order 
of linker arguments to pick the right symbol.  There should be one and one 
instance of every symbol.

I suppose the pp_standalone_scaffolding module should only be used when glsl is 
built as a command line tool no?

Jose
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org

Re: [Mesa-dev] [PATCH] nv50/ir: get rid of smemSize

2020-03-06 Thread Karol Herbst
please ignore, there is actually a use of that, but not through TGSI.

On Fri, Mar 6, 2020 at 3:07 PM Karol Herbst  wrote:
>
> we can rely on the value we get through the cso
>
> Signed-off-by: Karol Herbst 
> ---
>  src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h | 1 -
>  src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp | 1 -
>  src/gallium/drivers/nouveau/nv50/nv50_program.c  | 4 +---
>  src/gallium/drivers/nouveau/nvc0/nvc0_program.c  | 4 +---
>  4 files changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h 
> b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
> index 322bdd02557..1bd9bb36bf9 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
> @@ -89,7 +89,6 @@ struct nv50_ir_prog_info
>int16_t maxGPR; /* may be -1 if none used */
>int16_t maxOutput;
>uint32_t tlsSpace;  /* required local memory per thread */
> -  uint32_t smemSize;  /* required shared memory per block */
>uint32_t *code;
>uint32_t codeSize;
>uint32_t instructions;
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp 
> b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
> index bd78b76f384..89d515804bc 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
> @@ -1281,7 +1281,6 @@ Converter::parseNIR()
>info->prop.cp.numThreads[0] = nir->info.cs.local_size[0];
>info->prop.cp.numThreads[1] = nir->info.cs.local_size[1];
>info->prop.cp.numThreads[2] = nir->info.cs.local_size[2];
> -  info->bin.smemSize = nir->info.cs.shared_size;
>break;
> case Program::TYPE_FRAGMENT:
>info->prop.fp.earlyFragTests = nir->info.fs.early_fragment_tests;
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_program.c 
> b/src/gallium/drivers/nouveau/nv50/nv50_program.c
> index c9d01e8cee7..31edce2ea3d 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_program.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_program.c
> @@ -350,7 +350,6 @@ nv50_program_translate(struct nv50_program *prog, 
> uint16_t chipset,
>return false;
> }
>
> -   info->bin.smemSize = prog->cp.smem_size;
> info->io.auxCBSlot = 15;
> info->io.ucpBase = NV50_CB_AUX_UCP_OFFSET;
> info->io.genUserClip = prog->vp.clpd_nr;
> @@ -398,7 +397,6 @@ nv50_program_translate(struct nv50_program *prog, 
> uint16_t chipset,
> prog->interps = info->bin.fixupData;
> prog->max_gpr = MAX2(4, (info->bin.maxGPR >> 1) + 1);
> prog->tls_space = info->bin.tlsSpace;
> -   prog->cp.smem_size = info->bin.smemSize;
> prog->mul_zero_wins = info->io.mul_zero_wins;
> prog->vp.need_vertex_id = info->io.vertexId < PIPE_MAX_SHADER_INPUTS;
>
> @@ -447,7 +445,7 @@ nv50_program_translate(struct nv50_program *prog, 
> uint16_t chipset,
>
> pipe_debug_message(debug, SHADER_INFO,
>"type: %d, local: %d, shared: %d, gpr: %d, inst: %d, 
> bytes: %d",
> -  prog->type, info->bin.tlsSpace, info->bin.smemSize,
> +  prog->type, info->bin.tlsSpace, prog->cp.smem_size,
>prog->max_gpr, info->bin.instructions,
>info->bin.codeSize);
>
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c 
> b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
> index 128b94e1da5..5a9e0311101 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
> @@ -603,7 +603,6 @@ nvc0_program_translate(struct nvc0_program *prog, 
> uint16_t chipset,
> info->optLevel = 3;
>  #endif
>
> -   info->bin.smemSize = prog->cp.smem_size;
> info->io.genUserClip = prog->vp.num_ucps;
> info->io.auxCBSlot = 15;
> info->io.msInfoCBSlot = 15;
> @@ -644,7 +643,6 @@ nvc0_program_translate(struct nvc0_program *prog, 
> uint16_t chipset,
> prog->relocs = info->bin.relocData;
> prog->fixups = info->bin.fixupData;
> prog->num_gprs = MAX2(4, (info->bin.maxGPR + 1));
> -   prog->cp.smem_size = info->bin.smemSize;
> prog->num_barriers = info->numBarriers;
>
> prog->vp.need_vertex_id = info->io.vertexId < PIPE_MAX_SHADER_INPUTS;
> @@ -710,7 +708,7 @@ nvc0_program_translate(struct nvc0_program *prog, 
> uint16_t chipset,
>
> pipe_debug_message(debug, SHADER_INFO,
>"type: %d, local: %d, shared: %d, gpr: %d, inst: %d, 
> bytes: %d",
> -  prog->type, info->bin.tlsSpace, info->bin.smemSize,
> +  prog->type, info->bin.tlsSpace, prog->cp.smem_size,
>prog->num_gprs, info->bin.instructions,
>info->bin.codeSize);
>
> --
> 2.24.1
>

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org

[Mesa-dev] [PATCH] nv50/ir: get rid of smemSize

2020-03-06 Thread Karol Herbst
we can rely on the value we get through the cso

Signed-off-by: Karol Herbst 
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h | 1 -
 src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp | 1 -
 src/gallium/drivers/nouveau/nv50/nv50_program.c  | 4 +---
 src/gallium/drivers/nouveau/nvc0/nvc0_program.c  | 4 +---
 4 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
index 322bdd02557..1bd9bb36bf9 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
@@ -89,7 +89,6 @@ struct nv50_ir_prog_info
   int16_t maxGPR; /* may be -1 if none used */
   int16_t maxOutput;
   uint32_t tlsSpace;  /* required local memory per thread */
-  uint32_t smemSize;  /* required shared memory per block */
   uint32_t *code;
   uint32_t codeSize;
   uint32_t instructions;
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
index bd78b76f384..89d515804bc 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
@@ -1281,7 +1281,6 @@ Converter::parseNIR()
   info->prop.cp.numThreads[0] = nir->info.cs.local_size[0];
   info->prop.cp.numThreads[1] = nir->info.cs.local_size[1];
   info->prop.cp.numThreads[2] = nir->info.cs.local_size[2];
-  info->bin.smemSize = nir->info.cs.shared_size;
   break;
case Program::TYPE_FRAGMENT:
   info->prop.fp.earlyFragTests = nir->info.fs.early_fragment_tests;
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_program.c 
b/src/gallium/drivers/nouveau/nv50/nv50_program.c
index c9d01e8cee7..31edce2ea3d 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_program.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_program.c
@@ -350,7 +350,6 @@ nv50_program_translate(struct nv50_program *prog, uint16_t 
chipset,
   return false;
}
 
-   info->bin.smemSize = prog->cp.smem_size;
info->io.auxCBSlot = 15;
info->io.ucpBase = NV50_CB_AUX_UCP_OFFSET;
info->io.genUserClip = prog->vp.clpd_nr;
@@ -398,7 +397,6 @@ nv50_program_translate(struct nv50_program *prog, uint16_t 
chipset,
prog->interps = info->bin.fixupData;
prog->max_gpr = MAX2(4, (info->bin.maxGPR >> 1) + 1);
prog->tls_space = info->bin.tlsSpace;
-   prog->cp.smem_size = info->bin.smemSize;
prog->mul_zero_wins = info->io.mul_zero_wins;
prog->vp.need_vertex_id = info->io.vertexId < PIPE_MAX_SHADER_INPUTS;
 
@@ -447,7 +445,7 @@ nv50_program_translate(struct nv50_program *prog, uint16_t 
chipset,
 
pipe_debug_message(debug, SHADER_INFO,
   "type: %d, local: %d, shared: %d, gpr: %d, inst: %d, 
bytes: %d",
-  prog->type, info->bin.tlsSpace, info->bin.smemSize,
+  prog->type, info->bin.tlsSpace, prog->cp.smem_size,
   prog->max_gpr, info->bin.instructions,
   info->bin.codeSize);
 
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
index 128b94e1da5..5a9e0311101 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
@@ -603,7 +603,6 @@ nvc0_program_translate(struct nvc0_program *prog, uint16_t 
chipset,
info->optLevel = 3;
 #endif
 
-   info->bin.smemSize = prog->cp.smem_size;
info->io.genUserClip = prog->vp.num_ucps;
info->io.auxCBSlot = 15;
info->io.msInfoCBSlot = 15;
@@ -644,7 +643,6 @@ nvc0_program_translate(struct nvc0_program *prog, uint16_t 
chipset,
prog->relocs = info->bin.relocData;
prog->fixups = info->bin.fixupData;
prog->num_gprs = MAX2(4, (info->bin.maxGPR + 1));
-   prog->cp.smem_size = info->bin.smemSize;
prog->num_barriers = info->numBarriers;
 
prog->vp.need_vertex_id = info->io.vertexId < PIPE_MAX_SHADER_INPUTS;
@@ -710,7 +708,7 @@ nvc0_program_translate(struct nvc0_program *prog, uint16_t 
chipset,
 
pipe_debug_message(debug, SHADER_INFO,
   "type: %d, local: %d, shared: %d, gpr: %d, inst: %d, 
bytes: %d",
-  prog->type, info->bin.tlsSpace, info->bin.smemSize,
+  prog->type, info->bin.tlsSpace, prog->cp.smem_size,
   prog->num_gprs, info->bin.instructions,
   info->bin.codeSize);
 
-- 
2.24.1

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