1
1
mkdir := if os () == " windows" { " mkdir -f -p" } else { " mkdir -p" }
2
2
3
- # PE options
4
- c-compile-options-pe := ' /GS /W3 /Zi /Od /fp:precise /WX- /std:c17 /showIncludes /MT /EHsc /nologo /diagnostics:column'
5
- c-linker-options-pe := ' /MANIFEST:NO /NXCOMPAT /HEAP:131072,131072 /STACK:65536,65536 /DEBUG /RELEASE /ENTRY:"entrypoint" /ALIGN:4096 /FILEALIGN:4096 /NODEFAULTLIB /SAFESEH:NO /driver /SUBSYSTEM:NATIVE /MACHINE:x64 /DYNAMICBASE /TSAWARE:no /section:.text,ERP /section:.rdata,RP /section:.data,RWP /section:.pdata,RP'
6
- c-include-flags-pe := " /I " + root / " src/hyperlight_guest_capi/include/" + " /I " + root / " src/hyperlight_guest/third_party/musl/include/" + " /I " + root / " src/hyperlight_guest/third_party/musl/arch/x86_64" + " /I " + root / " src/hyperlight_guest/third_party/printf"
7
- c-flags-debug-pe := ' /Od /Ob0 /Z7'
8
- c-flags-release-pe := ' /O2 /Gy'
9
-
10
3
# Elf options
11
4
# We don't support stack protectors at the moment, but Arch Linux clang auto-enables them for -linux platforms, so explicitly disable them.
12
5
c-compile-options-elf := ' -nobuiltininc -H --target=x86_64-unknown-linux-none -fno-stack-protector -fstack-clash-protection -mstack-probe-size=4096 -fPIC'
13
- c-include-flags-elf := replace (c- include-flags-pe, ' /I ' , ' -I ' )
6
+ c-include-flags-elf := " -I " + root / " src/hyperlight_guest_capi/ include/" + " -I " + root / " src/hyperlight_guest/third_party/musl/include/" + " -I " + root / " src/hyperlight_guest/third_party/musl/arch/x86_64" + " -I " + root / " src/hyperlight_guest/third_party/printf"
14
7
c-linker-options-elf := ' --entry "entrypoint" --nostdlib -pie'
15
8
c-flags-debug-elf := ' -O0'
16
9
c-flags-release-elf := ' -O3'
@@ -19,25 +12,18 @@ build-c-guests target=default-target: (build-rust-capi target) (compile-c-guest
19
12
20
13
build-rust-capi target = default-target :
21
14
cd src/ hyperlight_guest_capi && cargo build --profile {{ if target == " debug" { " dev" } else { target } }}
22
- cd src/ hyperlight_guest_capi && cargo build --profile {{ if target == " debug" { " dev" } else { target } }} --target x86 _64 -pc-windows-msvc
23
15
24
16
compile-c-guest target = default-target :
25
- cd src/ tests/ c_guests/ c_simpleguest && {{ mkdir }} " ./out/{{ target}} " && clang-cl / c main.c {{ c-compile-options-pe }} {{ if target == " debug" { c-flags-debug-pe } else { c-flags-release-pe } }} {{ c-include-flags-pe}} / Fo" out/{{ target }} /main.obj"
26
- cd src/ tests/ c_guests/ c_callbackguest && {{ mkdir }} " ./out/{{ target}} " && clang-cl / c main.c {{ c-compile-options-pe }} {{ if target == " debug" { c-flags-debug-pe } else { c-flags-release-pe } }} {{ c-include-flags-pe}} / Fo" out/{{ target }} /main.obj"
27
17
# elf
28
- cd src/ tests/ c_guests/ c_simpleguest && 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"
29
- cd src/ tests/ c_guests/ c_callbackguest && 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"
18
+ 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"
19
+ cd src/ tests/ c_guests/ c_callbackguest && {{ 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"
30
20
31
21
link-c-guest target = default-target :
32
- cd src/ tests/ c_guests/ c_simpleguest && lld-link / OUT:./ out/ {{ target }} / simpleguest.exe / PDB:./ out/ {{ target }} / simpleguest.pdb {{ c-linker-options-pe}} out/ {{ target }} / main.obj {{ justfile_directory ()}} / target/ x86 _64 -pc-windows-msvc/ {{ target }} / hyperlight_guest_capi.lib
33
- cd src/ tests/ c_guests/ c_callbackguest && lld-link / OUT:./ out/ {{ target }} / callbackguest.exe / PDB:./ out/ {{ target }} / callbackguest.pdb {{ c-linker-options-pe}} out/ {{ target }} / main.obj {{ justfile_directory ()}} / target/ x86 _64 -pc-windows-msvc/ {{ target }} / hyperlight_guest_capi.lib
34
22
# elf
35
23
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/x86_64-unknown-none/{{ target}} "
36
24
cd src/ tests/ c_guests/ c_callbackguest && ld.lld -o out/ {{ target}} / callbackguest {{ c-linker-options-elf}} out/ {{ target}} / main.o -l hyperlight_guest_capi -L " {{ justfile_directory ()}} /target/x86_64-unknown-none/{{ target}} "
37
25
38
26
move-c-guests target = default-target :
39
- cp src/ tests/ c_guests/ c_simpleguest/ out/ {{ target}} / simpleguest.exe src/ tests/ c_guests/ bin/ {{ target}} /
40
- cp src/ tests/ c_guests/ c_callbackguest/ out/ {{ target}} / callbackguest.exe src/ tests/ c_guests/ bin/ {{ target}} /
41
27
# elf
42
28
cp src/ tests/ c_guests/ c_simpleguest/ out/ {{ target}} / simpleguest src/ tests/ c_guests/ bin/ {{ target}} /
43
29
cp src/ tests/ c_guests/ c_callbackguest/ out/ {{ target}} / callbackguest src/ tests/ c_guests/ bin/ {{ target}} /
0 commit comments