cosmopolitan build
This commit is contained in:
parent
bb91e60199
commit
511936220e
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
**/*.o
|
||||||
|
**/*.a
|
||||||
|
**/*.lds
|
||||||
|
**/*.h
|
||||||
|
zig-out/
|
||||||
|
zig-cache/
|
0
.gitmodules
vendored
Normal file
0
.gitmodules
vendored
Normal file
5
build-cosmo.sh
Executable file
5
build-cosmo.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
zig build-obj ./src/main.zig -fno-PIE -fno-PIC -fno-stack-check
|
||||||
|
ld.bfd main.o -o zig-out/bin/nmvm.com.dbg -T extern/cosmopolitan/ape.lds extern/cosmopolitan/crt.o extern/cosmopolitan/ape-copy-self.o \
|
||||||
|
extern/cosmopolitan/cosmopolitan.a -z common-page-size=0x1000 -z max-page-size=0x1000 --gc-sections
|
4
extern/cosmopolitan/get.sh
vendored
Executable file
4
extern/cosmopolitan/get.sh
vendored
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
wget wget https://justine.lol/cosmopolitan/cosmopolitan.tar.gz
|
||||||
|
unzip cosmopolitan.tar.gz
|
4
extern/get.sh
vendored
Executable file
4
extern/get.sh
vendored
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd ./cosmopolitan
|
||||||
|
./get.sh
|
7
prepare.sh
Executable file
7
prepare.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd ./extern
|
||||||
|
./get.sh
|
||||||
|
|
||||||
|
cd ../
|
||||||
|
zig translate-c ./extern/cosmopolitan/cosmopolitan.h > ./src/cosmopolitan/cosmopolitan.zig
|
0
src/cosmopolitan/.getkeep
Normal file
0
src/cosmopolitan/.getkeep
Normal file
19
src/main.zig
19
src/main.zig
@ -1,20 +1,29 @@
|
|||||||
const std = @import("std");
|
|
||||||
const tolmac = @import("tolmac.zig");
|
const tolmac = @import("tolmac.zig");
|
||||||
|
const cosmo = @import("cosmopolitan/cosmopolitan.zig");
|
||||||
|
|
||||||
fn printInt3(int: u64, other: u32, another: u16) callconv(.SysV) void {
|
fn printInt3(int: u64, other: u32, another: u16) callconv(.SysV) void {
|
||||||
@setAlignStack(16);
|
@setAlignStack(16);
|
||||||
std.debug.print("test: {}, {}, {}\n", .{ int, other, another });
|
_ = cosmo.printf("%u\n", @as(c_uint, @intCast(int + other + another)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn printInt2(int: u64, other: u8) callconv(.SysV) void {
|
fn printInt2(int: u64, other: u8) callconv(.SysV) void {
|
||||||
@setAlignStack(16);
|
@setAlignStack(16);
|
||||||
std.debug.print("test: {}, {}\n", .{ int, other });
|
_ = cosmo.printf("%u\n", @as(c_uint, @intCast(int + other)));
|
||||||
}
|
}
|
||||||
|
|
||||||
const opPrintInt3Zov = tolmac.generateOpZovSysvFromPrototype(printInt3) catch unreachable;
|
const opPrintInt3Zov = tolmac.generateOpZovSysvFromPrototype(printInt3) catch unreachable;
|
||||||
const opPrintInt2Zov = tolmac.generateOpZovSysvFromPrototype(printInt2) catch unreachable;
|
const opPrintInt2Zov = tolmac.generateOpZovSysvFromPrototype(printInt2) catch unreachable;
|
||||||
|
|
||||||
pub fn main() !void {
|
comptime {
|
||||||
|
@export(cosmopolitanMain, .{ .name = "main" });
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo: No cosmopolitan main.
|
||||||
|
|
||||||
|
fn cosmopolitanMain(argc: c_int, argv: [*][*:0]u8) callconv(.SysV) c_int {
|
||||||
|
_ = argc;
|
||||||
|
_ = argv;
|
||||||
|
|
||||||
const add = [_]tolmac.Word{
|
const add = [_]tolmac.Word{
|
||||||
@as(tolmac.Word, @intFromPtr(&tolmac.opSumWordsWithOverflow)),
|
@as(tolmac.Word, @intFromPtr(&tolmac.opSumWordsWithOverflow)),
|
||||||
@as(tolmac.Word, @intFromPtr(&tolmac.opReturn)),
|
@as(tolmac.Word, @intFromPtr(&tolmac.opReturn)),
|
||||||
@ -43,6 +52,8 @@ pub fn main() !void {
|
|||||||
};
|
};
|
||||||
|
|
||||||
tolmac.execute(&entry, 0);
|
tolmac.execute(&entry, 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
Loading…
Reference in New Issue
Block a user