https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251112

            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: [email protected]
          Reporter: [email protected]

Compiler error:
...
/usr/bin/c++ -g -fno-omit-frame-pointer -shared-libasan
-fsanitize=address,undefined -fsanitize-recover=vptr -O2 -g -DNDEBUG -flto=thin
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 
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 => /usr/lib/libc++.so.1 (0x800675000)
        libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x800742000)
        libm.so.5 => /lib/libm.so.5 (0x800764000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x800796000)
        libc.so.7 => /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   
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.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to