-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy pathc.just
More file actions
27 lines (21 loc) · 2 KB
/
Copy pathc.just
File metadata and controls
27 lines (21 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
mkdir := if os() == "windows" { "mkdir -f -p" } else { "mkdir -p"}
# Elf options
hyperlight-target-c := if hyperlight-target-arch == "x86_64" { "x86_64-unknown-linux-none" } else if hyperlight-target-arch == "aarch64" { "aarch64-unknown-linux-none" } else { error("Unsupported architecture: " + hyperlight-target-arch) }
# We don't support stack protectors at the moment, but Arch Linux clang auto-enables them for -linux platforms, so explicitly disable them.
c-compile-options-elf := "-nostdlibinc -H --target=" + hyperlight-target-c + " -fno-stack-protector -fstack-clash-protection -mstack-probe-size=4096 -fPIC"
c-include-flags-elf := "-I " + root / "src/hyperlight_guest_capi/include/" + " -I " + root / "src/hyperlight_libc/third_party/picolibc/libc/include/" + " -I " + root / "src/hyperlight_libc/third_party/picolibc/libc/stdio/" + " -I " + root / "src/hyperlight_libc/include/"
c-linker-options-elf := '--entry "entrypoint" --nostdlib -pie --no-dynamic-linker'
c-flags-debug-elf := '-O0'
c-flags-release-elf := '-O3'
build-c-guests target=default-target: (build-rust-capi target) (compile-c-guest target) (link-c-guest target)
build-rust-capi target=default-target: (ensure-cargo-hyperlight)
cd src/hyperlight_guest_capi && cargo hyperlight build --profile {{ if target == "debug" { "dev" } else { target } }}
compile-c-guest target=default-target:
# elf
cd src/tests/c_guests/c_simpleguest && {{ mkdir }} "./out/{{target}}" && clang -c {{ c-compile-options-elf }} {{ if target == "debug" { c-flags-debug-elf } else { c-flags-release-elf } }} main.c {{c-include-flags-elf}} -o "out/{{ target }}/main.o"
link-c-guest target=default-target:
# elf
cd src/tests/c_guests/c_simpleguest && ld.lld -o out/{{target}}/simpleguest {{c-linker-options-elf}} out/{{target}}/main.o -l hyperlight_guest_capi -L "{{justfile_directory()}}/target/{{hyperlight-target}}/{{target}}"
move-c-guests target=default-target:
# elf
cp src/tests/c_guests/c_simpleguest/out/{{target}}/simpleguest src/tests/c_guests/bin/{{target}}/