Skip to content

Commit 6ebc685

Browse files
danakjcopybara-github
authored andcommitted
Tell rustc that we will always be providing clangrt libraries
This prevents rustc from trying to link sanitizer runtimes, so we don't need to make fake ones in our sysroot anymore. And this avoids rustc trying to link the Linux runtime when we're targeting Windows due to rust-lang/rust#131363. When this flag is specified, rustc avoids adding sanitizer libraries here: https://github.com/rust-lang/rust/blob/7caad6925314911eefe54b040d4bc5be940e8f92/compiler/rustc_codegen_ssa/src/back/link.rs#L1263-L1267 [email protected] Bug: 371512562 Cq-Include-Trybots: luci.chromium.try:win-asan,android-rust-arm32-rel,android-rust-arm64-dbg,android-rust-arm64-rel,linux-rust-x64-rel,linux-rust-x64-dbg,mac-rust-x64-dbg,win-rust-x64-dbg,win-rust-x64-rel,mac_chromium_asan_rel_ng,linux_chromium_asan_rel_ng Change-Id: Ifcc6cb841af2697c6ca5ab3b64adcc995683fbc6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5913992 Commit-Queue: danakj <[email protected]> Reviewed-by: Arthur Eubanks <[email protected]> Cr-Commit-Position: refs/heads/main@{#1365077} NOKEYCHECK=True GitOrigin-RevId: 7d029cad43d3bf03b0464d9e3c55cc0f8b5474e2
1 parent 884faaf commit 6ebc685

File tree

2 files changed

+3
-46
lines changed

2 files changed

+3
-46
lines changed

Diff for: config/compiler/BUILD.gn

+3
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,9 @@ config("compiler") {
10411041
# For deterministic builds, keep the local machine's current working
10421042
# directory from appearing in build outputs.
10431043
"-Zremap-cwd-prefix=.",
1044+
1045+
# We use clang-rt sanitizer runtimes.
1046+
"-Zexternal-clangrt",
10441047
]
10451048

10461049
if (!is_win || force_rustc_color_output) {

Diff for: rust/std/BUILD.gn

-46
Original file line numberDiff line numberDiff line change
@@ -236,51 +236,6 @@ if (toolchain_has_rust) {
236236
visibility = [ ":*" ]
237237
}
238238

239-
# When given -Zsanitize=..., rustc insists on passing a sanitizer runtime to
240-
# the linker it invokes. Unfortunately, our C++ ldflags already tell the
241-
# linker to link against a C++ sanitizer runtime - which contains the same
242-
# symbols. So, make a blank library.
243-
# The list of relevant sanitizers here is taken from
244-
# https://github.com/rust-lang/rust/blob/7e7483d26e3cec7a44ef00cf7ae6c9c8c918bec6/compiler/rustc_codegen_ssa/src/back/link.rs#L1148
245-
template("rustc_sanitizer_runtime") {
246-
rt_name = target_name
247-
not_needed([ "invoker" ])
248-
static_library("sanitizer_rt_$rt_name") {
249-
sources = []
250-
output_name = "librustc-${rust_channel}_rt.$rt_name"
251-
output_dir = "$local_rustc_sysroot/$sysroot_lib_subdir"
252-
if (is_win) {
253-
arflags = [ "/llvmlibempty" ]
254-
}
255-
}
256-
}
257-
rustc_sanitizer_runtimes = []
258-
if (is_asan) {
259-
rustc_sanitizer_runtime("asan") {
260-
}
261-
rustc_sanitizer_runtimes += [ ":sanitizer_rt_asan" ]
262-
}
263-
if (is_lsan) {
264-
rustc_sanitizer_runtime("lsan") {
265-
}
266-
rustc_sanitizer_runtimes += [ ":sanitizer_rt_lsan" ]
267-
}
268-
if (is_msan) {
269-
rustc_sanitizer_runtime("msan") {
270-
}
271-
rustc_sanitizer_runtimes += [ ":sanitizer_rt_msan" ]
272-
}
273-
if (is_tsan) {
274-
rustc_sanitizer_runtime("tsan") {
275-
}
276-
rustc_sanitizer_runtimes += [ ":sanitizer_rt_tsan" ]
277-
}
278-
if (is_hwasan) {
279-
rustc_sanitizer_runtime("hwasan") {
280-
}
281-
rustc_sanitizer_runtimes += [ ":sanitizer_rt_hwasan" ]
282-
}
283-
284239
# Builds and links against the Rust stdlib. Both Rust and C++ targets should
285240
# depend on this, as it provides the path to the library and includes the
286241
# allocator hooks.
@@ -299,7 +254,6 @@ if (toolchain_has_rust) {
299254
foreach(libname, stdlib_files + skip_stdlib_files) {
300255
deps += [ "rules:$libname" ]
301256
}
302-
deps += rustc_sanitizer_runtimes
303257

304258
public_deps = [ ":remap_alloc" ]
305259
}

0 commit comments

Comments
 (0)