Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS: Set as options to cross-compile for x86_64 #9

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
test:
strategy:
matrix:
# have to use macos-13 because newer versions are arm-based
os: [ubuntu-latest, macos-13]
# check on macos-13 (x86) and macos-latest (ARM through Rosetta)
os: [ubuntu-latest, macos-13, macos-latest]

runs-on: ${{ matrix.os }}

Expand Down
27 changes: 21 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,27 @@ fn output_path(
fn assemble(options: &CliOptions, file: &Path, asm_file: OutFile) -> Result<OutFile, WreccError> {
let output_path = output_path(file, &options.output_path, options.no_link, "o");

let output = Command::new("as")
.arg(asm_file.get())
.arg("-o")
.arg(output_path.get())
.output()
.map_err(|_| WreccError::Sys("could not invoke assembler 'as'".to_string()))?;
let output = match std::env::consts::OS {
"linux" => {
Command::new("as")
.arg(asm_file.get())
.arg("-o")
.arg(output_path.get())
.output()
.map_err(|_| WreccError::Sys("could not invoke assembler 'as'".to_string()))?
}
"macos" => {
Command::new("as")
.arg(asm_file.get())
.arg("-o")
.arg(output_path.get())
.arg("-arch")
.arg("x86_64")
.output()
.map_err(|_| WreccError::Sys("could not invoke assembler 'as'".to_string()))?
}
_ => return Err(WreccError::Sys(String::from("only supports linux and macos"))),
};

if output.status.success() {
Ok(output_path)
Expand Down
Loading