Skip to content

Commit

Permalink
[gn] attempt to port 53a81d4 (win/asan dynamic runtime)
Browse files Browse the repository at this point in the history
Based on the output of llvm/utils/gn/build/sync_source_lists_from_cmake.py
and reading the diff, but not actually tested on Windows.
  • Loading branch information
nico committed Sep 10, 2024
1 parent 0ccc609 commit 4a63d62
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 54 deletions.
30 changes: 14 additions & 16 deletions llvm/utils/gn/secondary/compiler-rt/lib/asan/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,6 @@ if (current_toolchain == host_toolchain) {
sources = [ "asan_preinit.cpp" ]
}

source_set("weak_interception") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
sources = [ "asan_win_weak_interception.cpp" ]
defines = [ "SANITIZER_DYNAMIC" ]
}

shared_library("asan_shared_library") {
output_dir = crt_current_out_dir
if (current_os == "mac") {
Expand Down Expand Up @@ -242,22 +235,25 @@ if (current_toolchain == host_toolchain) {
}
}
if (current_os == "win") {
static_library("asan_dll_thunk") {
static_library("asan_static_runtime_thunk") {
output_dir = crt_current_out_dir
output_name = "clang_rt.asan_dll_thunk$crt_current_target_suffix"
output_name = "clang_rt.asan_static_runtime_thunk$crt_current_target_suffix"
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
complete_static_lib = true
configs -= [ "//llvm/utils/gn/build:thin_archive" ]
sources = [
"asan_globals_win.cpp",
"asan_win_dll_thunk.cpp",
"asan_malloc_win_thunk.cpp",
"asan_win_common_runtime_thunk.cpp",
"asan_win_static_runtime_thunk.cpp",
]
defines = [ "SANITIZER_DLL_THUNK" ]
defines = [ "SANITIZER_STATIC_RUNTIME_THUNK" ]
deps = [
"//compiler-rt/lib/interception:sources",
"//compiler-rt/lib/sanitizer_common:dll_thunk",
"//compiler-rt/lib/ubsan:dll_thunk",
"//compiler-rt/lib/sanitizer_common:runtime_thunk",
"//compiler-rt/lib/sanitizer_common:sancov_runtime_thunk",
"//compiler-rt/lib/ubsan:runtime_thunk",
]
}
static_library("asan_dynamic_runtime_thunk") {
Expand All @@ -270,12 +266,14 @@ if (current_toolchain == host_toolchain) {
configs -= [ "//llvm/utils/gn/build:thin_archive" ]
sources = [
"asan_globals_win.cpp",
"asan_win_common_runtime_thunk.cpp",
"asan_win_dynamic_runtime_thunk.cpp",
]
defines = [ "SANITIZER_DYNAMIC_RUNTIME_THUNK" ]
deps = [
"//compiler-rt/lib/sanitizer_common:dynamic_runtime_thunk",
"//compiler-rt/lib/ubsan:dynamic_runtime_thunk",
"//compiler-rt/lib/sanitizer_common:runtime_thunk",
"//compiler-rt/lib/sanitizer_common:sancov_runtime_thunk",
"//compiler-rt/lib/ubsan:runtime_thunk",
]
cflags = [ "-Zl" ]
}
Expand All @@ -284,7 +282,7 @@ if (current_toolchain == host_toolchain) {
deps = [ ":asan_shared_library" ]
if (current_os == "win") {
deps += [
":asan_dll_thunk",
":asan_static_runtime_thunk",
":asan_dynamic_runtime_thunk",
]
}
Expand Down
38 changes: 17 additions & 21 deletions llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -167,42 +167,38 @@ source_set("sources") {
"sanitizer_vector.h",
"sanitizer_win.cpp",
"sanitizer_win.h",
"sanitizer_win_interception.cpp",
"sanitizer_win_interception.h",
"sanitizer_win_defs.h",
"sanitizer_win_dll_thunk.h",
"sanitizer_win_weak_interception.h",
"sanitizer_win_thunk_interception.h",
]
}

source_set("weak_interception") {
source_set("runtime_thunk") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
sources = [
"sanitizer_coverage_win_weak_interception.cpp",
"sanitizer_win_weak_interception.cpp",
sources = [ "sanitizer_win_thunk_interception.cpp" ]
defines = [
"SANITIZER_DYNAMIC_RUNTIME_THUNK",
"SANITIZER_STATIC_RUNTIME_THUNK",
]
defines = [ "SANITIZER_DYNAMIC" ]
cflags = []
if (current_os == "win") {
cflags += [ "-Zl" ]
}
}

source_set("dll_thunk") {
source_set("sancov_runtime_thunk") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
sources = [
"sanitizer_coverage_win_dll_thunk.cpp",
"sanitizer_coverage_win_runtime_thunk.cpp",
"sanitizer_coverage_win_sections.cpp",
"sanitizer_win_dll_thunk.cpp",
]
defines = [ "SANITIZER_DLL_THUNK" ]
}

source_set("dynamic_runtime_thunk") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
sources = [
"sanitizer_coverage_win_dynamic_runtime_thunk.cpp",
"sanitizer_coverage_win_sections.cpp",
"sanitizer_win_dynamic_runtime_thunk.cpp",
defines = [
"SANITIZER_DYNAMIC_RUNTIME_THUNK",
"SANITIZER_STATIC_RUNTIME_THUNK",
]
defines = [ "SANITIZER_DYNAMIC_RUNTIME_THUNK" ]
cflags = []
if (current_os == "win") {
cflags += [ "-Zl" ]
Expand Down
23 changes: 6 additions & 17 deletions llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,14 @@ source_set("sources") {
]
}

source_set("weak_interception") {
source_set("runtime_thunk") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
sources = [ "ubsan_win_weak_interception.cpp" ]
defines = [ "SANITIZER_DYNAMIC" ]
}

source_set("dll_thunk") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
sources = [ "ubsan_win_dll_thunk.cpp" ]
defines = [ "SANITIZER_DLL_THUNK" ]
}

source_set("dynamic_runtime_thunk") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
defines = [ "SANITIZER_DYNAMIC_RUNTIME_THUNK" ]
sources = [ "ubsan_win_dynamic_runtime_thunk.cpp" ]
sources = [ "ubsan_win_runtime_thunk.cpp" ]
defines = [
"SANITIZER_DYNAMIC_RUNTIME_THUNK",
"SANITIZER_STATIC_RUNTIME_THUNK",
]
}

source_set("standalone_sources") {
Expand Down

0 comments on commit 4a63d62

Please sign in to comment.