+impl NativeLibBoilerplate {
+ /// On OSX we don't want to ship the exact filename that compiler-rt builds.
+ /// This conflicts with the system and ours is likely a wildly different
+ /// version, so they can't be substituted.
+ ///
+ /// As a result, we rename it here but we need to also use
+ /// `install_name_tool` on OSX to rename the commands listed inside of it to
+ /// ensure it's linked against correctly.
+ pub fn fixup_sanitizer_lib_name(&self, sanitizer_name: &str) {
+ if env::var("TARGET").unwrap() != "x86_64-apple-darwin" {
+ return
+ }
+
+ let dir = self.out_dir.join("build/lib/darwin");
+ let name = format!("clang_rt.{}_osx_dynamic", sanitizer_name);
+ let src = dir.join(&format!("lib{}.dylib", name));
+ let new_name = format!("lib__rustc__{}.dylib", name);
+ let dst = dir.join(&new_name);
+
+ println!("{} => {}", src.display(), dst.display());
+ fs::rename(&src, &dst).unwrap();
+ let status = Command::new("install_name_tool")
+ .arg("-id")
+ .arg(format!("@rpath/{}", new_name))
+ .arg(&dst)
+ .status()
+ .expect("failed to execute `install_name_tool`");
+ assert!(status.success());
+ }
+}
+