|
@@ -1247,35 +1247,12 @@ impl BuildRequest {
|
|
//
|
|
//
|
|
// We dump its output directly into the patch exe location which is different than how rustc
|
|
// We dump its output directly into the patch exe location which is different than how rustc
|
|
// does it since it uses llvm-objcopy into the `target/debug/` folder.
|
|
// does it since it uses llvm-objcopy into the `target/debug/` folder.
|
|
- let res = match cfg!(target_os = "windows") {
|
|
|
|
- // Handle windows response files
|
|
|
|
- // https://learn.microsoft.com/en-us/cpp/build/reference/at-specify-a-linker-response-file?view=msvc-170
|
|
|
|
- true => {
|
|
|
|
- let cmd_file = tempfile::NamedTempFile::new()?;
|
|
|
|
- let mut contents = String::new();
|
|
|
|
- for arg in object_files.iter() {
|
|
|
|
- contents.push_str(&format!("{}\n", dunce::canonicalize(arg)?.display()));
|
|
|
|
- }
|
|
|
|
- for arg in self.thin_link_args(&args)? {
|
|
|
|
- contents.push_str(&format!("{}\n", arg));
|
|
|
|
- }
|
|
|
|
- for arg in out_arg.iter() {
|
|
|
|
- contents.push_str(&format!("{}\n", arg));
|
|
|
|
- }
|
|
|
|
- Command::new(linker)
|
|
|
|
- .arg(format!("@{}", cmd_file.path().display()))
|
|
|
|
- .output()
|
|
|
|
- .await?
|
|
|
|
- }
|
|
|
|
- false => {
|
|
|
|
- Command::new(linker)
|
|
|
|
- .args(object_files.iter())
|
|
|
|
- .args(self.thin_link_args(&args)?)
|
|
|
|
- .args(out_arg)
|
|
|
|
- .output()
|
|
|
|
- .await?
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+ let res = Command::new(linker)
|
|
|
|
+ .args(object_files.iter())
|
|
|
|
+ .args(self.thin_link_args(&args)?)
|
|
|
|
+ .args(out_arg)
|
|
|
|
+ .output()
|
|
|
|
+ .await?;
|
|
|
|
|
|
if !res.stderr.is_empty() {
|
|
if !res.stderr.is_empty() {
|
|
let errs = String::from_utf8_lossy(&res.stderr);
|
|
let errs = String::from_utf8_lossy(&res.stderr);
|
|
@@ -1704,31 +1681,11 @@ impl BuildRequest {
|
|
_ => vec!["-o".to_string(), exe.display().to_string()],
|
|
_ => vec!["-o".to_string(), exe.display().to_string()],
|
|
};
|
|
};
|
|
|
|
|
|
- let res = match cfg!(target_os = "windows") {
|
|
|
|
- // Handle windows response files
|
|
|
|
- // https://learn.microsoft.com/en-us/cpp/build/reference/at-specify-a-linker-response-file?view=msvc-170
|
|
|
|
- true => {
|
|
|
|
- let cmd_file = tempfile::NamedTempFile::new()?;
|
|
|
|
- let mut contents = String::new();
|
|
|
|
- for arg in args.iter().skip(1) {
|
|
|
|
- contents.push_str(&format!("{}\n", arg));
|
|
|
|
- }
|
|
|
|
- for arg in out_arg.iter() {
|
|
|
|
- contents.push_str(&format!("{}\n", arg));
|
|
|
|
- }
|
|
|
|
- Command::new(linker)
|
|
|
|
- .arg(format!("@{}", cmd_file.path().display()))
|
|
|
|
- .output()
|
|
|
|
- .await?
|
|
|
|
- }
|
|
|
|
- false => {
|
|
|
|
- Command::new(linker)
|
|
|
|
- .args(args.iter().skip(1))
|
|
|
|
- .args(out_arg)
|
|
|
|
- .output()
|
|
|
|
- .await?
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+ let res = Command::new(linker)
|
|
|
|
+ .args(args.iter().skip(1))
|
|
|
|
+ .args(out_arg)
|
|
|
|
+ .output()
|
|
|
|
+ .await?;
|
|
|
|
|
|
if !res.stderr.is_empty() {
|
|
if !res.stderr.is_empty() {
|
|
let errs = String::from_utf8_lossy(&res.stderr);
|
|
let errs = String::from_utf8_lossy(&res.stderr);
|
|
@@ -1761,6 +1718,20 @@ impl BuildRequest {
|
|
/// cause issues with a custom linker setup. In theory, rust translates most flags to the right
|
|
/// cause issues with a custom linker setup. In theory, rust translates most flags to the right
|
|
/// linker format.
|
|
/// linker format.
|
|
fn select_linker(&self) -> Result<PathBuf, Error> {
|
|
fn select_linker(&self) -> Result<PathBuf, Error> {
|
|
|
|
+ // Use a custom linker for non-crosscompile and crosscompile targets
|
|
|
|
+ if matches!(
|
|
|
|
+ self.triple.operating_system,
|
|
|
|
+ OperatingSystem::Darwin(_) | OperatingSystem::Linux | OperatingSystem::Windows
|
|
|
|
+ ) {
|
|
|
|
+ if let Ok(linker) = std::env::var("DX_HOST_LINKER") {
|
|
|
|
+ return Ok(PathBuf::from(linker));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if let Ok(linker) = std::env::var("DX_LINKER") {
|
|
|
|
+ return Ok(PathBuf::from(linker));
|
|
|
|
+ }
|
|
|
|
+
|
|
let cc = match self.triple.operating_system {
|
|
let cc = match self.triple.operating_system {
|
|
OperatingSystem::Unknown if self.platform == Platform::Web => self.workspace.wasm_ld(),
|
|
OperatingSystem::Unknown if self.platform == Platform::Web => self.workspace.wasm_ld(),
|
|
|
|
|
|
@@ -3594,9 +3565,14 @@ impl BuildRequest {
|
|
///
|
|
///
|
|
/// This might stop working if/when cargo stabilizes contents-based fingerprinting.
|
|
/// This might stop working if/when cargo stabilizes contents-based fingerprinting.
|
|
fn bust_fingerprint(&self, ctx: &BuildContext) -> Result<()> {
|
|
fn bust_fingerprint(&self, ctx: &BuildContext) -> Result<()> {
|
|
- // if matches!(ctx.mode, BuildMode::Fat | BuildMode::Base) {
|
|
|
|
if !matches!(ctx.mode, BuildMode::Thin { .. }) {
|
|
if !matches!(ctx.mode, BuildMode::Thin { .. }) {
|
|
std::fs::File::open(&self.crate_target.src_path)?.set_modified(SystemTime::now())?;
|
|
std::fs::File::open(&self.crate_target.src_path)?.set_modified(SystemTime::now())?;
|
|
|
|
+
|
|
|
|
+ // read and write the file to update the mtime
|
|
|
|
+ if cfg!(target_os = "windows") {
|
|
|
|
+ let contents = std::fs::read_to_string(&self.crate_target.src_path)?;
|
|
|
|
+ _ = std::fs::write(&self.crate_target.src_path, contents);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
Ok(())
|
|
Ok(())
|
|
}
|
|
}
|