Skip to content

Commit 30bf850

Browse files
committed
Use Zig musl/libc++ toolchain to build programs
1 parent 5640d3d commit 30bf850

37 files changed

+1188
-338
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
**/build/
2+
**/.zig/
23
**/build_*/
34
**/riscv32-unknown-elf/
45
**/riscv64-unknown-elf/

engine/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export ENGINE_CC="ccache $CC"
55

66
# Build the script
77
pushd ../programs
8-
source build.sh $@
8+
#source build.sh $@
9+
source zig.sh $@
910
popd
1011

1112
echo "RISC-V C-extension is: $CEXT"

engine/scripts/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,26 @@
1616
add_shared_program(gameplay.elf 0x50000000
1717
*[Gg]ameplay*
1818
"src/gameplay.cpp"
19-
"src/gameplay_remote.cpp"
19+
#"src/gameplay_remote.cpp"
2020
"src/events.cpp"
2121
)
2222

23-
add_level(gui.elf 0x400000
23+
add_level(gui.elf
2424
"src/gui.cpp"
2525
)
26-
attach_program(gui.elf gameplay.elf)
26+
#attach_program(gui.elf gameplay.elf)
2727

2828

29-
add_level(level1.elf 0x400000
29+
add_level(level1.elf
3030
"src/level1.cpp"
3131
"src/level1_local.cpp"
32-
"src/level1_remote.cpp"
32+
#"src/level1_remote.cpp"
3333
"src/level1_threads.cpp"
3434
"src/events.cpp"
3535
)
36-
attach_program(level1.elf gameplay.elf)
36+
#attach_program(level1.elf gameplay.elf)
3737

38-
add_level(level2.elf 0x400000
38+
add_level(level2.elf
3939
"src/level2.cpp"
4040
)
41-
attach_program(level2.elf gameplay.elf)
41+
#attach_program(level2.elf gameplay.elf)

engine/scripts/src/events.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <api.h>
2-
#include <include/event_loop.hpp>
2+
#include <event_loop.hpp>
33

44
static std::array<Events<>, 2> events;
55

engine/scripts/src/events.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <api.h>
2-
#include <include/event_loop.hpp>
2+
#include <event_loop.hpp>
33

44
PUBLIC(bool add_work(const Events<>::Work*));
55

engine/scripts/src/gameplay.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ static void empty_function() {}
1313

1414
static void full_thread_function()
1515
{
16-
microthread::create([](int, int, int) { /* ... */ }, 1, 2, 3);
16+
//microthread::create([](int, int, int) { /* ... */ }, 1, 2, 3);
1717
}
1818

1919
static void oneshot_thread_function()
2020
{
21-
microthread::oneshot([](int, int, int) { /* ... */ }, 1, 2, 3);
21+
//microthread::oneshot([](int, int, int) { /* ... */ }, 1, 2, 3);
2222
}
2323

2424
static void direct_thread_function()
2525
{
26-
microthread::direct([] { /* ... */ });
26+
//microthread::direct([] { /* ... */ });
2727
}
2828

2929
static void opaque_dyncall_handler()
@@ -49,24 +49,10 @@ PUBLIC(void public_donothing())
4949
/* nothing */
5050
}
5151

52-
inline void* sys_memset(void* vdest, const int ch, std::size_t size)
53-
{
54-
register char* a0 asm("a0") = (char*)vdest;
55-
register int a1 asm("a1") = ch;
56-
register size_t a2 asm("a2") = size;
57-
register long syscall_id asm("a7") = SYSCALL_MEMSET;
58-
59-
asm volatile ("ecall"
60-
: "=m"(*(char(*)[size]) a0)
61-
: "r"(a0), "r"(a1), "r"(a2), "r"(syscall_id));
62-
return vdest;
63-
}
64-
6552
static void bench_alloc_free()
6653
{
6754
auto x = std::make_unique_for_overwrite<char[]>(1024);
6855
__asm__("" :: "m"(x[0]) : "memory");
69-
//sys_memset(x.get(), 0, 1024);
7056
}
7157

7258
PUBLIC(void benchmarks())

engine/scripts/src/gui.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ measure_exception_throw()
1414
{
1515
print("Caught exception: ", e.what(), "\n");
1616
}
17+
//print("Exception handling done\n");
1718
const auto cycle1 = rdcycle();
1819
const auto time1 = rdtime();
1920
return {cycle1-cycle0, time1-time0};

engine/scripts/src/interface.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include <include/function.hpp>
2+
#include <function.hpp>
33
#include <map>
44
#include <string>
55
#include <vector>

engine/scripts/src/level1.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PUBLIC(void start())
2323
print("** Threads **\n");
2424

2525
/* Test-run some micro-threads. */
26-
do_threads_stuff();
26+
//do_threads_stuff();
2727
}
2828

2929
static std::unique_ptr<TestData[]> test_vector;
@@ -75,6 +75,6 @@ void do_benchmarks()
7575
});
7676

7777

78-
if (Game::setting("remote").value_or(false))
79-
do_remote_stuff();
78+
//if (Game::setting("remote").value_or(false))
79+
// do_remote_stuff();
8080
}

engine/scripts/src/level1_threads.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ void do_threads_stuff()
2121
b = 4;
2222
c = 6;
2323
microthread::yield();
24+
print("Done, back in the main thread!\n");
2425

25-
auto thread = microthread::create(
26+
/*auto thread = microthread::create(
2627
[](int a, int b, int c)
2728
{
2829
print(
@@ -40,6 +41,7 @@ void do_threads_stuff()
4041
print("Joining the thread any time now...\n");
4142
auto retval = microthread::join(thread);
4243
print("Full thread exited, return value: ", retval, "\n");
44+
*/
4345

4446
/* GDB can be automatically opened at this point. */
4547
Game::breakpoint();

0 commit comments

Comments
 (0)