Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Nov 2020 20:33:19 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 251112] Compiling C++ with asan fails by default because libclang_rt.asan-x86_64.so uses symbol pthread_attr_get_np but doesn't link to libpthread.so
Message-ID:  <bug-251112-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D251112

            Bug ID: 251112
           Summary: Compiling C++ with asan fails by default because
                    libclang_rt.asan-x86_64.so uses symbol
                    pthread_attr_get_np but doesn't link to libpthread.so
           Product: Base System
           Version: 12.2-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: astitcher@apache.org

Compiler error:
...
/usr/bin/c++ -g -fno-omit-frame-pointer -shared-libasan
-fsanitize=3Daddress,undefined -fsanitize-recover=3Dvptr -O2 -g -DNDEBUG -f=
lto=3Dthin
c/tests/CMakeFiles/test_main.dir/test_main.cpp.o
c/tests/CMakeFiles/c-proactor-test.dir/pn_test.cpp.o
c/tests/CMakeFiles/c-proactor-test.dir/pn_test_proactor.cpp.o
c/tests/CMakeFiles/c-proactor-test.dir/proactor_test.cpp.o -o
c/tests/c-proactor-test  -Wl,-rpath,/home/vagrant/qpid-proton/BLD/c=20
c/libqpid-proton-proactor.so.1.7.1  c/libqpid-proton-core.so.10.11.0 && :
ld: error: /usr/lib/clang/10.0.1/lib/freebsd/libclang_rt.asan-x86_64.so:
undefined reference to pthread_attr_get_np

And indeed the library only links in portable pthreads via libc:
$ ldd /usr/lib/clang/10.0.1/lib/freebsd/libclang_rt.asan-x86_64.so
/usr/lib/clang/10.0.1/lib/freebsd/libclang_rt.asan-x86_64.so:
        libc++.so.1 =3D> /usr/lib/libc++.so.1 (0x800675000)
        libcxxrt.so.1 =3D> /lib/libcxxrt.so.1 (0x800742000)
        libm.so.5 =3D> /lib/libm.so.5 (0x800764000)
        libgcc_s.so.1 =3D> /lib/libgcc_s.so.1 (0x800796000)
        libc.so.7 =3D> /lib/libc.so.7 (0x80024e000)

Whereas the needed symbol is in libpthreads:
$ objdump -T /usr/lib/libpthread.so | grep pthread_attr_get_np
000000000001b960  w   DF .text  0000000000000264  FBSD_1.0=20=20=20
pthread_attr_get_np
000000000001b960  w   DF .text  0000000000000264  FBSDprivate_1.0
_pthread_attr_get_np

You can work around this by manually linking -lpthreads, but our build files
which work elsewhere don't do this as it's not necessary elsewhere.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-251112-227>