[llvm] 4066591 - gn build: Add support for building scudo and its unit tests.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 18:12:59 PST 2019


Author: Peter Collingbourne
Date: 2019-12-05T18:12:36-08:00
New Revision: 4066591841408223dbb811a3e36df41347efcf70

URL: https://github.com/llvm/llvm-project/commit/4066591841408223dbb811a3e36df41347efcf70
DIFF: https://github.com/llvm/llvm-project/commit/4066591841408223dbb811a3e36df41347efcf70.diff

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

Differential Revision: https://reviews.llvm.org/D71081

Added: 
    llvm/utils/gn/secondary/compiler-rt/lib/scudo/BUILD.gn
    llvm/utils/gn/secondary/compiler-rt/lib/scudo/standalone/BUILD.gn
    llvm/utils/gn/secondary/compiler-rt/lib/scudo/standalone/tests/BUILD.gn

Modified: 
    llvm/utils/gn/secondary/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/llvm/utils/gn/secondary/BUILD.gn b/llvm/utils/gn/secondary/BUILD.gn
index 4e5016445ecb..491fc8952f79 100644
--- a/llvm/utils/gn/secondary/BUILD.gn
+++ b/llvm/utils/gn/secondary/BUILD.gn
@@ -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",
   ]

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
index 000000000000..f0fdae1c1c00
--- /dev/null
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/scudo/BUILD.gn
@@ -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",
+  ]
+}

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
index 000000000000..245ba18643ab
--- /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
index 000000000000..6fb11d27a955
--- /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
+}


        


More information about the llvm-commits mailing list