2015-12-10 06:46:49 +08:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2014-02-18 17:33:45 +08:00
|
|
|
add_custom_target(profile)
|
|
|
|
|
2014-04-23 02:49:32 +08:00
|
|
|
set(PROFILE_SOURCES
|
|
|
|
GCDAProfiling.c
|
|
|
|
InstrProfiling.c
|
2015-12-11 04:24:09 +08:00
|
|
|
InstrProfilingValue.c
|
2014-04-23 02:49:32 +08:00
|
|
|
InstrProfilingBuffer.c
|
|
|
|
InstrProfilingFile.c
|
2016-03-04 02:54:46 +08:00
|
|
|
InstrProfilingMerge.c
|
|
|
|
InstrProfilingMergeFile.c
|
2015-11-19 05:08:03 +08:00
|
|
|
InstrProfilingWriter.c
|
2014-04-23 02:49:32 +08:00
|
|
|
InstrProfilingPlatformDarwin.c
|
2015-10-14 02:40:00 +08:00
|
|
|
InstrProfilingPlatformLinux.c
|
2014-04-23 02:49:32 +08:00
|
|
|
InstrProfilingPlatformOther.c
|
2015-07-10 01:21:52 +08:00
|
|
|
InstrProfilingRuntime.cc
|
2016-01-07 00:55:21 +08:00
|
|
|
InstrProfilingUtil.c)
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
list(APPEND PROFILE_SOURCES WindowsMMap.c)
|
|
|
|
endif()
|
2014-03-20 11:57:33 +08:00
|
|
|
|
2015-11-14 06:33:07 +08:00
|
|
|
if(UNIX)
|
|
|
|
set(EXTRA_FLAGS
|
|
|
|
-fPIC
|
|
|
|
-Wno-pedantic)
|
|
|
|
endif()
|
|
|
|
|
2015-12-10 06:46:49 +08:00
|
|
|
if(COMPILER_RT_TARGET_HAS_ATOMICS)
|
|
|
|
set(EXTRA_FLAGS
|
|
|
|
${EXTRA_FLAGS}
|
|
|
|
-DCOMPILER_RT_HAS_ATOMICS=1)
|
|
|
|
endif()
|
|
|
|
|
2014-04-23 02:49:32 +08:00
|
|
|
if(APPLE)
|
2015-08-26 03:53:09 +08:00
|
|
|
add_compiler_rt_runtime(clang_rt.profile
|
|
|
|
STATIC
|
2015-10-01 05:23:22 +08:00
|
|
|
OS ${PROFILE_SUPPORTED_OS}
|
2015-08-26 03:53:09 +08:00
|
|
|
ARCHS ${PROFILE_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${PROFILE_SOURCES}
|
|
|
|
PARENT_TARGET profile)
|
2013-03-25 22:20:11 +08:00
|
|
|
else()
|
2015-08-26 03:53:09 +08:00
|
|
|
add_compiler_rt_runtime(clang_rt.profile
|
|
|
|
STATIC
|
|
|
|
ARCHS ${PROFILE_SUPPORTED_ARCH}
|
2015-11-14 06:33:07 +08:00
|
|
|
CFLAGS ${EXTRA_FLAGS}
|
2015-08-26 03:53:09 +08:00
|
|
|
SOURCES ${PROFILE_SOURCES}
|
|
|
|
PARENT_TARGET profile)
|
2013-03-19 17:17:35 +08:00
|
|
|
endif()
|
2014-02-18 17:33:45 +08:00
|
|
|
|
|
|
|
add_dependencies(compiler-rt profile)
|