Skip to content

Commit

Permalink
fixed mac detection of ld-classic
Browse files Browse the repository at this point in the history
  • Loading branch information
NotAFlyingGoose committed Mar 8, 2024
1 parent cfbe4ff commit d3cd205
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion crates/codegen/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use interner::Interner;
use internment::Intern;
use la_arena::Idx;
use rustc_hash::FxHashMap;
use std::backtrace;
use std::collections::VecDeque;
use uid_gen::UIDGenerator;

Expand Down
12 changes: 11 additions & 1 deletion crates/codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,17 @@ pub fn link_to_exec(object_file: &PathBuf, target: Triple, libs: &[String]) -> P
.join(object_file.file_stem().unwrap());

let linker_args: &[&str] = match target.operating_system {
OperatingSystem::Darwin => &["-Xlinker", "-ld_classic"],
OperatingSystem::Darwin => {
// check if -ld_classic is supported
let ld_v = Command::new("ld").arg("-v").output().unwrap();
let stderr = String::from_utf8(ld_v.stderr).expect("`ld` should have given utf8");

if stderr.contains("ld-classic") {
&["-Xlinker", "-ld_classic"]
} else {
&[]
}
}
_ => &[],
};

Expand Down

0 comments on commit d3cd205

Please sign in to comment.