Re: [Mesa-dev] Meson links with duplicate symbols

2020-03-13 Thread Jose Fonseca
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4186


From: Jose Fonseca 
Sent: Tuesday, March 10, 2020 17:20
To: ML mesa-dev 
Cc: Neha Bhende ; Dylan Baker 
Subject: Re: Meson links with duplicate symbols

I figured out enough of Meson to workout a fix.  I'll post it for review 
tomorrow (after I figure out what's the exact process for a MR.)

Jose


From: Jose Fonseca
Sent: Friday, March 6, 2020 15:08
To: ML mesa-dev ; Dylan Baker 

Cc: Neha Bhende 
Subject: Meson links with duplicate symbols

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_

Re: [Mesa-dev] Meson links with duplicate symbols

2020-03-10 Thread Jose Fonseca
I figured out enough of Meson to workout a fix.  I'll post it for review 
tomorrow (after I figure out what's the exact process for a MR.)

Jose


From: Jose Fonseca
Sent: Friday, March 6, 2020 15:08
To: ML mesa-dev ; Dylan Baker 

Cc: Neha Bhende 
Subject: Meson links with duplicate symbols

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. 

[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
https://lists.freedesktop.org/mailman/listinfo/m