gn build: Add support for building scudo and its unit tests.

Differential Revision: https://reviews.llvm.org/D71081
This commit is contained in:
Peter Collingbourne 2019-11-19 14:51:48 -08:00
parent b3516a0d4a
commit 4066591841
4 changed files with 191 additions and 0 deletions

View File

@ -7,6 +7,7 @@ group("default") {
"//clang-tools-extra/clangd/test",
"//clang-tools-extra/test",
"//clang/test",
"//compiler-rt/lib/scudo",
"//lld/test",
"//llvm/test",
]

View File

@ -0,0 +1,48 @@
import("//llvm/utils/gn/build/toolchain/compiler.gni")
supported_toolchains = []
if (target_os != "win") {
supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_unix" ]
}
if (android_ndk_path != "") {
supported_toolchains += [
"//llvm/utils/gn/build/toolchain:stage2_android_aarch64",
"//llvm/utils/gn/build/toolchain:stage2_android_arm",
]
}
group("scudo") {
deps = []
foreach(toolchain, supported_toolchains) {
deps += [
"standalone/tests:ScudoCUnitTest($toolchain)",
"standalone/tests:ScudoCxxUnitTest($toolchain)",
"standalone/tests:ScudoUnitTest($toolchain)",
]
}
testonly = true
}
# This target is unused, it only exists to satisfy
# sync_source_lists_from_cmake.py.
source_set("sources") {
sources = [
"scudo_allocator.cpp",
"scudo_allocator.h",
"scudo_allocator_combined.h",
"scudo_allocator_secondary.h",
"scudo_crc32.cpp",
"scudo_crc32.h",
"scudo_errors.cpp",
"scudo_errors.h",
"scudo_flags.cpp",
"scudo_flags.h",
"scudo_interface_internal.h",
"scudo_malloc.cpp",
"scudo_platform.h",
"scudo_termination.cpp",
"scudo_tsd.h",
"scudo_tsd_exclusive.cpp",
"scudo_tsd_shared.cpp",
]
}

View File

@ -0,0 +1,84 @@
import("//compiler-rt/target.gni")
source_set("sources") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
sources = [
"allocator_config.h",
"atomic_helpers.h",
"bytemap.h",
"checksum.cpp",
"checksum.h",
"chunk.h",
"combined.h",
"common.cpp",
"crc32_hw.cpp",
"flags.cpp",
"flags.h",
"flags_parser.cpp",
"flags_parser.h",
"fuchsia.cpp",
"fuchsia.h",
"interface.h",
"internal_defs.h",
"linux.cpp",
"linux.h",
"list.h",
"local_cache.h",
"mutex.h",
"platform.h",
"primary32.h",
"primary64.h",
"quarantine.h",
"release.h",
"report.cpp",
"report.h",
"secondary.h",
"size_class_map.h",
"stats.h",
"string_utils.cpp",
"string_utils.h",
"tsd.h",
"tsd_exclusive.h",
"tsd_shared.h",
"vector.h",
"wrappers_c.h",
"wrappers_c_checks.h",
]
if (current_cpu == "arm" || current_cpu == "arm64") {
cflags = [ "-mcrc" ]
}
if (current_cpu == "x64") {
cflags = [ "-msse4.2" ]
}
public_configs = [ ":scudo_config" ]
}
source_set("c_wrapper_sources") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
sources = [
"wrappers_c.cpp",
]
public_configs = [ ":scudo_config" ]
}
source_set("cxx_wrapper_sources") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
sources = [
"wrappers_cpp.cpp",
]
public_configs = [ ":scudo_config" ]
}
config("scudo_config") {
include_dirs = [ "//compiler-rt/lib/scudo/standalone" ]
if (current_os == "android") {
cflags = [ "-fno-emulated-tls" ]
}
}

View File

@ -0,0 +1,58 @@
import("//llvm/utils/unittest/unittest.gni")
unittest("ScudoUnitTest") {
configs += [ "//llvm/utils/gn/build:crt_code" ]
deps = [
"//compiler-rt/lib/scudo/standalone:sources",
]
sources = [
"atomic_test.cpp",
"bytemap_test.cpp",
"checksum_test.cpp",
"chunk_test.cpp",
"combined_test.cpp",
"flags_test.cpp",
"list_test.cpp",
"map_test.cpp",
"mutex_test.cpp",
"primary_test.cpp",
"quarantine_test.cpp",
"release_test.cpp",
"report_test.cpp",
"scudo_unit_test_main.cpp",
"secondary_test.cpp",
"size_class_map_test.cpp",
"stats_test.cpp",
"strings_test.cpp",
"tsd_test.cpp",
"vector_test.cpp",
]
has_custom_main = true
}
unittest("ScudoCUnitTest") {
configs += [ "//llvm/utils/gn/build:crt_code" ]
deps = [
"//compiler-rt/lib/scudo/standalone:c_wrapper_sources",
"//compiler-rt/lib/scudo/standalone:sources",
]
sources = [
"scudo_unit_test_main.cpp",
"wrappers_c_test.cpp",
]
has_custom_main = true
}
unittest("ScudoCxxUnitTest") {
configs += [ "//llvm/utils/gn/build:crt_code" ]
deps = [
"//compiler-rt/lib/scudo/standalone:c_wrapper_sources",
"//compiler-rt/lib/scudo/standalone:cxx_wrapper_sources",
"//compiler-rt/lib/scudo/standalone:sources",
]
sources = [
"scudo_unit_test_main.cpp",
"wrappers_cpp_test.cpp",
]
has_custom_main = true
}