<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
While reviewing my colleagues efforts to consume Meson for Windows I stumbled across two issues.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
First is that even though we added the "<i>W</i><i>ARNING: 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</i>" 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.<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
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:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: "Courier New", monospace; font-size: 8pt;"><b>$ git diff</b></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: "Courier New", monospace; font-size: 8pt;">diff --git a/src/gallium/targets/libgl-gdi/meson.build b/src/gallium/targets/libgl-gdi/meson.build</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">index cd4e02d1fa9..fb8a42439c8 100644</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">--- a/src/gallium/targets/libgl-gdi/meson.build</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">+++ b/src/gallium/targets/libgl-gdi/meson.build</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">@@ -33,10 +33,8 @@ libopengl32 = shared_library(</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">   include_directories : [</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">     inc_common, inc_wgl, inc_gallium_winsys_sw, inc_gallium_drivers,</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">   ],</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">-  link_whole : [libwgl],</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">-  link_with : [</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">-    libgallium, libglsl, libmesa_gallium, libwsgdi, libglapi_static, libglapi</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">-  ],</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">+  link_whole : [libwgl, libgallium, libglsl, libmesa_gallium, libwsgdi, libglapi_static, libglapi],</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">+  link_with : [],</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">   dependencies : [</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">     dep_ws2_32, idep_nir, idep_mesautil, driver_swrast, driver_swr,</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">   ],</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"><b>$ meson --cross .gitlab-ci/x86_64-w64-mingw32 . build/meson-windows-<b style="font-family: "Courier New", monospace; font-size: 10.6667px; background-color: rgb(255, 255, 255)">x86_64</b>-debug<br>
$ ninja -C build/meson-windows-x86_64-debug/</b></span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">ninja: Entering directory `build/meson-windows-x86_64-debug/'</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">[2/2] Linking target src/gallium/targets/libgl-gdi/opengl32.dll.</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">FAILED: src/gallium/targets/libgl-gdi/opengl32.dll
</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">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</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"><b>src/mesa/libmesa_common.a(main_shaderapi.c.obj): In function `_mesa_get_shader_include_cursor':</b></span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"><b>/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'</b></span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"><b>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</b></span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"><b>src/mesa/libmesa_common.a(main_shaderapi.c.obj): In function `_mesa_set_shader_include_cursor':</b></span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"><b>/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'</b></span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"><b>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</b></span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"><b>src/mesa/libmesa_common.a(main_shaderapi.c.obj): In function `_mesa_lookup_shader_include':</b></span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"><b>/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'</b></span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"><b>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</b></span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">collect2: error: ld returned 1 exit status</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">ninja: build stopped: subcommand failed.</span></div>
</div>
</blockquote>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span></span><br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
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.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">I suppose the pp_standalone_scaffolding module should only be used when glsl is built as a command line tool no?</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Jose</div>
</body>
</html>