<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Missing OpenGL symbols in OSMesa Gallium when building with meson"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=109659">109659</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missing OpenGL symbols in OSMesa Gallium when building with meson
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>18.3
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Drivers/OSMesa
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>pierre.guillou@lip6.fr
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Building OSMesa Gallium with meson leads to missing exported OpenGL symbols in
libOSMesa.so compared to using the autotools/configure script.

Use case/context: ParaView in-situ analysis and rendering
(<a href="https://blog.kitware.com/messing-with-mesa-for-paraview-5-0vtk-7-0/">https://blog.kitware.com/messing-with-mesa-for-paraview-5-0vtk-7-0/</a>)

When using meson to build OSMesa from Mesa 18.3:

$ meson [sourcedir] -Dosmesa=gallium
$ ninja

I noticed that libOSMesa.so does not export OpenGL symbols:

$ nm -D src/gallium/targets/osmesa/libOSMesa.so | grep " T "
000000000006cbe0 T OSMesaColorClamp
000000000006c6a0 T OSMesaCreateContext
000000000006c1a0 T OSMesaCreateContextAttribs
000000000006c620 T OSMesaCreateContextExt
000000000006cc60 T OSMesaDestroyContext
000000000006c0a0 T OSMesaGetColorBuffer
000000000006c0f0 T OSMesaGetCurrentContext
000000000006cf50 T OSMesaGetDepthBuffer
000000000006c6c0 T OSMesaGetIntegerv
000000000006cb70 T OSMesaGetProcAddress
000000000006c7d0 T OSMesaMakeCurrent
000000000006cc00 T OSMesaPixelStore
000000000006cee0 T OSMesaPostprocess

However, using the autotools/configure script (Mesa 18.3):

$ [sourcedir]/autogen.sh --enable-gallium-osmesa
or, from release tarball
$ [sourcedir]/configure --enable-gallium-osmesa
$ make

the generated library exports the whole OpenGL API:

$ nm -D lib/gallium/libOSMesa.so | grep " T "
0000000000558f80 T glAccum
000000000055e300 T glActiveShaderProgram
[...]
000000000055ae40 T glWindowPos3sv
000000000055ae40 T glWindowPos3svARB
0000000000557200 T OSMesaColorClamp
00000000005569d0 T OSMesaCreateContext
00000000005564d0 T OSMesaCreateContextAttribs
0000000000556950 T OSMesaCreateContextExt
0000000000557280 T OSMesaDestroyContext
00000000005563d0 T OSMesaGetColorBuffer
0000000000556420 T OSMesaGetCurrentContext
0000000000556ea0 T OSMesaGetDepthBuffer
00000000005569f0 T OSMesaGetIntegerv
0000000000557190 T OSMesaGetProcAddress
0000000000556b00 T OSMesaMakeCurrent
0000000000557220 T OSMesaPixelStore
00000000005572b0 T OSMesaPostprocess

This behavior has been witnessed on up-to-date ArchLinux and Ubuntu 18.04.

Assuming this is a bug in the Meson build script, one quick fix would be to
edit src/gallium/targets/osmesa/meson.build and move libglapi_static from the
link_with section to the link_whole section in the osmesa library declaration:

diff --git a/src/gallium/targets/osmesa/meson.build
b/src/gallium/targets/osmesa/meson.build
index b4ae8f4b6ec..e873e311aa0 100644
--- a/src/gallium/targets/osmesa/meson.build
+++ b/src/gallium/targets/osmesa/meson.build
@@ -43,9 +43,9 @@ libosmesa = shared_library(
     inc_gallium_drivers,
   ],
   link_depends : osmesa_link_deps,
-  link_whole : [libosmesa_st],
+  link_whole : [libosmesa_st, libglapi_static],
   link_with : [
-    libmesa_gallium, libgallium, libglapi_static, libws_null,
osmesa_link_with,
+    libmesa_gallium, libgallium, libws_null, osmesa_link_with,
   ],
   dependencies : [
     dep_selinux, dep_thread, dep_clock, dep_unwind,

However, being quite new at building Mesa and maybe missing the big picture,
I'm not sure
* if what I'm describing here is really a bug, or is intentional and
* if there is some unforeseen consequences of the aforementioned quick fix.

Is there a more appropriate way to use OpenGL through OSMesa?

Similar to: <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - osmesa gallium build with scons on linux contains no OSMesa* and GL* symbols"
   href="show_bug.cgi?id=94489">https://bugs.freedesktop.org/show_bug.cgi?id=94489</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>