[llvm] c870e36 - gn build: Only build the hwasan runtime in aliasing mode on x86.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Mon May 17 11:49:08 PDT 2021


Author: Peter Collingbourne
Date: 2021-05-17T11:48:49-07:00
New Revision: c870e36be1b21c1f306927fc9eb983390e434278

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

LOG: gn build: Only build the hwasan runtime in aliasing mode on x86.

The LAM mode is currently untested by check-hwasan, so we only need
to build the runtime in aliasing mode. Because LAM mode will always
need to be conditional (because only certain hardware will support
it) we can always just disable the LAM lit tests if it ever starts
being tested.

Added: 
    

Modified: 
    llvm/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/llvm/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn
index 919d2347b2bc4..10089350671e3 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn
@@ -1,5 +1,11 @@
 import("//compiler-rt/target.gni")
 
+if (current_cpu == "x64") {
+  hwasan_name = "hwasan_aliases"
+} else {
+  hwasan_name = "hwasan"
+}
+
 action("version_script") {
   script = "//compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py"
   sources = [ "hwasan.syms.extra" ]
@@ -13,10 +19,10 @@ action("version_script") {
     "--extra",
     rebase_path(sources[0], root_build_dir),
     rebase_path(
-        "$crt_current_out_dir/libclang_rt.hwasan$crt_current_target_suffix.a",
+        "$crt_current_out_dir/libclang_rt.$hwasan_name$crt_current_target_suffix.a",
         root_build_dir),
     rebase_path(
-        "$crt_current_out_dir/libclang_rt.hwasan_cxx$crt_current_target_suffix.a",
+        "$crt_current_out_dir/libclang_rt.${hwasan_name}_cxx$crt_current_target_suffix.a",
         root_build_dir),
     "--nm-executable",
     "nm",
@@ -29,6 +35,9 @@ source_set("sources") {
   configs -= [ "//llvm/utils/gn/build:llvm_code" ]
   configs += [ "//llvm/utils/gn/build:crt_code" ]
   defines = [ "HWASAN_WITH_INTERCEPTORS=1" ]
+  if (current_cpu == "x64") {
+    defines += [ "HWASAN_ALIASING_MODE" ]
+  }
   deps = [
     "//compiler-rt/lib/interception:sources",
     "//compiler-rt/lib/sanitizer_common:sources",
@@ -76,7 +85,7 @@ source_set("cxx_sources") {
 
 static_library("hwasan") {
   output_dir = crt_current_out_dir
-  output_name = "clang_rt.hwasan$crt_current_target_suffix"
+  output_name = "clang_rt.$hwasan_name$crt_current_target_suffix"
   complete_static_lib = true
   configs -= [
     "//llvm/utils/gn/build:llvm_code",
@@ -88,7 +97,7 @@ static_library("hwasan") {
 
 static_library("hwasan_cxx") {
   output_dir = crt_current_out_dir
-  output_name = "clang_rt.hwasan_cxx$crt_current_target_suffix"
+  output_name = "clang_rt.${hwasan_name}_cxx$crt_current_target_suffix"
   complete_static_lib = true
   configs -= [
     "//llvm/utils/gn/build:llvm_code",
@@ -100,7 +109,7 @@ static_library("hwasan_cxx") {
 
 shared_library("hwasan_shared") {
   output_dir = crt_current_out_dir
-  output_name = "clang_rt.hwasan$crt_current_target_suffix"
+  output_name = "clang_rt.$hwasan_name$crt_current_target_suffix"
   configs -= [ "//llvm/utils/gn/build:llvm_code" ]
   configs += [ "//llvm/utils/gn/build:crt_code" ]
   deps = [


        


More information about the llvm-commits mailing list