<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/125566>125566</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
compiler-rt: build fix for NetBSD-10.99.12
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
0-wiz-0
</td>
</tr>
</table>
<pre>
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.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEV82O47gRfhr6UqBAkZZsH3yQW3bWwPwsur07QS4CRVIWY1oUSKo9vYc8e0BZ090eTDeSYDMrGJAlFr_6qlh_4t7rY6fUGmUblJUzPoTWujXBF_0HJrPayqf1vgOUbUKrPQh7PuuAshLRZRtC7xErEN0hujvq0A51IuwZ0d0nFTYPJaI77wSiu2kX3aV5NmdiviIZFUtKGJuLphGZyFc15Y1U6bIhdJ4tEV0hegcoJ1VlLn11VKF3-pEHVTXcB0RHiZzAhXs420clIVjg0KkLcCda7HsldKMFtIpL5aDRRiWIFIdoRO0UP3kIrYJ60EaCbaJhvTbKYReiSaRAOZl-pNgV-w_bErECjK6jVbzTQf-hXBUtsx2iu7uP_KR22iiP6O7-8PBN4m4U-KBrkXxd5lU-T6R2N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