2 CHECK_CXX_SOURCE_COMPILES("
4 #include <intrin.h> /* Workaround for PR19898. */
11 InterlockedCompareExchange(&val, 0, 1);
12 InterlockedIncrement(&val);
13 InterlockedDecrement(&val);
15 volatile unsigned long val = 1;
17 __sync_val_compare_and_swap(&val, 1, 0);
18 __sync_add_and_fetch(&val, 1);
19 __sync_sub_and_fetch(&val, 1);
23 " COMPILER_RT_TARGET_HAS_ATOMICS)
25 CHECK_CXX_SOURCE_COMPILES("
26 #if defined(__linux__)
34 s_flock.l_type = F_WRLCK;
35 fcntl(fd, F_SETLKW, &s_flock);
39 " COMPILER_RT_TARGET_HAS_FCNTL_LCK)
41 CHECK_CXX_SOURCE_COMPILES("
42 #include <sys/utsname.h>
47 " COMPILER_RT_TARGET_HAS_UNAME)
49 add_compiler_rt_component(profile)
54 InstrProfilingInternal.c
56 InstrProfilingBuffer.c
59 InstrProfilingMergeFile.c
60 InstrProfilingNameVar.c
61 InstrProfilingVersionVar.c
62 InstrProfilingWriter.c
63 InstrProfilingPlatformAIX.c
64 InstrProfilingPlatformDarwin.c
65 InstrProfilingPlatformFuchsia.c
66 InstrProfilingPlatformLinux.c
67 InstrProfilingPlatformOther.c
68 InstrProfilingPlatformWindows.c
69 InstrProfilingRuntime.cpp
75 InstrProfilingInternal.h
82 list(APPEND PROFILE_SOURCES
87 include_directories(..)
88 include_directories(../../include)
96 if(COMPILER_RT_TARGET_HAS_ATOMICS)
99 -DCOMPILER_RT_HAS_ATOMICS=1)
102 if(COMPILER_RT_TARGET_HAS_FCNTL_LCK)
105 -DCOMPILER_RT_HAS_FCNTL_LCK=1)
108 if(COMPILER_RT_TARGET_HAS_UNAME)
111 -DCOMPILER_RT_HAS_UNAME=1)
114 # We don't use the C++ Standard Library here, so avoid including it by mistake.
115 append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ EXTRA_FLAGS)
116 # XRay uses C++ standard library headers.
117 string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
119 # This appears to be a C-only warning banning the use of locals in aggregate
120 # initializers. All other compilers accept this, though.
121 # nonstandard extension used : 'identifier' : cannot be initialized using address of automatic variable
122 append_list_if(COMPILER_RT_HAS_WD4221_FLAG /wd4221 EXTRA_FLAGS)
124 # Disable 'nonstandard extension used: translation unit is empty'.
125 append_list_if(COMPILER_RT_HAS_WD4206_FLAG /wd4206 EXTRA_FLAGS)
128 add_compiler_rt_runtime(clang_rt.profile
130 OS ${PROFILE_SUPPORTED_OS}
131 ARCHS ${PROFILE_SUPPORTED_ARCH}
132 CFLAGS ${EXTRA_FLAGS}
133 SOURCES ${PROFILE_SOURCES}
134 ADDITIONAL_HEADERS ${PROFILE_HEADERS}
135 PARENT_TARGET profile)
137 add_compiler_rt_runtime(clang_rt.profile
139 ARCHS ${PROFILE_SUPPORTED_ARCH}
140 CFLAGS ${EXTRA_FLAGS}
141 SOURCES ${PROFILE_SOURCES}
142 ADDITIONAL_HEADERS ${PROFILE_HEADERS}
143 PARENT_TARGET profile)