diff --git a/llvm/utils/gn/secondary/BUILD.gn b/llvm/utils/gn/secondary/BUILD.gn --- a/llvm/utils/gn/secondary/BUILD.gn +++ b/llvm/utils/gn/secondary/BUILD.gn @@ -7,6 +7,7 @@ "//clang-tools-extra/clangd/test", "//clang-tools-extra/test", "//clang/test", + "//compiler-rt/lib/scudo", "//lld/test", "//llvm/test", ] diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/scudo/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/scudo/BUILD.gn new file mode 100644 --- /dev/null +++ b/llvm/utils/gn/secondary/compiler-rt/lib/scudo/BUILD.gn @@ -0,0 +1,24 @@ +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 +} diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/scudo/standalone/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/scudo/standalone/BUILD.gn new file mode 100644 --- /dev/null +++ b/llvm/utils/gn/secondary/compiler-rt/lib/scudo/standalone/BUILD.gn @@ -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" ] + } +} diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/scudo/standalone/tests/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/scudo/standalone/tests/BUILD.gn new file mode 100644 --- /dev/null +++ b/llvm/utils/gn/secondary/compiler-rt/lib/scudo/standalone/tests/BUILD.gn @@ -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 +}