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)
55 InstrProfilingBuffer.c
58 InstrProfilingMergeFile.c
59 InstrProfilingNameVar.c
60 InstrProfilingWriter.c
61 InstrProfilingPlatformDarwin.c
62 InstrProfilingPlatformLinux.c
63 InstrProfilingPlatformOther.c
64 InstrProfilingRuntime.cc
68 list(APPEND PROFILE_SOURCES WindowsMMap.c)
77 if(COMPILER_RT_TARGET_HAS_ATOMICS)
80 -DCOMPILER_RT_HAS_ATOMICS=1)
83 if(COMPILER_RT_TARGET_HAS_FCNTL_LCK)
86 -DCOMPILER_RT_HAS_FCNTL_LCK=1)
89 if(COMPILER_RT_TARGET_HAS_UNAME)
92 -DCOMPILER_RT_HAS_UNAME=1)
95 # This appears to be a C-only warning banning the use of locals in aggregate
96 # initializers. All other compilers accept this, though.
97 # nonstandard extension used : 'identifier' : cannot be initialized using address of automatic variable
98 append_list_if(COMPILER_RT_HAS_WD4221_FLAG /wd4221 EXTRA_FLAGS)
101 add_compiler_rt_runtime(clang_rt.profile
103 OS ${PROFILE_SUPPORTED_OS}
104 ARCHS ${PROFILE_SUPPORTED_ARCH}
105 CFLAGS ${EXTRA_FLAGS}
106 SOURCES ${PROFILE_SOURCES}
107 PARENT_TARGET profile)
109 add_compiler_rt_runtime(clang_rt.profile
111 ARCHS ${PROFILE_SUPPORTED_ARCH}
112 CFLAGS ${EXTRA_FLAGS}
113 SOURCES ${PROFILE_SOURCES}
114 PARENT_TARGET profile)