From cf2ed733d5293c75f22bcc586739d13d46269d43 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Mon, 11 Sep 2023 14:23:46 -0700 Subject: [PATCH] [gn build] Add rules for crtbegin/end --- .../gn/secondary/compiler-rt/lib/BUILD.gn | 5 ++- .../compiler-rt/lib/builtins/BUILD.gn | 32 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn index d8c75a01c6945..398b95a06b805 100644 --- a/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn +++ b/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn @@ -5,7 +5,10 @@ group("lib") { "//compiler-rt/lib/cfi:ignorelist($host_toolchain)", ] if (current_os == "linux") { - deps += [ "//compiler-rt/lib/msan" ] + deps += [ + "//compiler-rt/lib/builtins:crt", + "//compiler-rt/lib/msan", + ] } if (current_os == "linux" || current_os == "android") { deps += [ "//compiler-rt/lib/ubsan_minimal" ] diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn index 303a6c29d7b91..a45795d194c61 100644 --- a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn +++ b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn @@ -574,6 +574,38 @@ static_library("builtins") { deps = lse_targets } +if (current_os == "linux") { + source_set("crt_src") { + sources = [ + "crtbegin.c", + "crtend.c", + ] + cflags = [ + "-std=c11", + "-fPIC", + ] + } + copy("crtbegin") { + # TODO: use get_target_outputs if it ever works with source_set to avoid hardcoding crt_src.crtbegin.o + input_dir = get_label_info(":crt_src", "target_out_dir") + sources = [ "$input_dir/crt_src.crtbegin.o" ] + outputs = [ "$crt_current_out_dir/clang_rt.crtbegin.o" ] + deps = [ ":crt_src" ] + } + copy("crtend") { + input_dir = get_label_info(":crt_src", "target_out_dir") + sources = [ "$input_dir/crt_src.crtend.o" ] + outputs = [ "$crt_current_out_dir/clang_rt.crtend.o" ] + deps = [ ":crt_src" ] + } + group("crt") { + deps = [ + ":crtbegin", + ":crtend", + ] + } +} + # Currently unused but necessary to make sync_source_lists_from_cmake.py happy. source_set("_unused") { sources = [