Skip to content

Commit e79ec96

Browse files
committed
Update justfiles, build.rs and readme for musl subtree
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 42ee008 commit e79ec96

File tree

5 files changed

+31
-79
lines changed

5 files changed

+31
-79
lines changed

Justfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ install-flatbuffers-with-vcpkg: install-vcpkg
2626
cd ../vcpkg && ./vcpkg install flatbuffers || cd -
2727

2828
tar-headers: (build-rust-capi) # build-rust-capi is a dependency because we need the hyperlight_guest.h to be built
29-
tar -zcvf include.tar.gz -C {{root}}/src/hyperlight_guest/third_party/ libc/musl/include libc/musl/arch/x86_64 printf/printf.h -C {{root}}/src/hyperlight_guest_capi include
29+
tar -zcvf include.tar.gz -C {{root}}/src/hyperlight_guest/third_party/ musl/include musl/arch/x86_64 printf/printf.h -C {{root}}/src/hyperlight_guest_capi include
3030

3131
tar-static-lib: (build-rust-capi "release") (build-rust-capi "debug")
3232
tar -zcvf hyperlight-guest-c-api-windows.tar.gz -C {{root}}/target/x86_64-pc-windows-msvc/ release/hyperlight_guest_capi.lib -C {{root}}/target/x86_64-pc-windows-msvc/ debug/hyperlight_guest_capi.lib

c.just

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mkdir := if os() == "windows" { "mkdir -f -p" } else { "mkdir -p"}
33
# PE options
44
c-compile-options-pe := '/GS /W3 /Zi /Od /fp:precise /WX- /std:c17 /showIncludes /MT /EHsc /nologo /diagnostics:column'
55
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/libc/musl/include/" + " /I " + root / "src/hyperlight_guest/third_party/libc/musl/arch/x86_64" + " /I " + root / "src/hyperlight_guest/third_party/printf"
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"
77
c-flags-debug-pe := '/Od /Ob0 /Z7'
88
c-flags-release-pe := '/O2 /Gy'
99

src/hyperlight_guest/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ log = { version = "0.4", default-features = false }
2929
[build-dependencies]
3030
cc = "1.2"
3131
cfg-if = "1.0"
32+
glob = "0.3.1"

src/hyperlight_guest/build.rs

+26-75
Original file line numberDiff line numberDiff line change
@@ -52,63 +52,16 @@ fn cargo_main() {
5252
}
5353

5454
if cfg!(feature = "libc") {
55-
cfg.file("third_party/libc/musl/src/ctype/isalpha.c")
56-
.file("third_party/libc/musl/src/ctype/isalnum.c")
57-
.file("third_party/libc/musl/src/ctype/isdigit.c")
58-
.file("third_party/libc/musl/src/ctype/isgraph.c")
59-
.file("third_party/libc/musl/src/ctype/islower.c")
60-
.file("third_party/libc/musl/src/ctype/isprint.c")
61-
.file("third_party/libc/musl/src/ctype/isspace.c")
62-
.file("third_party/libc/musl/src/ctype/isupper.c")
63-
.file("third_party/libc/musl/src/ctype/isxdigit.c")
64-
.file("third_party/libc/musl/src/ctype/tolower.c")
65-
.file("third_party/libc/musl/src/ctype/toupper.c")
66-
.file("third_party/libc/musl/src/errno/__errno_location.c")
67-
.file("third_party/libc/musl/src/internal/floatscan.c")
68-
.file("third_party/libc/musl/src/internal/intscan.c")
69-
.file("third_party/libc/musl/src/internal/shgetc.c")
70-
.file("third_party/libc/musl/src/math/copysign.c")
71-
.file("third_party/libc/musl/src/math/copysignl.c")
72-
.file("third_party/libc/musl/src/math/fabs.c")
73-
.file("third_party/libc/musl/src/math/fabsl.c")
74-
.file("third_party/libc/musl/src/math/fmod.c")
75-
.file("third_party/libc/musl/src/math/fmodl.c")
76-
.file("third_party/libc/musl/src/math/scalbnl.c")
77-
.file("third_party/libc/musl/src/math/__signbit.c")
78-
.file("third_party/libc/musl/src/math/__signbitl.c")
79-
.file("third_party/libc/musl/src/math/__fpclassify.c")
80-
.file("third_party/libc/musl/src/math/__fpclassifyl.c")
81-
.file("third_party/libc/musl/src/stdio/__toread.c")
82-
.file("third_party/libc/musl/src/stdio/__uflow.c")
83-
.file("third_party/libc/musl/src/stdlib/atoi.c")
84-
.file("third_party/libc/musl/src/stdlib/strtod.c")
85-
.file("third_party/libc/musl/src/stdlib/strtol.c")
86-
.file("third_party/libc/musl/src/stdlib/qsort.c")
87-
.file("third_party/libc/musl/src/stdlib/qsort_nr.c")
88-
.file("third_party/libc/musl/src/stdlib/bsearch.c")
89-
.file("third_party/libc/musl/src/string/memchr.c")
90-
.file("third_party/libc/musl/src/string/memcmp.c")
91-
.file("third_party/libc/musl/src/string/memcpy.c")
92-
.file("third_party/libc/musl/src/string/memmove.c")
93-
.file("third_party/libc/musl/src/string/memset.c")
94-
.file("third_party/libc/musl/src/string/stpncpy.c")
95-
.file("third_party/libc/musl/src/string/strchr.c")
96-
.file("third_party/libc/musl/src/string/strchrnul.c")
97-
.file("third_party/libc/musl/src/string/strcmp.c")
98-
.file("third_party/libc/musl/src/string/strcspn.c")
99-
.file("third_party/libc/musl/src/string/strlen.c")
100-
.file("third_party/libc/musl/src/string/strncasecmp.c")
101-
.file("third_party/libc/musl/src/string/strncat.c")
102-
.file("third_party/libc/musl/src/string/strncmp.c")
103-
.file("third_party/libc/musl/src/string/strncpy.c")
104-
.file("third_party/libc/musl/src/string/strspn.c")
105-
.file("third_party/libc/musl/src/string/strstr.c")
106-
.file("third_party/libc/musl/src/prng/rand.c")
107-
.include("third_party/libc/musl/src/include")
108-
.include("third_party/libc/musl/include")
109-
.include("third_party/libc/musl/src/internal")
110-
.include("third_party/libc/musl/arch/generic")
111-
.include("third_party/libc/musl/arch/x86_64");
55+
let entries = glob::glob("third_party/musl/**/*.[cs]") // .c and .s files
56+
.expect("glob pattern should be valid")
57+
.filter_map(Result::ok);
58+
cfg.files(entries);
59+
60+
cfg.include("third_party/musl/src/include")
61+
.include("third_party/musl/include")
62+
.include("third_party/musl/src/internal")
63+
.include("third_party/musl/arch/generic")
64+
.include("third_party/musl/arch/x86_64");
11265
}
11366

11467
if cfg!(feature = "alloca") {
@@ -124,24 +77,22 @@ fn cargo_main() {
12477
feature = "libc",
12578
feature = "alloca"
12679
)) {
127-
if is_pe {
128-
cfg.define("hidden", "");
129-
cfg.define("weak_alias(old, new) ", " ");
130-
cfg.define("__DEFINED_va_list", None);
131-
cfg.define("__DEFINED___isoc_va_list", None);
132-
}
133-
cfg.define("__x86_64__", None);
134-
cfg.define("__LITTLE_ENDIAN__", None);
80+
cfg.define("HYPERLIGHT", None); // used in certain musl files for conditional compilation
13581

13682
// silence compiler warnings
137-
cfg.flag("-Wno-sign-compare");
138-
cfg.flag("-Wno-bitwise-op-parentheses");
139-
cfg.flag("-Wno-unknown-pragmas");
140-
cfg.flag("-Wno-shift-op-parentheses");
141-
cfg.flag("-Wno-logical-op-parentheses");
142-
cfg.flag("-Wno-unused-but-set-variable");
83+
cfg.flag("-Wno-unused-command-line-argument") // including .s files makes clang believe arguments are unused
84+
.flag("-Wno-sign-compare")
85+
.flag("-Wno-bitwise-op-parentheses")
86+
.flag("-Wno-unknown-pragmas")
87+
.flag("-Wno-shift-op-parentheses")
88+
.flag("-Wno-logical-op-parentheses")
89+
.flag("-Wno-unused-but-set-variable")
90+
.flag("-Wno-unused-parameter")
91+
.flag("-Wno-string-plus-int");
14392

14493
if is_pe {
94+
cfg.flag("-Wno-unused-label");
95+
cfg.flag("-Wno-unused-variable");
14596
cfg.compiler("clang-cl");
14697
} else {
14798
cfg.flag("-fPIC");
@@ -182,10 +133,10 @@ fn cargo_main() {
182133
}
183134
if cfg!(feature = "libc") {
184135
copy_includes(&include_dir, "include");
185-
copy_includes(&include_dir, "third_party/libc/musl/include");
186-
copy_includes(&include_dir, "third_party/libc/musl/arch/generic");
187-
copy_includes(&include_dir, "third_party/libc/musl/arch/x86_64");
188-
copy_includes(&include_dir, "third_party/libc/musl/src/internal");
136+
copy_includes(&include_dir, "third_party/musl/include");
137+
copy_includes(&include_dir, "third_party/musl/arch/generic");
138+
copy_includes(&include_dir, "third_party/musl/arch/x86_64");
139+
copy_includes(&include_dir, "third_party/musl/src/internal");
189140
}
190141
/* do not canonicalize: clang has trouble with UNC paths */
191142
let include_str = include_dir

src/hyperlight_guest/third_party/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ Changes have been applied to the original code for Hyperlight using this [patch]
1111

1212
## libc
1313

14-
A partial version of musl libc is used by hyperlight and is located in the [musl](./libc/musl) directory.
14+
A partial version of musl libc is used by hyperlight and is located in the [musl](./musl) directory as a git subtree.
1515

16-
The current version is release [v1.2.3](https://git.musl-libc.org/cgit/musl/tag/?h=v1.2.3). Many files have been deleted and changes have been made to some of the remaining files, those deletions and changes can be applied using [this](./libc/musl-libc.patch) patch.
16+
The current version is release [v1.2.5](https://git.musl-libc.org/cgit/musl/tag/?h=v1.2.5). Many files have been deleted and changes have been made to some of the remaining files.

0 commit comments

Comments
 (0)