Index: llvm/trunk/utils/gn/secondary/clang/runtimes.gni =================================================================== --- llvm/trunk/utils/gn/secondary/clang/runtimes.gni +++ llvm/trunk/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" +} Index: llvm/trunk/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn +++ llvm/trunk/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn @@ -11,7 +11,7 @@ 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", Index: llvm/trunk/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn +++ llvm/trunk/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn @@ -16,10 +16,10 @@ "--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 @@ 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_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 @@ 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 = [ Index: llvm/trunk/utils/gn/secondary/compiler-rt/target.gni =================================================================== --- llvm/trunk/utils/gn/secondary/compiler-rt/target.gni +++ llvm/trunk/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 @@ 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) } Index: llvm/trunk/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn +++ llvm/trunk/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn @@ -11,7 +11,7 @@ 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 @@ 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=[]" ]