-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a61cd2
commit 54197b9
Showing
8 changed files
with
118 additions
and
41 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
#[cfg(target_os = "macos")] | ||
mod macos; | ||
mod task; | ||
|
||
use std::{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use std::{ffi::OsString, path::PathBuf}; | ||
|
||
use itertools::Itertools as _; | ||
use which::which; | ||
|
||
use crate::{ | ||
cli::OutputFilePath, | ||
driver::{main::task::ErasedTask, Error as DriverError, Result as DriverResult}, | ||
}; | ||
|
||
pub fn find_linker() -> DriverResult<PathBuf> { | ||
const LINKER_NAMES: [&str; 5] = ["lld", "ld.lld", "gold", "ld.gold", "ld"]; | ||
|
||
LINKER_NAMES | ||
.iter() | ||
.map(which) | ||
.find_or_last(Result::is_ok) | ||
.unwrap() | ||
.map_err(|err| DriverError::ExecutableNotFound { | ||
executable_name: String::from("ld"), | ||
error: err, | ||
}) | ||
} | ||
|
||
pub async fn get_linker_path_and_args( | ||
inputs: &Vec<Box<dyn ErasedTask>>, | ||
output_path: &OutputFilePath, | ||
) -> DriverResult<(PathBuf, Vec<OsString>)> { | ||
let executable_path = find_linker()?; | ||
|
||
let mut arguments = vec![OsString::from("-o"), output_path.as_os_str().to_owned()]; | ||
|
||
for input in inputs { | ||
arguments.push(input.get_output_path().as_os_str().to_owned()); | ||
} | ||
|
||
Ok((executable_path, arguments)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
cfg_if::cfg_if! { | ||
if #[cfg(target_os = "linux")] { | ||
mod linux; | ||
|
||
pub use self::linux::get_linker_path_and_args; | ||
} else if #[cfg(target_os = "macos")] { | ||
mod macos; | ||
|
||
pub use self::macos::get_linker_path_and_args; | ||
} else { | ||
use std::path::PathBuf; | ||
use std::ffi::OsString; | ||
|
||
use crate::{ | ||
cli::OutputFilePath, | ||
driver::{main::task::ErasedTask, Result as DriverResult}, | ||
}; | ||
|
||
pub async fn get_linker_path_and_args( | ||
_inputs: &Vec<Box<dyn ErasedTask>>, | ||
_output_path: &OutputFilePath, | ||
) -> DriverResult<(PathBuf, Vec<OsString>)> { | ||
compile_error!("Unsupported OS") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ juice-macros = { workspace = true } | |
lasso = "0.7.2" | ||
num-bigint = "0.4.4" | ||
take_mut = "0.2.2" | ||
|