Skip to content

Commit

Permalink
Merge pull request #9 from MattX/aarch64
Browse files Browse the repository at this point in the history
MacOS: Set `as` options to cross-compile for x86_64
  • Loading branch information
PhilippRados authored Dec 19, 2024
2 parents 21f1c70 + 5632323 commit b313622
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
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

0 comments on commit b313622

Please sign in to comment.