[compiler-rt] [RTSan][Darwin] Adjust OSSpinLock/_os_nospin_lock interceptor and tests (PR #132867)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 25 02:37:34 PDT 2025


davidtrevelyan wrote:

> @cjappl @davidtrevelyan could you confirm this works for you on both the OSes?

Hi @thetruestblue - many thanks for your help on this. I've tried this patch and unfortunately get the following error:

```sh
cd /Users/david/Repositories/rtsan/llvm-project/build/projects/compiler-rt/lib/rtsan/tests && /Users/david/Repositories/rtsan/llvm-project/build/./bin/clang++ -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -I/Users/david/Repositories/rtsan/llvm-project/compiler-rt/include -g -Wno-covered-switch-default -Wno-suggest-override -DGTEST_NO_LLVM_SUPPORT=1 -DGTEST_HAS_RTTI=0 -I/Users/david/Repositories/rtsan/llvm-project/llvm/../third-party/unittest/googletest/include -I/Users/david/Repositories/rtsan/llvm-project/llvm/../third-party/unittest/googletest -DGTEST_NO_LLVM_SUPPORT=1 -DGTEST_HAS_RTTI=0 -I/Users/david/Repositories/rtsan/llvm-project/llvm/../third-party/unittest/googlemock/include -I/Users/david/Repositories/rtsan/llvm-project/llvm/../third-party/unittest/googlemock -I/Users/david/Repositories/rtsan/llvm-project/compiler-rt/lib/ -I/Users/david/Repositories/rtsan/llvm-project/compiler-rt/include/ -I/Users/david/Repositories/rtsan/llvm-project/compiler-rt/lib/rtsan -I/Users/david/Repositories/rtsan/llvm-project/compiler-rt/lib/sanitizer_common/tests -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS -O2 -stdlib=libc++ -mmacosx-version-min=15.1 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -fsanitize=realtime -arch arm64 -c -o RtsanTestObjects.rtsan_test_interceptors_posix.cpp.arm64.o /Users/david/Repositories/rtsan/llvm-project/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
/Users/david/Repositories/rtsan/llvm-project/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp:1132:23: error: use of undeclared identifier '_os_nospin_lock_lock'; did you mean 'os_unfair_lock_lock'?
 1132 |   auto Func = [&]() { _os_nospin_lock_lock(&lock); };
      |                       ^~~~~~~~~~~~~~~~~~~~
      |                       os_unfair_lock_lock
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/lock.h:115:6: note: 'os_unfair_lock_lock' declared here
  115 | void os_unfair_lock_lock(os_unfair_lock_t lock);
      |      ^
/Users/david/Repositories/rtsan/llvm-project/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp:1132:44: error: cannot initialize a parameter of type 'os_unfair_lock_t _Nonnull' (aka 'os_unfair_lock_s *') with an rvalue of type 'OSSpinLock *' (aka 'int *')
 1132 |   auto Func = [&]() { _os_nospin_lock_lock(&lock); };
      |                                            ^~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/lock.h:115:43: note: passing argument to parameter 'lock' here
  115 | void os_unfair_lock_lock(os_unfair_lock_t lock);
      |                                           ^
2 errors generated.
```

In the above, `MacOSX.sdk` is a soft link to the 15.2 SDK. Hope this is helpful for your investigations!

https://github.com/llvm/llvm-project/pull/132867


More information about the llvm-commits mailing list