Skip to content

Commit 16db912

Browse files
committed
feat(guest): replace musl with picolibc
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
1 parent 8e6a3b4 commit 16db912

561 files changed

Lines changed: 1882 additions & 46864 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "src/hyperlight_guest_bin/third_party/picolibc"]
2+
path = src/hyperlight_guest_bin/third_party/picolibc
3+
url = https://github.com/picolibc/picolibc.git
4+
shallow = true

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ build target=default-target:
4343
guests: build-and-move-rust-guests build-and-move-c-guests
4444

4545
ensure-cargo-hyperlight:
46-
command -v cargo-hyperlight >/dev/null 2>&1 || cargo install --locked cargo-hyperlight
46+
cargo install --locked --force --git https://github.com/hyperlight-dev/cargo-hyperlight --branch picolibc cargo-hyperlight
4747

4848
witguest-wit:
4949
command -v wasm-tools >/dev/null 2>&1 || cargo install --locked wasm-tools

NOTICE.txt

Lines changed: 46 additions & 213 deletions
Original file line numberDiff line numberDiff line change
@@ -2,227 +2,60 @@ NOTICES
22

33
This repository incorporates material as listed below or described in the code.
44

5-
Component. printf
5+
Component. picolibc
66

7-
Open Source License/Copyright Notice.
8-
9-
The MIT License (MIT)
7+
picolibc is a C library designed for embedded systems, derived from newlib.
8+
https://github.com/picolibc/picolibc
109

11-
Copyright (c) 2014 Marco Paland
10+
Version: 1.8.10
1211

13-
Permission is hereby granted, free of charge, to any person obtaining a copy
14-
of this software and associated documentation files (the "Software"), to deal
15-
in the Software without restriction, including without limitation the rights
16-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17-
copies of the Software, and to permit persons to whom the Software is
18-
furnished to do so, subject to the following conditions:
12+
Open Source License/Copyright Notice.
1913

20-
The above copyright notice and this permission notice shall be included in all
21-
copies or substantial portions of the Software.
14+
Copyright © 2019 Keith Packard
2215

23-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29-
SOFTWARE.
16+
picolibc is licensed under the BSD-3-Clause license:
3017

31-
Component. musl
18+
----------------------------------------------------------------------
19+
Redistribution and use in source and binary forms, with or without
20+
modification, are permitted provided that the following conditions
21+
are met:
22+
23+
1. Redistributions of source code must retain the above copyright
24+
notice, this list of conditions and the following disclaimer.
25+
26+
2. Redistributions in binary form must reproduce the above
27+
copyright notice, this list of conditions and the following
28+
disclaimer in the documentation and/or other materials provided
29+
with the distribution.
30+
31+
3. Neither the name of the copyright holder nor the names of its
32+
contributors may be used to endorse or promote products derived
33+
from this software without specific prior written permission.
34+
35+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
38+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
39+
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
40+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
41+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
42+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44+
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46+
OF THE POSSIBILITY OF SUCH DAMAGE.
47+
----------------------------------------------------------------------
3248

33-
Open Source License/Copyright Notice.
49+
Portions of picolibc are derived from newlib, which is:
3450

35-
musl as a whole is licensed under the following standard MIT license:
51+
Copyright © 2020 The Newlib Project
3652

37-
----------------------------------------------------------------------
38-
Copyright © 2005-2020 Rich Felker, et al.
39-
40-
Permission is hereby granted, free of charge, to any person obtaining
41-
a copy of this software and associated documentation files (the
42-
"Software"), to deal in the Software without restriction, including
43-
without limitation the rights to use, copy, modify, merge, publish,
44-
distribute, sublicense, and/or sell copies of the Software, and to
45-
permit persons to whom the Software is furnished to do so, subject to
46-
the following conditions:
47-
48-
The above copyright notice and this permission notice shall be
49-
included in all copies or substantial portions of the Software.
50-
51-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
52-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
53-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
54-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
55-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
56-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
57-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
58-
----------------------------------------------------------------------
53+
Newlib code is licensed under a collection of BSD-compatible and
54+
permissive licenses. The full license details for all files are
55+
documented in the COPYING.picolibc and COPYING.NEWLIB files in the
56+
picolibc submodule at src/hyperlight_guest_bin/third_party/picolibc/.
5957

60-
Authors/contributors include:
61-
62-
A. Wilcox
63-
Ada Worcester
64-
Alex Dowad
65-
Alex Suykov
66-
Alexander Monakov
67-
Andre McCurdy
68-
Andrew Kelley
69-
Anthony G. Basile
70-
Aric Belsito
71-
Arvid Picciani
72-
Bartosz Brachaczek
73-
Benjamin Peterson
74-
Bobby Bingham
75-
Boris Brezillon
76-
Brent Cook
77-
Chris Spiegel
78-
Clément Vasseur
79-
Daniel Micay
80-
Daniel Sabogal
81-
Daurnimator
82-
David Carlier
83-
David Edelsohn
84-
Denys Vlasenko
85-
Dmitry Ivanov
86-
Dmitry V. Levin
87-
Drew DeVault
88-
Emil Renner Berthing
89-
Fangrui Song
90-
Felix Fietkau
91-
Felix Janda
92-
Gianluca Anzolin
93-
Hauke Mehrtens
94-
He X
95-
Hiltjo Posthuma
96-
Isaac Dunham
97-
Jaydeep Patil
98-
Jens Gustedt
99-
Jeremy Huntwork
100-
Jo-Philipp Wich
101-
Joakim Sindholt
102-
John Spencer
103-
Julien Ramseier
104-
Justin Cormack
105-
Kaarle Ritvanen
106-
Khem Raj
107-
Kylie McClain
108-
Leah Neukirchen
109-
Luca Barbato
110-
Luka Perkov
111-
M Farkas-Dyck (Strake)
112-
Mahesh Bodapati
113-
Markus Wichmann
114-
Masanori Ogino
115-
Michael Clark
116-
Michael Forney
117-
Mikhail Kremnyov
118-
Natanael Copa
119-
Nicholas J. Kain
120-
orc
121-
Pascal Cuoq
122-
Patrick Oppenlander
123-
Petr Hosek
124-
Petr Skocik
125-
Pierre Carrier
126-
Reini Urban
127-
Rich Felker
128-
Richard Pennington
129-
Ryan Fairfax
130-
Samuel Holland
131-
Segev Finer
132-
Shiz
133-
sin
134-
Solar Designer
135-
Stefan Kristiansson
136-
Stefan O'Rear
137-
Szabolcs Nagy
138-
Timo Teräs
139-
Trutz Behn
140-
Valentin Ochs
141-
Will Dietz
142-
William Haddon
143-
William Pitcock
144-
145-
Portions of this software are derived from third-party works licensed
146-
under terms compatible with the above MIT license:
147-
148-
The TRE regular expression implementation (src/regex/reg* and
149-
src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed
150-
under a 2-clause BSD license (license text in the source files). The
151-
included version has been heavily modified by Rich Felker in 2012, in
152-
the interests of size, simplicity, and namespace cleanliness.
153-
154-
Much of the math library code (src/math/* and src/complex/*) is
155-
Copyright © 1993,2004 Sun Microsystems or
156-
Copyright © 2003-2011 David Schultz or
157-
Copyright © 2003-2009 Steven G. Kargl or
158-
Copyright © 2003-2009 Bruce D. Evans or
159-
Copyright © 2008 Stephen L. Moshier or
160-
Copyright © 2017-2018 Arm Limited
161-
and labelled as such in comments in the individual source files. All
162-
have been licensed under extremely permissive terms.
163-
164-
The ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008
165-
The Android Open Source Project and is licensed under a two-clause BSD
166-
license. It was taken from Bionic libc, used on Android.
167-
168-
The AArch64 memcpy and memset code (src/string/aarch64/*) are
169-
Copyright © 1999-2019, Arm Limited.
170-
171-
The implementation of DES for crypt (src/crypt/crypt_des.c) is
172-
Copyright © 1994 David Burren. It is licensed under a BSD license.
173-
174-
The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was
175-
originally written by Solar Designer and placed into the public
176-
domain. The code also comes with a fallback permissive license for use
177-
in jurisdictions that may not recognize the public domain.
178-
179-
The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011
180-
Valentin Ochs and is licensed under an MIT-style license.
181-
182-
The x86_64 port was written by Nicholas J. Kain and is licensed under
183-
the standard MIT terms.
184-
185-
The mips and microblaze ports were originally written by Richard
186-
Pennington for use in the ellcc project. The original code was adapted
187-
by Rich Felker for build system and code conventions during upstream
188-
integration. It is licensed under the standard MIT terms.
189-
190-
The mips64 port was contributed by Imagination Technologies and is
191-
licensed under the standard MIT terms.
192-
193-
The powerpc port was also originally written by Richard Pennington,
194-
and later supplemented and integrated by John Spencer. It is licensed
195-
under the standard MIT terms.
196-
197-
All other files which have no copyright comments are original works
198-
produced specifically for use as part of this library, written either
199-
by Rich Felker, the main author of the library, or by one or more
200-
contributors listed above. Details on authorship of individual files
201-
can be found in the git version control history of the project. The
202-
omission of copyright and license comments in each file is in the
203-
interest of source tree size.
204-
205-
In addition, permission is hereby granted for all public header files
206-
(include/* and arch/*/bits/*) and crt files intended to be linked into
207-
applications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit
208-
the copyright notice and permission notice otherwise required by the
209-
license, and to use these files without any requirement of
210-
attribution. These files include substantial contributions from:
211-
212-
Bobby Bingham
213-
John Spencer
214-
Nicholas J. Kain
215-
Rich Felker
216-
Richard Pennington
217-
Stefan Kristiansson
218-
Szabolcs Nagy
219-
220-
all of whom have explicitly granted such permission.
221-
222-
This file previously contained text expressing a belief that most of
223-
the files covered by the above exception were sufficiently trivial not
224-
to be subject to copyright, resulting in confusion over whether it
225-
negated the permissions granted in the license. In the spirit of
226-
permissive licensing, and of not having licensing issues being an
227-
obstacle to adoption, that text has been removed.
58+
Note: The picolibc submodule uses sparse checkout to exclude
59+
GPL/AGPL-licensed test and script files that are not needed for
60+
building. Only BSD/MIT/permissive-licensed source files are included.
22861

c.just

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ mkdir := if os() == "windows" { "mkdir -f -p" } else { "mkdir -p"}
22

33
# Elf options
44
# We don't support stack protectors at the moment, but Arch Linux clang auto-enables them for -linux platforms, so explicitly disable them.
5-
c-compile-options-elf := '-nobuiltininc -H --target=x86_64-unknown-linux-none -fno-stack-protector -fstack-clash-protection -mstack-probe-size=4096 -fPIC'
6-
c-include-flags-elf := "-I " + root / "src/hyperlight_guest_capi/include/" + " -I " + root / "src/hyperlight_guest_bin/third_party/musl/include/" + " -I " + root / "src/hyperlight_guest_bin/third_party/musl/arch/x86_64" + " -I " + root / "src/hyperlight_guest_bin/third_party/printf"
7-
c-linker-options-elf := '--entry "entrypoint" --nostdlib -pie'
5+
c-compile-options-elf := '-nostdlibinc -H --target=x86_64-unknown-linux-none -fno-stack-protector -fstack-clash-protection -mstack-probe-size=4096 -fPIC'
6+
c-include-flags-elf := "-I " + root / "src/hyperlight_guest_capi/include/" + " -I " + root / "src/hyperlight_guest_bin/third_party/picolibc/newlib/libc/include/" + " -I " + root / "src/hyperlight_guest_bin/third_party/picolibc/newlib/libc/tinystdio/"
7+
c-linker-options-elf := '--entry "entrypoint" --nostdlib -pie --no-dynamic-linker'
88
c-flags-debug-elf := '-O0'
99
c-flags-release-elf := '-O3'
1010

hack/clippy-package-features.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ PROFILE=$([ "$TARGET" = "debug" ] && echo "dev" || echo "$TARGET")
2929
if [[ "$PACKAGE" == "hyperlight-host" ]]; then
3030
REQUIRED_FEATURES=("kvm" "mshv3")
3131
elif [[ "$PACKAGE" == "hyperlight-guest-bin" ]]; then
32-
REQUIRED_FEATURES=("printf")
32+
REQUIRED_FEATURES=("libc")
3333
else
3434
REQUIRED_FEATURES=()
3535
fi
@@ -78,4 +78,4 @@ if [[ -n "$features" ]]; then
7878
echo "Testing $PACKAGE with all features: $all_features"
7979
(set -x; "$CARGO" clippy -p "$PACKAGE" --all-targets --no-default-features --features "$all_features" --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings)
8080
fi
81-
fi
81+
fi

src/hyperlight_guest_bin/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ and third-party code used by our C-API needed to build a native hyperlight-guest
1414
"""
1515

1616
[features]
17-
default = ["libc", "printf", "macros"]
18-
libc = [] # compile musl libc
19-
printf = [ "libc" ] # compile printf
17+
default = ["libc", "macros"]
18+
libc = [] # compile libc from picolibc
2019
trace_guest = ["hyperlight-common/trace_guest", "hyperlight-guest/trace_guest", "hyperlight-guest-tracing/trace"]
2120
mem_profile = ["hyperlight-common/mem_profile"]
2221
macros = ["dep:hyperlight-guest-macro", "dep:linkme"]
@@ -37,6 +36,7 @@ tracing = { version = "0.1.44", default-features = false, features = ["attribute
3736
workspace = true
3837

3938
[build-dependencies]
39+
anyhow = "1"
4040
cc = "1.2"
4141
cfg-if = "1.0"
4242
glob = "0.3.3"

0 commit comments

Comments
 (0)