Skip to content

Commit e2e32f0

Browse files
authored
[gn build] Add rules for crtbegin/end (#66012)
1 parent 4718b40 commit e2e32f0

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ group("lib") {
55
"//compiler-rt/lib/cfi:ignorelist($host_toolchain)",
66
]
77
if (current_os == "linux") {
8-
deps += [ "//compiler-rt/lib/msan" ]
8+
deps += [
9+
"//compiler-rt/lib/builtins:crt",
10+
"//compiler-rt/lib/msan",
11+
]
912
}
1013
if (current_os == "linux" || current_os == "android") {
1114
deps += [ "//compiler-rt/lib/ubsan_minimal" ]

llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,38 @@ static_library("builtins") {
574574
deps = lse_targets
575575
}
576576

577+
if (current_os == "linux") {
578+
source_set("crt_src") {
579+
sources = [
580+
"crtbegin.c",
581+
"crtend.c",
582+
]
583+
cflags = [
584+
"-std=c11",
585+
"-fPIC",
586+
]
587+
}
588+
copy("crtbegin") {
589+
# TODO: use get_target_outputs if it ever works with source_set to avoid hardcoding crt_src.crtbegin.o
590+
input_dir = get_label_info(":crt_src", "target_out_dir")
591+
sources = [ "$input_dir/crt_src.crtbegin.o" ]
592+
outputs = [ "$crt_current_out_dir/clang_rt.crtbegin.o" ]
593+
deps = [ ":crt_src" ]
594+
}
595+
copy("crtend") {
596+
input_dir = get_label_info(":crt_src", "target_out_dir")
597+
sources = [ "$input_dir/crt_src.crtend.o" ]
598+
outputs = [ "$crt_current_out_dir/clang_rt.crtend.o" ]
599+
deps = [ ":crt_src" ]
600+
}
601+
group("crt") {
602+
deps = [
603+
":crtbegin",
604+
":crtend",
605+
]
606+
}
607+
}
608+
577609
# Currently unused but necessary to make sync_source_lists_from_cmake.py happy.
578610
source_set("_unused") {
579611
sources = [

0 commit comments

Comments
 (0)