aboutsummaryrefslogtreecommitdiff
path: root/lib/profile/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'lib/profile/CMakeLists.txt')
-rw-r--r--lib/profile/CMakeLists.txt62
1 files changed, 53 insertions, 9 deletions
diff --git a/lib/profile/CMakeLists.txt b/lib/profile/CMakeLists.txt
index d03409fc45b7..1b10ade0eee6 100644
--- a/lib/profile/CMakeLists.txt
+++ b/lib/profile/CMakeLists.txt
@@ -1,27 +1,71 @@
+
+CHECK_CXX_SOURCE_COMPILES("
+#ifdef _MSC_VER
+#include <Intrin.h> /* Workaround for PR19898. */
+#include <windows.h>
+#endif
+int main() {
+#ifdef _MSC_VER
+ volatile LONG val = 1;
+ MemoryBarrier();
+ InterlockedCompareExchange(&val, 0, 1);
+ InterlockedIncrement(&val);
+ InterlockedDecrement(&val);
+#else
+ volatile unsigned long val = 1;
+ __sync_synchronize();
+ __sync_val_compare_and_swap(&val, 1, 0);
+ __sync_add_and_fetch(&val, 1);
+ __sync_sub_and_fetch(&val, 1);
+#endif
+ return 0;
+ }
+" COMPILER_RT_TARGET_HAS_ATOMICS)
+
add_custom_target(profile)
set(PROFILE_SOURCES
GCDAProfiling.c
InstrProfiling.c
+ InstrProfilingValue.c
InstrProfilingBuffer.c
InstrProfilingFile.c
+ InstrProfilingWriter.c
InstrProfilingPlatformDarwin.c
+ InstrProfilingPlatformLinux.c
InstrProfilingPlatformOther.c
InstrProfilingRuntime.cc
InstrProfilingUtil.c)
+if(UNIX)
+ set(EXTRA_FLAGS
+ -fPIC
+ -Wno-pedantic)
+else()
+ set(EXTRA_FLAGS
+ -fPIC)
+endif()
+
+if(COMPILER_RT_TARGET_HAS_ATOMICS)
+ set(EXTRA_FLAGS
+ ${EXTRA_FLAGS}
+ -DCOMPILER_RT_HAS_ATOMICS=1)
+endif()
+
if(APPLE)
- add_compiler_rt_osx_static_runtime(clang_rt.profile_osx
+ add_compiler_rt_runtime(clang_rt.profile
+ STATIC
+ OS ${PROFILE_SUPPORTED_OS}
ARCHS ${PROFILE_SUPPORTED_ARCH}
- SOURCES ${PROFILE_SOURCES})
- add_dependencies(profile clang_rt.profile_osx)
+ SOURCES ${PROFILE_SOURCES}
+ PARENT_TARGET profile)
else()
- foreach(arch ${PROFILE_SUPPORTED_ARCH})
- add_compiler_rt_runtime(clang_rt.profile-${arch} ${arch} STATIC
- CFLAGS -fPIC
- SOURCES ${PROFILE_SOURCES})
- add_dependencies(profile clang_rt.profile-${arch})
- endforeach()
+ add_compiler_rt_runtime(clang_rt.profile
+ STATIC
+ ARCHS ${PROFILE_SUPPORTED_ARCH}
+ CFLAGS ${EXTRA_FLAGS}
+ SOURCES ${PROFILE_SOURCES}
+ PARENT_TARGET profile)
endif()
add_dependencies(compiler-rt profile)