[llvm] r351258 - gn build: Add a stage2 host toolchain and make the hwasan runtime buildable on x86_64 Linux.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 15 14:02:13 PST 2019
Author: pcc
Date: Tue Jan 15 14:02:12 2019
New Revision: 351258
URL: http://llvm.org/viewvc/llvm-project?rev=351258&view=rev
Log:
gn build: Add a stage2 host toolchain and make the hwasan runtime buildable on x86_64 Linux.
Differential Revision: https://reviews.llvm.org/D56711
Added:
llvm/trunk/utils/gn/secondary/compiler-rt/target.gni
Modified:
llvm/trunk/utils/gn/build/toolchain/BUILD.gn
llvm/trunk/utils/gn/secondary/BUILD.gn
llvm/trunk/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn
llvm/trunk/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn
Modified: llvm/trunk/utils/gn/build/toolchain/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/build/toolchain/BUILD.gn?rev=351258&r1=351257&r2=351258&view=diff
==============================================================================
--- llvm/trunk/utils/gn/build/toolchain/BUILD.gn (original)
+++ llvm/trunk/utils/gn/build/toolchain/BUILD.gn Tue Jan 15 14:02:12 2019
@@ -150,8 +150,10 @@ unix_toolchain("unix") {
}
}
-if (android_ndk_path != "") {
- unix_toolchain("stage2_android_aarch64") {
+template("stage2_unix_toolchain") {
+ unix_toolchain(target_name) {
+ forward_variables_from(invoker, "*")
+
cc = "bin/clang"
cxx = "bin/clang++"
ld = cxx
@@ -162,7 +164,19 @@ if (android_ndk_path != "") {
"//:lld($host_toolchain)",
"//:llvm-ar($host_toolchain)",
]
+ }
+}
+stage2_unix_toolchain("stage2_unix") {
+ toolchain_args = {
+ current_os = host_os
+ current_cpu = host_cpu
+ use_lld = host_os != "mac"
+ }
+}
+
+if (android_ndk_path != "") {
+ stage2_unix_toolchain("stage2_android_aarch64") {
toolchain_args = {
current_os = "android"
current_cpu = "arm64"
Modified: llvm/trunk/utils/gn/secondary/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/BUILD.gn?rev=351258&r1=351257&r2=351258&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/BUILD.gn Tue Jan 15 14:02:12 2019
@@ -9,9 +9,9 @@ group("default") {
"//llvm/test",
]
+ # FIXME: This should be a dependency of a test target instead of being
+ # depended on from here.
if (android_ndk_path != "") {
- # FIXME: This should be a dependency of a test target instead of being
- # depended on from here.
android_aarch64_toolchain =
"//llvm/utils/gn/build/toolchain:stage2_android_aarch64"
deps += [
@@ -19,6 +19,9 @@ group("default") {
"//llvm/tools/llvm-symbolizer($android_aarch64_toolchain)",
]
}
+ if (host_cpu == "x64" && host_os == "linux") {
+ deps += [ "//compiler-rt/lib/hwasan:hwasan_shared(//llvm/utils/gn/build/toolchain:stage2_unix)" ]
+ }
testonly = true
}
Modified: llvm/trunk/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn?rev=351258&r1=351257&r2=351258&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn Tue Jan 15 14:02:12 2019
@@ -1,10 +1,4 @@
-import("//clang/resource_dir.gni")
-
-# FIXME: Make this support more platforms.
-assert(current_os == "android")
-
-runtime_output_dir = "$clang_resource_dir/lib/linux"
-runtime_target = "aarch64-android"
+import("//compiler-rt/target.gni")
action("version_script") {
script = "//compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py"
@@ -22,10 +16,11 @@ action("version_script") {
"--version-list",
"--extra",
rebase_path(sources[0], root_build_dir),
- rebase_path("$runtime_output_dir/libclang_rt.hwasan-$runtime_target.a",
- root_build_dir),
- rebase_path("$runtime_output_dir/libclang_rt.hwasan_cxx-$runtime_target.a",
+ rebase_path("$crt_current_out_dir/libclang_rt.hwasan-$crt_current_target.a",
root_build_dir),
+ rebase_path(
+ "$crt_current_out_dir/libclang_rt.hwasan_cxx-$crt_current_target.a",
+ root_build_dir),
"-o",
rebase_path(outputs[0], root_build_dir),
]
@@ -66,8 +61,8 @@ source_set("cxx_sources") {
}
static_library("hwasan") {
- output_dir = runtime_output_dir
- output_name = "clang_rt.hwasan-$runtime_target"
+ output_dir = crt_current_out_dir
+ output_name = "clang_rt.hwasan-$crt_current_target"
complete_static_lib = true
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
@@ -77,8 +72,8 @@ static_library("hwasan") {
}
static_library("hwasan_cxx") {
- output_dir = runtime_output_dir
- output_name = "clang_rt.hwasan_cxx-$runtime_target"
+ output_dir = crt_current_out_dir
+ output_name = "clang_rt.hwasan_cxx-$crt_current_target"
complete_static_lib = true
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
@@ -88,8 +83,8 @@ static_library("hwasan_cxx") {
}
shared_library("hwasan_shared") {
- output_dir = runtime_output_dir
- output_name = "clang_rt.hwasan-$runtime_target"
+ output_dir = crt_current_out_dir
+ output_name = "clang_rt.hwasan-$crt_current_target"
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
deps = [
Modified: llvm/trunk/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn?rev=351258&r1=351257&r2=351258&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn Tue Jan 15 14:02:12 2019
@@ -1,6 +1,16 @@
source_set("sources") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
+ deps = [
+ "//llvm/utils/gn/build/libs/pthread",
+ ]
+ libs = []
+ if (current_os == "linux" || current_os == "android") {
+ libs += [ "dl" ]
+ }
+ if (current_os == "linux") {
+ libs += [ "rt" ]
+ }
sources = [
"sancov_flags.cc",
"sanitizer_allocator.cc",
@@ -67,4 +77,7 @@ source_set("sources") {
"sanitizer_unwind_win.cc",
"sanitizer_win.cc",
]
+ if (current_cpu == "x64") {
+ sources += [ "sanitizer_linux_x86_64.S" ]
+ }
}
Added: llvm/trunk/utils/gn/secondary/compiler-rt/target.gni
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/compiler-rt/target.gni?rev=351258&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/compiler-rt/target.gni (added)
+++ llvm/trunk/utils/gn/secondary/compiler-rt/target.gni Tue Jan 15 14:02:12 2019
@@ -0,0 +1,20 @@
+import("//clang/resource_dir.gni")
+
+if (current_os == "linux" || current_os == "android") {
+ crt_current_out_dir = "$clang_resource_dir/lib/linux"
+} else {
+ assert(false, "unimplemented current_os " + current_os)
+}
+
+if (current_cpu == "x64") {
+ crt_current_target_arch = "x86_64"
+} else if (current_cpu == "arm64") {
+ crt_current_target_arch = "aarch64"
+} else {
+ assert(false, "unimplemented current_cpu " + current_cpu)
+}
+
+crt_current_target = crt_current_target_arch
+if (current_os == "android") {
+ crt_current_target += "-android"
+}
More information about the llvm-commits
mailing list