Bug 110663 - threads_posix.h:96: undefined reference to `pthread_once'
Summary: threads_posix.h:96: undefined reference to `pthread_once'
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-10 21:17 UTC by Vinson Lee
Modified: 2019-07-15 17:14 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Vinson Lee 2019-05-10 21:17:54 UTC
meson builddir -Ddri-drivers='' -Dbuild-tests=true -Dgallium-drivers=swrast -Dplatforms=x11 -Dvulkan-drivers=''

FAILED: src/gallium/tests/trivial/quad-tex 
ccache c++  -o src/gallium/tests/trivial/quad-tex 'src/gallium/tests/trivial/quad-tex@exe/quad-tex.c.o' -Wl,--no-undefined -Wl,--as-needed -Wl,--start-group src/util/libmesa_util.a src/gallium/auxiliary/libgallium.a src/compiler/glsl/libglsl.a src/compiler/glsl/glcpp/libglcpp.a src/compiler/nir/libnir.a src/compiler/libcompiler.a src/gallium/auxiliary/pipe-loader/libpipe_loader_dynamic.a src/loader/libloader.a src/util/libxmlconfig.a -lz -lm -Wl,--end-group -ldrm -L/usr/lib/llvm-6.0/lib -lLLVM-6.0 -lunwind -ldl -lm -lsensors -lz -lm -ldrm -ldrm -lexpat -lm -lz -lm  
src/util/libmesa_util.a(u_cpu_detect.c.o): In function `call_once':
../include/c11/threads_posix.h:96: undefined reference to `pthread_once'
Comment 1 Eric Engestrom 2019-05-11 07:05:04 UTC
This should fix your issue, but I haven't had time to dive in and see exactly why quad-tex uses threads.

----8<----
diff --git a/src/gallium/tests/trivial/meson.build b/src/gallium/tests/trivial/meson.build
index bbb25519e12ff466ce46..1f912d5aa46a16a06eda 100644
--- a/src/gallium/tests/trivial/meson.build
+++ b/src/gallium/tests/trivial/meson.build
@@ -24,6 +24,7 @@ foreach t : ['compute', 'tri', 'quad-tex']
     '@0@.c'.format(t),
     include_directories : inc_common,
     link_with : [libmesa_util, libgallium, libpipe_loader_dynamic],
+    dependencies : dep_thread,
     install : false,
   )
 endforeach
---->8----
Comment 2 Vinson Lee 2019-05-14 22:45:06 UTC
This patch fixed my build issue.

Tested-by: Vinson Lee <vlee@freedesktop.org>


(In reply to Eric Engestrom from comment #1)
> This should fix your issue, but I haven't had time to dive in and see
> exactly why quad-tex uses threads.
> 
> ----8<----
> diff --git a/src/gallium/tests/trivial/meson.build
> b/src/gallium/tests/trivial/meson.build
> index bbb25519e12ff466ce46..1f912d5aa46a16a06eda 100644
> --- a/src/gallium/tests/trivial/meson.build
> +++ b/src/gallium/tests/trivial/meson.build
> @@ -24,6 +24,7 @@ foreach t : ['compute', 'tri', 'quad-tex']
>      '@0@.c'.format(t),
>      include_directories : inc_common,
>      link_with : [libmesa_util, libgallium, libpipe_loader_dynamic],
> +    dependencies : dep_thread,
>      install : false,
>    )
>  endforeach
> ---->8----
Comment 3 Vinson Lee 2019-07-15 17:14:27 UTC
commit 730ceeddb557cec08a502e82b7faeb689bc91d2a
Author: Vinson Lee <vlee@freedesktop.org>
Date:   Thu Jun 13 15:08:27 2019 -0700

    meson: Add dep_thread dependency.
    
    Fix this build error on Ubuntu 18.04.
    
    /usr/bin/ld: src/util/libmesa_util.a(u_cpu_detect.c.o): undefined reference to symbol 'pthread_once@@GLIBC_2.2.5'
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110663
    Suggested-by: Eric Engestrom <eric@@engestrom.ch>
    Signed-off-by: Vinson Lee <vlee@freedesktop.org>
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Acked-by: Eric Engestrom <eric@engestrom.ch>


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.