From: Petr Hosek Date: Sat, 6 Apr 2019 23:05:56 +0000 (+0000) Subject: [gn] Support for per-target runtime directory layout X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=003add3c6655ffa0dd063bdb91f5b72751ae8133;p=llvm [gn] Support for per-target runtime directory layout This change also introduces the clang_enable_per_target_runtime_dir to enable the use of per-target runtime directory layout which is the equivalent of LLVM_ENABLE_PER_TARGET_RUNTIME_DIR CMake option. Differential Revision: https://reviews.llvm.org/D60332 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357850 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/gn/secondary/clang/runtimes.gni b/utils/gn/secondary/clang/runtimes.gni new file mode 100644 index 00000000000..44c291e1b7b --- /dev/null +++ b/utils/gn/secondary/clang/runtimes.gni @@ -0,0 +1,13 @@ +import("//clang/resource_dir.gni") +import("//llvm/triples.gni") + +declare_args() { + # Use target triple as the name of the runtimes directory. + clang_enable_per_target_runtime_dir = false +} + +if (clang_enable_per_target_runtime_dir) { + runtimes_dir = "$clang_resource_dir/$llvm_target_triple/lib" +} else { + runtimes_dir = "$root_build_dir/lib" +} diff --git a/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn b/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn index dc830a5b273..2841fcac3df 100644 --- a/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn +++ b/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn @@ -11,7 +11,7 @@ declare_args() { static_library("builtins") { output_dir = crt_current_out_dir - output_name = "clang_rt.builtins-$crt_current_target" + output_name = "clang_rt.builtins$crt_current_target_suffix" complete_static_lib = true cflags = [ "-fPIC", diff --git a/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn b/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn index f5da8edc25d..ebc16c11b68 100644 --- a/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn +++ b/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn @@ -16,10 +16,10 @@ action("version_script") { "--version-list", "--extra", rebase_path(sources[0], root_build_dir), - rebase_path("$crt_current_out_dir/libclang_rt.hwasan-$crt_current_target.a", + rebase_path("$crt_current_out_dir/libclang_rt.hwasan$crt_current_target_suffix.a", root_build_dir), rebase_path( - "$crt_current_out_dir/libclang_rt.hwasan_cxx-$crt_current_target.a", + "$crt_current_out_dir/libclang_rt.hwasan_cxx$crt_current_target_suffix.a", root_build_dir), "-o", rebase_path(outputs[0], root_build_dir), @@ -75,7 +75,7 @@ source_set("cxx_sources") { static_library("hwasan") { output_dir = crt_current_out_dir - output_name = "clang_rt.hwasan-$crt_current_target" + output_name = "clang_rt.hwasan$crt_current_target_suffix" complete_static_lib = true configs -= [ "//llvm/utils/gn/build:llvm_code", @@ -89,7 +89,7 @@ static_library("hwasan") { static_library("hwasan_cxx") { output_dir = crt_current_out_dir - output_name = "clang_rt.hwasan_cxx-$crt_current_target" + output_name = "clang_rt.hwasan_cxx$crt_current_target_suffix" complete_static_lib = true configs -= [ "//llvm/utils/gn/build:llvm_code", @@ -103,7 +103,7 @@ static_library("hwasan_cxx") { shared_library("hwasan_shared") { output_dir = crt_current_out_dir - output_name = "clang_rt.hwasan-$crt_current_target" + output_name = "clang_rt.hwasan$crt_current_target_suffix" configs -= [ "//llvm/utils/gn/build:llvm_code" ] configs += [ "//llvm/utils/gn/build:crt_code" ] deps = [ diff --git a/utils/gn/secondary/compiler-rt/target.gni b/utils/gn/secondary/compiler-rt/target.gni index c511bed8204..50e581f5c9e 100644 --- a/utils/gn/secondary/compiler-rt/target.gni +++ b/utils/gn/secondary/compiler-rt/target.gni @@ -1,10 +1,5 @@ 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) -} +import("//clang/runtimes.gni") if (current_cpu == "x86") { crt_current_target_arch = "i386" @@ -16,7 +11,17 @@ if (current_cpu == "x86") { assert(false, "unimplemented current_cpu " + current_cpu) } -crt_current_target = crt_current_target_arch -if (current_os == "android") { - crt_current_target += "-android" +if (clang_enable_per_target_runtime_dir) { + crt_current_out_dir = runtimes_dir + + crt_current_target_suffix = "" +} else if (current_os == "linux" || current_os == "android") { + crt_current_out_dir = "$clang_resource_dir/lib/linux" + + crt_current_target_suffix = "-$crt_current_target_arch" + if (current_os == "android") { + crt_current_target_suffix += "-android" + } +} else { + assert(false, "unimplemented current_os " + current_os) } diff --git a/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn b/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn index ee658381dbd..f98622dd154 100644 --- a/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn +++ b/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn @@ -11,7 +11,7 @@ write_cmake_config("lit_site_cfg") { values = [ "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit", - "HWASAN_TEST_CONFIG_SUFFIX=-$crt_current_target", + "HWASAN_TEST_CONFIG_SUFFIX=$crt_current_target_suffix", "HWASAN_TEST_TARGET_CFLAGS=$target_flags_string", "HWASAN_TEST_TARGET_ARCH=$crt_current_target_arch", @@ -21,7 +21,7 @@ write_cmake_config("lit_site_cfg") { if (current_os == "android") { values += [ "HWASAN_ANDROID_FILES_TO_PUSH=[\"" + rebase_path( - "$crt_current_out_dir/libclang_rt.hwasan-$crt_current_target.so") + "\", \"" + rebase_path( + "$crt_current_out_dir/libclang_rt.hwasan$crt_current_target_suffix.so") + "\", \"" + rebase_path( "$root_out_dir/bin/llvm-symbolizer") + "\"]" ] } else { values += [ "HWASAN_ANDROID_FILES_TO_PUSH=[]" ]