2017-05-02 01:12:38 +08:00
|
|
|
const config = @import("builtin");
|
2017-04-05 07:47:22 +08:00
|
|
|
const assert = @import("std").debug.assert;
|
|
|
|
|
|
|
|
comptime {
|
2017-12-18 22:59:57 +08:00
|
|
|
@export("derp", derp);
|
2017-08-27 12:11:09 +08:00
|
|
|
if (config.arch == config.Arch.x86_64 and config.os == config.Os.linux) {
|
2017-04-05 07:47:22 +08:00
|
|
|
asm volatile (
|
2017-12-18 22:59:57 +08:00
|
|
|
\\.globl my_aoeu_symbol_asdf;
|
|
|
|
\\.type my_aoeu_symbol_asdf, @function;
|
|
|
|
\\.set my_aoeu_symbol_asdf, derp;
|
2017-04-05 07:47:22 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test "module level assembly" {
|
2017-08-27 12:11:09 +08:00
|
|
|
if (config.arch == config.Arch.x86_64 and config.os == config.Os.linux) {
|
2017-12-18 22:59:57 +08:00
|
|
|
assert(my_aoeu_symbol_asdf() == 1234);
|
2017-04-05 07:47:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-18 22:59:57 +08:00
|
|
|
extern fn my_aoeu_symbol_asdf() -> i32;
|
2017-04-05 07:47:22 +08:00
|
|
|
|
2017-12-18 22:59:57 +08:00
|
|
|
extern fn derp() -> i32 {
|
2017-04-05 07:47:22 +08:00
|
|
|
return 1234;
|
|
|
|
}
|