1 add_compiler_rt_component(scudo_standalone)
3 include_directories(../.. include)
7 list(APPEND SCUDO_CFLAGS
13 # Remove -stdlib= which is unused when passing -nostdinc++.
14 string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
16 append_list_if(COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden SCUDO_CFLAGS)
18 append_list_if(COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG -fno-exceptions SCUDO_CFLAGS)
20 append_list_if(COMPILER_RT_HAS_WNO_PEDANTIC -Wno-pedantic SCUDO_CFLAGS)
22 # FIXME: find cleaner way to agree with GWPAsan flags
23 append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto SCUDO_CFLAGS)
26 list(APPEND SCUDO_CFLAGS -O0 -DSCUDO_DEBUG=1)
28 list(APPEND SCUDO_CFLAGS -O3)
33 list(APPEND SCUDO_LINK_FLAGS -Wl,-z,defs,-z,now,-z,relro)
35 list(APPEND SCUDO_LINK_FLAGS -ffunction-sections -fdata-sections -Wl,--gc-sections)
37 # We don't use the C++ standard library, so avoid including it by mistake.
38 append_list_if(COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ SCUDO_LINK_FLAGS)
41 list(APPEND SCUDO_CFLAGS -fno-emulated-tls)
43 # Put the shared library in the global group. For more details, see
44 # android-changes-for-ndk-developers.md#changes-to-library-search-order
45 append_list_if(COMPILER_RT_HAS_Z_GLOBAL -Wl,-z,global SCUDO_LINK_FLAGS)
84 include/scudo/interface.h
100 # Enable the SSE 4.2 instruction set for crc32_hw.cpp, if available.
101 if (COMPILER_RT_HAS_MSSE4_2_FLAG)
102 set_source_files_properties(crc32_hw.cpp PROPERTIES COMPILE_FLAGS -msse4.2)
105 # Enable the AArch64 CRC32 feature for crc32_hw.cpp, if available.
106 # Note that it is enabled by default starting with armv8.1-a.
107 if (COMPILER_RT_HAS_MCRC_FLAG)
108 set_source_files_properties(crc32_hw.cpp PROPERTIES COMPILE_FLAGS -mcrc)
111 set(SCUDO_SOURCES_C_WRAPPERS
115 set(SCUDO_SOURCES_CXX_WRAPPERS
119 set(SCUDO_OBJECT_LIBS)
121 if (COMPILER_RT_HAS_GWP_ASAN)
122 add_dependencies(scudo_standalone gwp_asan)
123 list(APPEND SCUDO_OBJECT_LIBS
124 RTGwpAsan RTGwpAsanBacktraceLibc RTGwpAsanSegvHandler
125 RTGwpAsanOptionsParser)
127 append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG -fno-omit-frame-pointer
128 -mno-omit-leaf-frame-pointer
130 list(APPEND SCUDO_CFLAGS -DGWP_ASAN_HOOKS)
136 append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread SCUDO_LINK_FLAGS)
138 append_list_if(FUCHSIA zircon SCUDO_LINK_LIBS)
140 if(COMPILER_RT_HAS_SCUDO_STANDALONE)
141 add_compiler_rt_object_libraries(RTScudoStandalone
142 ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH}
143 SOURCES ${SCUDO_SOURCES}
144 ADDITIONAL_HEADERS ${SCUDO_HEADERS}
145 CFLAGS ${SCUDO_CFLAGS})
146 add_compiler_rt_object_libraries(RTScudoStandaloneCWrappers
147 ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH}
148 SOURCES ${SCUDO_SOURCES_C_WRAPPERS}
149 ADDITIONAL_HEADERS ${SCUDO_HEADERS}
150 CFLAGS ${SCUDO_CFLAGS})
151 add_compiler_rt_object_libraries(RTScudoStandaloneCxxWrappers
152 ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH}
153 SOURCES ${SCUDO_SOURCES_CXX_WRAPPERS}
154 ADDITIONAL_HEADERS ${SCUDO_HEADERS}
155 CFLAGS ${SCUDO_CFLAGS})
157 add_compiler_rt_runtime(clang_rt.scudo_standalone
159 ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH}
160 SOURCES ${SCUDO_SOURCES} ${SCUDO_SOURCES_C_WRAPPERS}
161 ADDITIONAL_HEADERS ${SCUDO_HEADERS}
162 CFLAGS ${SCUDO_CFLAGS}
163 OBJECT_LIBS ${SCUDO_OBJECT_LIBS}
164 PARENT_TARGET scudo_standalone)
165 add_compiler_rt_runtime(clang_rt.scudo_standalone_cxx
167 ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH}
168 SOURCES ${SCUDO_SOURCES_CXX_WRAPPERS}
169 ADDITIONAL_HEADERS ${SCUDO_HEADERS}
170 CFLAGS ${SCUDO_CFLAGS}
171 PARENT_TARGET scudo_standalone)
173 add_compiler_rt_runtime(clang_rt.scudo_standalone
175 ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH}
176 SOURCES ${SCUDO_SOURCES} ${SCUDO_SOURCES_C_WRAPPERS} ${SCUDO_SOURCES_CXX_WRAPPERS}
177 ADDITIONAL_HEADERS ${SCUDO_HEADERS}
178 CFLAGS ${SCUDO_CFLAGS}
179 OBJECT_LIBS ${SCUDO_OBJECT_LIBS}
180 LINK_FLAGS ${SCUDO_LINK_FLAGS}
181 LINK_LIBS ${SCUDO_LINK_LIBS}
182 PARENT_TARGET scudo_standalone)
184 add_subdirectory(benchmarks)
185 if(COMPILER_RT_INCLUDE_TESTS)
186 add_subdirectory(tests)