1

我至少已经根据此处的说明成功配置了 llvm 编译器的构建。

当我去构建使用时,cmake --build . -v我得到以下错误输出:

$ cmake --build . -v
...
[ 63%] Building CXX object projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan_osx_dynamic.dir/rtl/tsan_libdispatch_mac.cc.o
cd /Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/build/projects/compiler-rt/lib/tsan && /usr/bin/clang++ --sysroot=/  -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Dclang_rt_tsan_osx_dynamic_EXPORTS -I/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/build/projects/compiler-rt/lib/tsan -I/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/projects/compiler-rt/lib/tsan -I/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/build/include -I/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/include -I/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/projects/compiler-rt/lib/tsan/..  -isystem / -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -std=c++11 -Wall -std=c++11 -O3 -DNDEBUG -arch x86_64 -arch x86_64h -fPIC    -stdlib=libc++ -mmacosx-version-min=10.9 -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fvisibility-inlines-hidden -fno-function-sections -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fPIE -fno-rtti -msse3 -Wframe-larger-than=512 -Wglobal-constructors -o CMakeFiles/clang_rt.tsan_osx_dynamic.dir/rtl/tsan_libdispatch_mac.cc.o -c /Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc
/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc:144:22: error: 
      conflicting types for 'dispatch_sync'
DISPATCH_INTERCEPT_B(dispatch_sync)
                     ^
/usr/include/dispatch/queue.h:292:1: note: previous declaration is here
dispatch_sync(dispatch_queue_t queue, DISPATCH_NOESCAPE dispatch_block_t block);
^
/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc:145:22: error: 
      conflicting types for 'dispatch_barrier_sync'
DISPATCH_INTERCEPT_B(dispatch_barrier_sync)
                     ^
/usr/include/dispatch/queue.h:1278:1: note: previous declaration is here
dispatch_barrier_sync(dispatch_queue_t queue,
^
/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc:162:24: error: 
      conflicting types for 'dispatch_once'
TSAN_INTERCEPTOR(void, dispatch_once, dispatch_once_t *predicate,
                       ^
/usr/include/dispatch/once.h:73:1: note: previous declaration is here
dispatch_once(dispatch_once_t *predicate,
^
3 errors generated.
make[2]: *** [projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan_osx_dynamic.dir/rtl/tsan_libdispatch_mac.cc.o] Error 1
make[1]: *** [projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan_osx_dynamic.dir/all] Error 2
make: *** [all] Error 2

我以前能够通过简单地复制和粘贴详细输出并在命令行中更正它来解决 cmake 设置的错误编译器标志,但我不确定在此处编辑什么才能使事情正常工作。

我已经尝试更改 -isysroot,将头文件从 /usr/include 或 MacOSX10.14.sdk 文件复制并粘贴到 llvm/include 中,并且持续存在的问题是error: conflicting types ...

我什至尝试对 tsan_libdispatch_mac.cc 做一些小的修改,但没有一个起作用(例如,更改#include <dispatch/dispatch.h>#include <dispatch.h>,将“user_alloc”更改为“user_alloc_internal”......)。

欢迎任何建议。

安东尼

4

2 回答 2

1

基本上我不得不用这里的一种形式替换我原来的 tsan_libdispatch_mac.cc 。我还没有完成完整的安装,更不用说测试性能了,但是我的构建现在已经过了这一点。

于 2020-02-15T13:43:48.190 回答
1

我尝试为 llvm 3.9.1 编译它,但 tsan_libdispatch_mac.cc 不同。这是一个有效的差异:

diff --git a/lib/tsan/rtl/tsan_libdispatch_mac.cc b/lib/tsan/rtl/tsan_libdispatch_mac.cc
index 529cedba4..86982e361 100644
--- a/lib/tsan/rtl/tsan_libdispatch_mac.cc
+++ b/lib/tsan/rtl/tsan_libdispatch_mac.cc
@@ -144,7 +144,7 @@ static void invoke_and_release_block(void *param) {
   }

 #define DISPATCH_INTERCEPT_SYNC_B(name, barrier)                             \
-  TSAN_INTERCEPTOR(void, name, dispatch_queue_t q, dispatch_block_t block) { \
+  TSAN_INTERCEPTOR(void, name, dispatch_queue_t q, DISPATCH_NOESCAPE dispatch_block_t block) { \
     SCOPED_TSAN_INTERCEPTOR(name, q, block);                                 \
     SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_START();                           \
     dispatch_block_t heap_block = Block_copy(block);                         \
@@ -234,7 +234,7 @@ TSAN_INTERCEPTOR(void, dispatch_after_f, dispatch_time_t when,
 // need to undefine the macro.
 #undef dispatch_once
 TSAN_INTERCEPTOR(void, dispatch_once, dispatch_once_t *predicate,
-                 dispatch_block_t block) {
+                 DISPATCH_NOESCAPE dispatch_block_t block) {
   SCOPED_INTERCEPTOR_RAW(dispatch_once, predicate, block);
   atomic_uint32_t *a = reinterpret_cast<atomic_uint32_t *>(predicate);
   u32 v = atomic_load(a, memory_order_acquire);
@@ -444,7 +444,7 @@ TSAN_INTERCEPTOR(void, dispatch_source_set_registration_handler_f,
 }

 TSAN_INTERCEPTOR(void, dispatch_apply, size_t iterations,
-                 dispatch_queue_t queue, void (^block)(size_t)) {
+                 dispatch_queue_t queue, DISPATCH_NOESCAPE void (^block)(size_t)) {
   SCOPED_TSAN_INTERCEPTOR(dispatch_apply, iterations, queue, block);

   void *parent_to_child_sync = nullptr;
于 2020-06-04T10:12:42.433 回答