mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
Just enough changes to compile on M1
This commit is contained in:
parent
95e38a36b6
commit
be9d817830
3 changed files with 54 additions and 36 deletions
|
@ -42,7 +42,7 @@ quickcheck = "0.8"
|
||||||
quickcheck_macros = "0.8"
|
quickcheck_macros = "0.8"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["llvm", "target-webassembly"]
|
default = ["llvm", "target-webassembly", "target-aarch64"]
|
||||||
target-arm = []
|
target-arm = []
|
||||||
target-aarch64 = []
|
target-aarch64 = []
|
||||||
target-webassembly = []
|
target-webassembly = []
|
||||||
|
|
|
@ -36,7 +36,6 @@ pub fn link(
|
||||||
..
|
..
|
||||||
} => link_linux(target, output_path, input_paths, link_type),
|
} => link_linux(target, output_path, input_paths, link_type),
|
||||||
Triple {
|
Triple {
|
||||||
architecture: Architecture::X86_64,
|
|
||||||
operating_system: OperatingSystem::Darwin,
|
operating_system: OperatingSystem::Darwin,
|
||||||
..
|
..
|
||||||
} => link_macos(target, output_path, input_paths, link_type),
|
} => link_macos(target, output_path, input_paths, link_type),
|
||||||
|
@ -724,42 +723,56 @@ fn link_macos(
|
||||||
String::from("-lSystem")
|
String::from("-lSystem")
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok((
|
let arch = match target.architecture {
|
||||||
|
Architecture::Aarch64(_) => "arm64".to_string(),
|
||||||
|
_ => target.architecture.to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut ld_child = Command::new("ld")
|
||||||
// NOTE: order of arguments to `ld` matters here!
|
// NOTE: order of arguments to `ld` matters here!
|
||||||
// The `-l` flags should go after the `.o` arguments
|
// The `-l` flags should go after the `.o` arguments
|
||||||
Command::new("ld")
|
// Don't allow LD_ env vars to affect this
|
||||||
// Don't allow LD_ env vars to affect this
|
.env_clear()
|
||||||
.env_clear()
|
.args(&[
|
||||||
.args(&[
|
// NOTE: we don't do --gc-sections on macOS because the default
|
||||||
// NOTE: we don't do --gc-sections on macOS because the default
|
// macOS linker doesn't support it, but it's a performance
|
||||||
// macOS linker doesn't support it, but it's a performance
|
// optimization, so if we ever switch to a different linker,
|
||||||
// optimization, so if we ever switch to a different linker,
|
// we'd like to re-enable it on macOS!
|
||||||
// we'd like to re-enable it on macOS!
|
// "--gc-sections",
|
||||||
// "--gc-sections",
|
link_type_arg,
|
||||||
link_type_arg,
|
"-arch",
|
||||||
"-arch",
|
&arch,
|
||||||
target.architecture.to_string().as_str(),
|
])
|
||||||
])
|
.args(input_paths)
|
||||||
.args(input_paths)
|
.args(&[
|
||||||
.args(&[
|
// Libraries - see https://github.com/rtfeldman/roc/pull/554#discussion_r496392274
|
||||||
// Libraries - see https://github.com/rtfeldman/roc/pull/554#discussion_r496392274
|
// for discussion and further references
|
||||||
// for discussion and further references
|
&big_sur_fix,
|
||||||
&big_sur_fix,
|
"-lSystem",
|
||||||
"-lSystem",
|
"-lresolv",
|
||||||
"-lresolv",
|
"-lpthread",
|
||||||
"-lpthread",
|
// "-lrt", // TODO shouldn't we need this?
|
||||||
// "-lrt", // TODO shouldn't we need this?
|
// "-lc_nonshared", // TODO shouldn't we need this?
|
||||||
// "-lc_nonshared", // TODO shouldn't we need this?
|
// "-lgcc", // TODO will eventually need compiler_rt from gcc or something - see https://github.com/rtfeldman/roc/pull/554#discussion_r496370840
|
||||||
// "-lgcc", // TODO will eventually need compiler_rt from gcc or something - see https://github.com/rtfeldman/roc/pull/554#discussion_r496370840
|
// "-framework", // Uncomment this line & the following ro run the `rand` crate in examples/cli
|
||||||
// "-framework", // Uncomment this line & the following ro run the `rand` crate in examples/cli
|
// "Security",
|
||||||
// "Security",
|
// Output
|
||||||
// Output
|
"-o",
|
||||||
"-o",
|
output_path.to_str().unwrap(), // app
|
||||||
output_path.to_str().unwrap(), // app
|
])
|
||||||
])
|
.spawn()?;
|
||||||
.spawn()?,
|
|
||||||
output_path,
|
match target.architecture {
|
||||||
))
|
Architecture::Aarch64(_) => {
|
||||||
|
ld_child.wait()?;
|
||||||
|
let child = Command::new("codesign")
|
||||||
|
.args(&["-s", "-", output_path.to_str().unwrap()])
|
||||||
|
.spawn()?;
|
||||||
|
|
||||||
|
Ok((child, output_path))
|
||||||
|
}
|
||||||
|
_ => Ok((ld_child, output_path)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn link_wasm32(
|
fn link_wasm32(
|
||||||
|
|
|
@ -31,6 +31,11 @@ pub fn target_triple_str(target: &Triple) -> &'static str {
|
||||||
operating_system: OperatingSystem::Linux,
|
operating_system: OperatingSystem::Linux,
|
||||||
..
|
..
|
||||||
} => "aarch64-unknown-linux-gnu",
|
} => "aarch64-unknown-linux-gnu",
|
||||||
|
Triple {
|
||||||
|
architecture: Architecture::Aarch64(_),
|
||||||
|
operating_system: OperatingSystem::Darwin,
|
||||||
|
..
|
||||||
|
} => "aarch64-apple-darwin",
|
||||||
Triple {
|
Triple {
|
||||||
architecture: Architecture::X86_64,
|
architecture: Architecture::X86_64,
|
||||||
operating_system: OperatingSystem::Darwin,
|
operating_system: OperatingSystem::Darwin,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue