Browse Source

Add tests for compiling assembly

add-rc-path
Alex Crichton 9 years ago
parent
commit
6eaa6439f0
  1. 8
      gcc-test/build.rs
  2. 9
      gcc-test/src/i686.S
  3. 4
      gcc-test/src/lib.rs
  4. 9
      gcc-test/src/x86_64.S
  5. 8
      gcc-test/src/x86_64.asm
  6. 7
      gcc-test/tests/all.rs

8
gcc-test/build.rs

@ -14,4 +14,12 @@ fn main() {
.file("src/bar1.c")
.file("src/bar2.c")
.compile("libbar.a");
let target = std::env::var("TARGET").unwrap();
let file = target.split("-").next().unwrap();
let file = format!("src/{}.{}", file,
if target.contains("msvc") {"asm"} else {"S"});
gcc::Config::new()
.file(file)
.compile("libasm.a");
}

9
gcc-test/src/i686.S

@ -0,0 +1,9 @@
.globl asm
asm:
mov $7, %eax
ret
.globl _asm
_asm:
mov $7, %eax
ret

4
gcc-test/src/lib.rs

@ -1,8 +1,8 @@
extern {
pub fn foo() -> i32;
}
extern {
pub fn bar1() -> i32;
pub fn bar2() -> i32;
pub fn asm() -> i32;
}

9
gcc-test/src/x86_64.S

@ -0,0 +1,9 @@
.globl asm
asm:
mov $7, %eax
ret
.globl _asm
_asm:
mov $7, %eax
ret

8
gcc-test/src/x86_64.asm

@ -0,0 +1,8 @@
_TEXT SEGMENT
asm PROC
MOV EAX, 7
RET
asm ENDP
END

7
gcc-test/tests/all.rs

@ -17,3 +17,10 @@ fn bar_here() {
}
}
#[test]
fn asm_here() {
unsafe {
assert_eq!(asm(), 7);
}
}

Loading…
Cancel
Save