Skip to content

Commit

Permalink
Use Linker Exectuable in Link
Browse files Browse the repository at this point in the history
Prepping for being able to choose a different linker exectuable. In
the future when custom linkers are supported and platform default
linking is supported the linker itself will probably want to build the
whole command rather than just providing the exectuable stirng to be
used. This works for now though.
  • Loading branch information
iwillspeak committed Aug 16, 2020
1 parent ac3e2ac commit 535be4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl Compilation {
module.write_to_file(temp_file.path())?;

// Shell out to Clang to link the final assembly
let output = Command::new("clang")
let output = Command::new(linker.cmd.executable())
.arg(temp_file.path())
.arg(format!("--target={}", target.triple()))
.arg("-o")
Expand Down
11 changes: 11 additions & 0 deletions src/compile/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ impl LinkerCommand {
pub fn default_asset_ty(&self) -> LinkerAssetType {
LinkerAssetType::LlvmBc
}

/// Get the executable this command should call.
///
pub fn executable(&self) -> &str {
// FIXME: instead of exposing a &str. We should
// make the linker buidl the command
// rather than the compiler.
match *self {
LinkerCommand::Clang => "clang"
}
}
}

impl Default for LinkerCommand {
Expand Down

0 comments on commit 535be4c

Please sign in to comment.