Skip to content

Commit 00fb3a8

Browse files
authored
Merge pull request #118 from tti0/theodoretucker/rust-lld-error
Handle case where `rust-lld` is not in path
2 parents e95913e + d3e368b commit 00fb3a8

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
- [#118] Handle case where rust-lld is not in path
1011
- [#109] Don't cache, because it is slow
1112
- [#108] CI: Update cargo-dist to v0.1.27
1213

14+
[#118]: https://github.com/knurling-rs/flip-link/pull/118
1315
[#109]: https://github.com/knurling-rs/flip-link/pull/109
1416
[#108]: https://github.com/knurling-rs/flip-link/pull/107
1517

src/linking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{
44
process::{Command, ExitStatus},
55
};
66

7-
const LINKER: &str = "rust-lld";
7+
pub const LINKER: &str = "rust-lld";
88

99
/// Normal linking with just the arguments the user provides
1010
pub fn link_normally(args: &[String]) -> io::Result<ExitStatus> {

src/main.rs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
borrow::Cow,
66
env,
77
fs::{self, File},
8-
io::Write,
8+
io::{ErrorKind::NotFound, Write},
99
ops::RangeInclusive,
1010
path::{Path, PathBuf},
1111
process,
@@ -41,7 +41,19 @@ fn notmain() -> Result<i32> {
4141
}
4242

4343
{
44-
let exit_status = linking::link_normally(&raw_args)?;
44+
let exit_status = match linking::link_normally(&raw_args) {
45+
Ok(status) => status,
46+
Err(e) => {
47+
if e.kind() == NotFound {
48+
eprintln!(
49+
"flip-link: Could not find the default linker ({}) in your path",
50+
linking::LINKER
51+
);
52+
}
53+
Err(Box::new(e))
54+
}?,
55+
};
56+
4557
if !exit_status.success() {
4658
eprintln!(
4759
"\nflip-link: the native linker failed to link the program normally; \
@@ -111,7 +123,19 @@ fn notmain() -> Result<i32> {
111123
}
112124
new_linker_script.flush()?;
113125

114-
let exit_status = linking::link_modified(&raw_args, &current_dir, tempdir, new_origin)?;
126+
let exit_status = match linking::link_modified(&raw_args, &current_dir, tempdir, new_origin)
127+
{
128+
Ok(status) => status,
129+
Err(e) => {
130+
if e.kind() == NotFound {
131+
eprintln!(
132+
"flip-link: Could not find the default linker ({}) in your path",
133+
linking::LINKER
134+
);
135+
}
136+
Err(Box::new(e))
137+
}?,
138+
};
115139
Ok(exit_status)
116140
})?;
117141

0 commit comments

Comments
 (0)