about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2024-08-03 14:18:55 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2024-08-03 14:20:18 +0300
commit1f873f9cf1e6307d1f0bee85f7a866f9531b8a98 (patch)
treeab485fe02d6413e8a84e890e3ca2bc33eee63b1f /compiler/rustc_codegen_ssa/src
parent35977b47cc80e54af8e8559231945bada6fe1c01 (diff)
downloadrust-1f873f9cf1e6307d1f0bee85f7a866f9531b8a98.tar.gz
rust-1f873f9cf1e6307d1f0bee85f7a866f9531b8a98.zip
Fix linking to sanitizers on Apple targets
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index 93ddd1ef044..653895380be 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -2099,10 +2099,14 @@ fn add_library_search_dirs(
 
     // Toolchains for some targets may ship `libunwind.a`, but place it into the main sysroot
     // library directory instead of the self-contained directories.
+    // Sanitizer libraries have the same issue and are also linked by name on Apple targets.
     // The targets here should be in sync with `copy_third_party_objects` in bootstrap.
-    // FIXME: implement `-Clink-self-contained=+/-unwind`, move the shipped libunwind
-    // to self-contained directory, and stop adding this search path.
-    if sess.target.vendor == "fortanix" || sess.target.os == "linux" || sess.target.os == "fuchsia"
+    // FIXME: implement `-Clink-self-contained=+/-unwind,+/-sanitizers`, move the shipped libunwind
+    // and sanitizers to self-contained directory, and stop adding this search path.
+    if sess.target.vendor == "fortanix"
+        || sess.target.os == "linux"
+        || sess.target.os == "fuchsia"
+        || sess.target.is_like_osx && !sess.opts.unstable_opts.sanitizer.is_empty()
     {
         let lib_path = sess.target_filesearch(PathKind::Native).get_lib_path();
         cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path));