Issue 125566
Summary compiler-rt: build fix for NetBSD-10.99.12
Labels new issue
Assignees
Reporter 0-wiz-0
    In [this commit](https://github.com/NetBSD/src/commit/16543c49052c820334cffc5c69b2afde18f02458), `__lwp_getprivate_fast()` was moved to a new arch-specific header file.
This breaks the build of compiler-rt:
```
FAILED: lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_linux_libcdep.cpp.o
/scratch/lang/compiler-rt/work/.cwrapper/bin/c++ -DHAVE_RPC_XDR_H=0 -I/scratch/lang/compiler-rt/work/compiler-rt-18.1.8.src/lib/sanitizer_common/.. -O2 -g -fstack-clash-protection -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/python3.13 -Wall -Wno-unused-parameter -DNDEBUG -std=c++17 -m64 -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fvisibility=hidden -fno-lto -O3 -g -Wno-variadic-macros -nostdinc++ -Wno-format -fno-rtti -Wframe-larger-than=570 -MD -MT lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_linux_libcdep.cpp.o -MF lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_linux_libcdep.cpp.o.d -o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_linux_libcdep.cpp.o -c /scratch/lang/compiler-rt/work/compiler-rt-18.1.8.src/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
/scratch/lang/compiler-rt/work/compiler-rt-18.1.8.src/lib/sanitizer_common/sanitizer_linux_libcdep.cpp: In function 'tls_tcb* __sanitizer::ThreadSelfTlsTcb()':
/scratch/lang/compiler-rt/work/compiler-rt-18.1.8.src/lib/sanitizer_common/sanitizer_linux_libcdep.cpp:452:27: error: '__lwp_getprivate_fast' was not declared in this scope; did you mean '_lwp_getprivate'?
  452 |   tcb = (struct tls_tcb *)__lwp_getprivate_fast();
      | ^~~~~~~~~~~~~~~~~~~~~
      | _lwp_getprivate
```

The fix is to include the new header `machine/lwp_private.h`. A tentative patch that fixes the build looks like this:

```
--- lib/sanitizer_common/sanitizer_linux_libcdep.cpp.orig 2024-06-15 17:21:32.000000000 +0000
+++ lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -29,7 +29,13 @@
 # include "sanitizer_solaris.h"

 #  if SANITIZER_NETBSD
-#    define _RTLD_SOURCE  // for __lwp_gettcb_fast() / __lwp_getprivate_fast()
+#    // for __lwp_gettcb_fast() / __lwp_getprivate_fast()
+#    include <sys/param.h>
+#    if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 1099001200)
+#      include <machine/lwp_private.h>
+#    else
+# define _RTLD_SOURCE
+#    endif
 #  endif

 #  include <dlfcn.h>  // for dlsym()
```
but I don't know the llvm codebase well enough, so I'd appreciate feedback.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to