unikraft / lib-newlib Goto Github PK
View Code? Open in Web Editor NEWUnikraft port of newlib, a C standard library
License: Other
Unikraft port of newlib, a C standard library
License: Other
When using newlib
with anything and compiling with gcc-11
hundreds of warnings are shown regarding alloc_size
.
These warnings have the following format:
In file included from /home/***/.unikraft/libs/newlib/include/stdlib.h:37,
from /home/***/.unikraft/apps/hello-test/build/libnewlibc/origin/newlib-2.5.0.20170922/newlib/libc/argz/envz_remove.c:10:
/home/***/.unikraft/apps/hello-test/build/libnewlibc/origin/newlib-2.5.0.20170922/newlib/libc/include/stdlib.h:144:13: warning: ignoring attribute ‘alloc_size (3)’ because it conflicts with previous ‘alloc_size (2)’ [-Wattributes]
144 | __alloc_size(3);
|
This is because chained alloc_size
attributes are deprecated in gcc-11
.
To fix this, multiple arguments are given to alloc_size
as per the documentation.
This has been fixed in newer versions of newlib
. The patch that fixes this issue will no longer apply when bumping the version.
I will add these fixes as a Pull Request and link this issue.
I come across this error when adding lib-newlib to the helloworld.
CC libsyscall_shim: uk_prsyscall.o
/home/galves46/Desktop/HackathonUnikraftPorto2023/git/scripts/workdir/unikraft/lib/syscall_shim/uk_prsyscall.c: In function ‘param_okflag’:
/home/galves46/Desktop/HackathonUnikraftPorto2023/git/scripts/workdir/unikraft/lib/syscall_shim/uk_prsyscall.c:431:38: error: ‘R_OK’ undeclared (first use in this function)
431 | PR_FLAG(sb, fmtf, orig_seek, R_, OK, okflags);
| ^~
/home/galves46/Desktop/HackathonUnikraftPorto2023/git/scripts/workdir/unikraft/lib/syscall_shim/uk_prsyscall.c:50:32: note: in definition of macro ‘PR_FLAG’
50 | if ((flags) & (prefix##flagname)) { \
| ^~~~~~
/home/galves46/Desktop/HackathonUnikraftPorto2023/git/scripts/workdir/unikraft/lib/syscall_shim/uk_prsyscall.c:431:38: note: each undeclared identifier is reported only once for each function it appears in
431 | PR_FLAG(sb, fmtf, orig_seek, R_, OK, okflags);
| ^~
/home/galves46/Desktop/HackathonUnikraftPorto2023/git/scripts/workdir/unikraft/lib/syscall_shim/uk_prsyscall.c:50:32: note: in definition of macro ‘PR_FLAG’
50 | if ((flags) & (prefix##flagname)) { \
| ^~~~~~
/home/galves46/Desktop/HackathonUnikraftPorto2023/git/scripts/workdir/unikraft/lib/syscall_shim/uk_prsyscall.c:432:38: error: ‘W_OK’ undeclared (first use in this function)
432 | PR_FLAG(sb, fmtf, orig_seek, W_, OK, okflags);
| ^~
/home/galves46/Desktop/HackathonUnikraftPorto2023/git/scripts/workdir/unikraft/lib/syscall_shim/uk_prsyscall.c:50:32: note: in definition of macro ‘PR_FLAG’
50 | if ((flags) & (prefix##flagname)) { \
| ^~~~~~
/home/galves46/Desktop/HackathonUnikraftPorto2023/git/scripts/workdir/unikraft/lib/syscall_shim/uk_prsyscall.c:433:38: error: ‘X_OK’ undeclared (first use in this function)
433 | PR_FLAG(sb, fmtf, orig_seek, X_, OK, okflags);
| ^~
/home/galves46/Desktop/HackathonUnikraftPorto2023/git/scripts/workdir/unikraft/lib/syscall_shim/uk_prsyscall.c:50:32: note: in definition of macro ‘PR_FLAG’
50 | if ((flags) & (prefix##flagname)) { \
| ^~~~~~
make[3]: *** [/home/galves46/Desktop/HackathonUnikraftPorto2023/git/scripts/workdir/unikraft/support/build/Makefile.build:27: /home/galves46/Desktop/HackathonUnikraftPorto2023/git/scripts/workdir/apps/app-helloworld/build/libsyscall_shim/uk_prsyscall.o] Error 1
make[2]: *** [Makefile:1032: sub-make] Error 2
make[1]: *** [Makefile:32: _all] Error 2
Bump the newlib library version to 4.0.0
.
Aditional porting might be required since it's a significant bump.
Current default libc for Unikraft is now lib-musl
. So lib-newlib
no longer works with the most recent version of Unikraft. Update newlib
to make it work.
redis
doesn't accept requests when run on AArch64
.
There seems to be a mismatch between O_NONBLOCK
and FNONBLOCK
. FNONBLOCK
shoud be an alias for O_NONBLOCK
used by vfscore
to create a nonblocking socket. However, redis
makes use of the O_NONBLOCK
flag, and even though the value for these 2 flags should be the same, it isn't.
That is because on AArch64
the O_NONBLOCK
flag is redefined in include/fcntl.h
, while, FNONBLOCK
isn't.
The result is a blocking socket, which makes it impossible for redis
to accept further requests.
Build and run redis
using newlib
support on AArch64
.
Download this executable and run it using this command:
$./redis-cli -h 172.44.0.2 -p 6379
redis
to be responding to requests:
$./redis-cli -h 172.44.0.2 -p 6379
172.44.0.2:6379> PING
PONG
172.44.0.2:6379> exit
AArch64
KVM
When trying to build app-helloworld-go, we get this error:
/home/razvan/Documents/Unikraft/debug_helloworld_go/apps/app-helloworld-go/build/libgcc/origin/gcc-7.3.0/libgo/runtime/go-signal.c:200:33: error: ‘siginfo_t {aka struct <anonymous>}’ has no member named ‘si_addr’; did you mean ‘si_code’?
ret.sigaddr = (uintptr)(info->si_addr);
This didn't happen before the uksignal support was integrated in newlib [1].
Apparently, the definition for siginfo_t
is now provided by lib-newlib/musl-imported/include/signal.h
and it is lighter than before, not including si_addr
(this patch has lost it's effect [2]).
I think some newlib/uksignal updates will be needed in order to cover this usecase again.
[1] 08d36e6
[2] https://github.com/unikraft/lib-newlib/blob/staging/patches/0006-Add-si_addr-field-for-siginfo_t-and-use-__rtems__-de.patch
In file included from /data1/deepl/workdir/libs/lib-newlib/include/sys/_types.h:37:0,
from /data1/deepl/workdir/apps/nginx/build/libnewlibc/origin/newlib-2.5.0.20170922/newlib/libc/include/machine/endian.h:5,
from /data1/deepl/workdir/apps/nginx/build/libnewlibc/origin/newlib-2.5.0.20170922/newlib/libc/include/sys/param.h:10,
from /data1/deepl/workdir/libs/lib-newlib/include/sys/param.h:4,
from /data1/deepl/workdir/unikraft/include/uk/essentials.h:48,
from /data1/deepl/workdir/unikraft/lib/ukdebug/include/uk/print.h:41,
from /data1/deepl/workdir/unikraft/plat/common/x86/trace.c:34:
/data1/deepl/workdir/libs/lib-newlib/include/uk/_types.h:44:10: fatal error: uk/time_types.h: No such file or directory
#include <uk/time_types.h>
^~~~~~~~~~~~~~~~~
failed to compile the nginx and other libs are ok.
Port the newlib
tests to use uktest
, the Unikraft testing API.
You can follow the libsodium
ported tests as an example and check the USoC
testing session for support.
Default size of the data model for AArch64
is 8 (64 bits) for long
types, however newlibc
ends up defining LONG_MAX
as 32 bits.
This issue causes extremely optimized functions, such as memchr
(which parses DTB for apps like SQLite
or redis
), to crash when compiled for AArch64
.
Build and run SQLite
on AArch64
using newlib
support.
Run the SQLite
app without any errors.
AArch64
KVM
When I run the SQLite
app this is the error I get:
[ 0.000000] ERR: [libkvmpl031] <pl031.c @ 187> Failed to find RTC IRQ from DTB
Most likely it is caused by the behaviour of memchr
when parsing DTB.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.