|
1 | 1 | use std::path::PathBuf;
|
2 | 2 | use std::{env, fs};
|
3 | 3 |
|
4 |
| -use crate::core::build_steps::compile; |
5 | 4 | use crate::core::build_steps::toolstate::ToolState;
|
| 5 | +use crate::core::build_steps::{compile, llvm}; |
6 | 6 | use crate::core::builder;
|
7 | 7 | use crate::core::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step};
|
8 | 8 | use crate::core::config::TargetSelection;
|
@@ -722,29 +722,50 @@ impl Step for Cargo {
|
722 | 722 |
|
723 | 723 | #[derive(Debug, Clone, Hash, PartialEq, Eq)]
|
724 | 724 | pub struct LldWrapper {
|
725 |
| - pub compiler: Compiler, |
726 |
| - pub target: TargetSelection, |
| 725 | + pub build_compiler: Compiler, |
| 726 | + pub target_compiler: Compiler, |
727 | 727 | }
|
728 | 728 |
|
729 | 729 | impl Step for LldWrapper {
|
730 |
| - type Output = PathBuf; |
| 730 | + type Output = (); |
731 | 731 |
|
732 | 732 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
733 | 733 | run.never()
|
734 | 734 | }
|
735 | 735 |
|
736 |
| - fn run(self, builder: &Builder<'_>) -> PathBuf { |
737 |
| - builder.ensure(ToolBuild { |
738 |
| - compiler: self.compiler, |
739 |
| - target: self.target, |
| 736 | + fn run(self, builder: &Builder<'_>) { |
| 737 | + if builder.config.dry_run() { |
| 738 | + return; |
| 739 | + } |
| 740 | + |
| 741 | + let target = self.target_compiler.host; |
| 742 | + |
| 743 | + let executable = builder.ensure(ToolBuild { |
| 744 | + compiler: self.build_compiler, |
| 745 | + target, |
740 | 746 | tool: "lld-wrapper",
|
741 | 747 | mode: Mode::ToolStd,
|
742 | 748 | path: "src/tools/lld-wrapper",
|
743 | 749 | source_type: SourceType::InTree,
|
744 | 750 | extra_features: Vec::new(),
|
745 | 751 | allow_features: "",
|
746 | 752 | cargo_args: Vec::new(),
|
747 |
| - }) |
| 753 | + }); |
| 754 | + |
| 755 | + let libdir_bin = builder.sysroot_target_bindir(self.target_compiler, target); |
| 756 | + t!(fs::create_dir_all(&libdir_bin)); |
| 757 | + |
| 758 | + let lld_install = builder.ensure(llvm::Lld { target }); |
| 759 | + let src_exe = exe("lld", target); |
| 760 | + let dst_exe = exe("rust-lld", target); |
| 761 | + |
| 762 | + builder.copy_link(&lld_install.join("bin").join(src_exe), &libdir_bin.join(dst_exe)); |
| 763 | + let self_contained_lld_dir = libdir_bin.join("gcc-ld"); |
| 764 | + t!(fs::create_dir_all(&self_contained_lld_dir)); |
| 765 | + |
| 766 | + for name in crate::LLD_FILE_NAMES { |
| 767 | + builder.copy_link(&executable, &self_contained_lld_dir.join(exe(name, target))); |
| 768 | + } |
748 | 769 | }
|
749 | 770 | }
|
750 | 771 |
|
|
0 commit comments