Solo5: make tests runnable outside of build
This commit is contained in:
parent
da38074890
commit
4ca891a7c4
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
{ stdenv, buildPackages, fetchurl, llvmPackages, pkgconfig, base, os }:
|
{ stdenv, buildPackages, fetchurl, llvmPackages, pkgconfig, base, os }:
|
||||||
|
|
||||||
|
# WARNING: recursive make, fucked as usual
|
||||||
|
|
||||||
let version = "0.6.3";
|
let version = "0.6.3";
|
||||||
in stdenv.mkDerivation {
|
in stdenv.mkDerivation {
|
||||||
pname = "solo5";
|
pname = "solo5";
|
||||||
|
@ -13,10 +15,11 @@ in stdenv.mkDerivation {
|
||||||
|
|
||||||
nativeBuildInputs = [ pkgconfig ];
|
nativeBuildInputs = [ pkgconfig ];
|
||||||
|
|
||||||
buildInputs = [ base.dev os.dev ];
|
buildInputs = [ base os ];
|
||||||
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "https://github.com/Solo5/solo5/releases/download/v${version}/solo5-v${version}.tar.gz";
|
url =
|
||||||
|
"https://github.com/Solo5/solo5/releases/download/v${version}/solo5-v${version}.tar.gz";
|
||||||
sha256 = "08z2gv0jlsq6r92vacapdj0hqhyfqfy3xdjn5k9c1pd23a2syq7w";
|
sha256 = "08z2gv0jlsq6r92vacapdj0hqhyfqfy3xdjn5k9c1pd23a2syq7w";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,12 +38,15 @@ in stdenv.mkDerivation {
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
mkdir -p $out/bin $tests/bin
|
mkdir -p $out/bin $tests/bin
|
||||||
make install-opam-genode PREFIX=$out
|
make install-opam-genode PREFIX=$out
|
||||||
|
local wrong_path=`find $NIX_BUILD_TOP -name solo5.lib.so`
|
||||||
for test in tests/*/*.genode; do
|
for test in tests/*/*.genode; do
|
||||||
cp $test $tests/bin/solo5-`basename $test .genode`
|
cp $test $tests/bin/solo5-`basename $test .genode`
|
||||||
done
|
done
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
dontFixup = true;
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with stdenv.lib; {
|
||||||
description = "Sandboxed execution environment.";
|
description = "Sandboxed execution environment.";
|
||||||
homepage = "https://github.com/solo5/solo5";
|
homepage = "https://github.com/solo5/solo5";
|
||||||
|
|
|
@ -1,30 +1,38 @@
|
||||||
diff --git a/GNUmakefile b/GNUmakefile
|
diff --git a/GNUmakefile b/GNUmakefile
|
||||||
index e168853..161facf 100644
|
index e168853..02d81e1 100644
|
||||||
--- a/GNUmakefile
|
--- a/GNUmakefile
|
||||||
+++ b/GNUmakefile
|
+++ b/GNUmakefile
|
||||||
@@ -100,7 +100,8 @@ install-opam-%: all opam/solo5-bindings-%.pc force-install
|
@@ -98,9 +98,11 @@ install-opam-%: all opam/solo5-bindings-%.pc force-install
|
||||||
|
(echo "error: PREFIX not set or incorrect"; false)
|
||||||
|
mkdir -p $(PREFIX)/lib/pkgconfig \
|
||||||
$(PREFIX)/lib/solo5-bindings-$* \
|
$(PREFIX)/lib/solo5-bindings-$* \
|
||||||
$(PREFIX)/include/solo5-bindings-$*/solo5 \
|
- $(PREFIX)/include/solo5-bindings-$*/solo5 \
|
||||||
$(PREFIX)/include/solo5-bindings-$*/crt
|
- $(PREFIX)/include/solo5-bindings-$*/crt
|
||||||
- cp -R include/solo5 include/crt $(PREFIX)/include/solo5-bindings-$*
|
- cp -R include/solo5 include/crt $(PREFIX)/include/solo5-bindings-$*
|
||||||
|
+ $(PREFIX)/include/solo5-bindings-$*
|
||||||
+ cp -R include/solo5 $(PREFIX)/include/solo5-bindings-$*
|
+ cp -R include/solo5 $(PREFIX)/include/solo5-bindings-$*
|
||||||
+ if [ -d "include/crt" ]; then cp -R include/crt $(PREFIX)/include/solo5-bindings-$*; fi
|
+ifdef CONFIG_HOST_CRT
|
||||||
|
+ cp -R include/crt $(PREFIX)/include/solo5-bindings-$*
|
||||||
|
+endif
|
||||||
ifndef CONFIG_GENODE
|
ifndef CONFIG_GENODE
|
||||||
cp bindings/$*/solo5_$*.o bindings/$*/solo5_$*.lds \
|
cp bindings/$*/solo5_$*.o bindings/$*/solo5_$*.lds \
|
||||||
$(PREFIX)/lib/solo5-bindings-$*
|
$(PREFIX)/lib/solo5-bindings-$*
|
||||||
diff --git a/Makefile.common b/Makefile.common
|
diff --git a/Makefile.common b/Makefile.common
|
||||||
index 5ccc2ea..0e1aed2 100644
|
index 5ccc2ea..2653a8b 100644
|
||||||
--- a/Makefile.common
|
--- a/Makefile.common
|
||||||
+++ b/Makefile.common
|
+++ b/Makefile.common
|
||||||
@@ -32,6 +32,7 @@ include $(TOPDIR)/Makeconf
|
@@ -30,8 +30,10 @@ include $(TOPDIR)/Makeconf
|
||||||
|
# tests (applications).
|
||||||
|
#
|
||||||
CC := $(MAKECONF_CC)
|
CC := $(MAKECONF_CC)
|
||||||
|
+CXX := $(MAKECONF_CXX)
|
||||||
CFLAGS := -std=c11 -Wall -Wextra -Werror -O2 -g
|
CFLAGS := -std=c11 -Wall -Wextra -Werror -O2 -g
|
||||||
CFLAGS += -ffreestanding -fstack-protector-strong $(MAKECONF_CFLAGS)
|
CFLAGS += -ffreestanding -fstack-protector-strong $(MAKECONF_CFLAGS)
|
||||||
+CXXLAGS += -Wall -Wextra -Werror -O2 -g
|
+CXXFLAGS += -Wall -Wextra -Werror -O2 -g
|
||||||
CPPFLAGS := -isystem $(TOPDIR)/include/crt -I$(TOPDIR)/include/solo5
|
CPPFLAGS := -isystem $(TOPDIR)/include/crt -I$(TOPDIR)/include/solo5
|
||||||
LD := $(MAKECONF_LD)
|
LD := $(MAKECONF_LD)
|
||||||
LDFLAGS := -nostdlib -z max-page-size=$(CONFIG_GUEST_PAGE_SIZE) -static \
|
LDFLAGS := -nostdlib -z max-page-size=$(CONFIG_GUEST_PAGE_SIZE) -static \
|
||||||
@@ -53,6 +54,12 @@ define COMPILE.c
|
@@ -53,6 +55,12 @@ define COMPILE.c
|
||||||
mv -f $*.Td $*.d && touch $@
|
mv -f $*.Td $*.d && touch $@
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -37,7 +45,7 @@ index 5ccc2ea..0e1aed2 100644
|
||||||
define COMPILE.S
|
define COMPILE.S
|
||||||
@echo "AS $<"
|
@echo "AS $<"
|
||||||
$(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) -DASM_FILE -c $< -o $@
|
$(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) -DASM_FILE -c $< -o $@
|
||||||
@@ -63,7 +70,7 @@ endef
|
@@ -63,7 +71,7 @@ endef
|
||||||
# The following variables and recpies apply to building tenders, i.e.
|
# The following variables and recpies apply to building tenders, i.e.
|
||||||
# artifacts built to run on the (Solo5 tender's) *host*.
|
# artifacts built to run on the (Solo5 tender's) *host*.
|
||||||
#
|
#
|
||||||
|
@ -81,7 +89,7 @@ index 147c245..d3efb36 100644
|
||||||
GENODE_LDFLAGS := -nostdlib -z max-page-size=$(CONFIG_GUEST_PAGE_SIZE) -shared \
|
GENODE_LDFLAGS := -nostdlib -z max-page-size=$(CONFIG_GUEST_PAGE_SIZE) -shared \
|
||||||
-gc-sections --eh-frame-hdr --entry=0x0 -T genode/genode_rel.ld
|
-gc-sections --eh-frame-hdr --entry=0x0 -T genode/genode_rel.ld
|
||||||
diff --git a/bindings/genode/bindings.cc b/bindings/genode/bindings.cc
|
diff --git a/bindings/genode/bindings.cc b/bindings/genode/bindings.cc
|
||||||
index eb55ffb..927a62f 100644
|
index eb55ffb..2b7db70 100644
|
||||||
--- a/bindings/genode/bindings.cc
|
--- a/bindings/genode/bindings.cc
|
||||||
+++ b/bindings/genode/bindings.cc
|
+++ b/bindings/genode/bindings.cc
|
||||||
@@ -35,15 +35,15 @@
|
@@ -35,15 +35,15 @@
|
||||||
|
@ -103,6 +111,45 @@ index eb55ffb..927a62f 100644
|
||||||
#include "../../tenders/common/mft.c"
|
#include "../../tenders/common/mft.c"
|
||||||
|
|
||||||
namespace Solo5
|
namespace Solo5
|
||||||
|
@@ -109,32 +109,32 @@ struct Solo5::Device
|
||||||
|
{
|
||||||
|
virtual
|
||||||
|
solo5_result_t
|
||||||
|
- net_info(solo5_net_info &info) {
|
||||||
|
+ net_info(solo5_net_info &) {
|
||||||
|
return SOLO5_R_EINVAL; }
|
||||||
|
|
||||||
|
virtual
|
||||||
|
solo5_result_t
|
||||||
|
- net_write(const uint8_t *buf, size_t size) {
|
||||||
|
+ net_write(const uint8_t *, size_t) {
|
||||||
|
return SOLO5_R_EINVAL; }
|
||||||
|
|
||||||
|
virtual
|
||||||
|
solo5_result_t
|
||||||
|
- net_read(uint8_t *buf, size_t size, size_t &read_size) {
|
||||||
|
+ net_read(uint8_t *, size_t, size_t &) {
|
||||||
|
return SOLO5_R_EINVAL; }
|
||||||
|
|
||||||
|
virtual
|
||||||
|
solo5_result_t
|
||||||
|
- block_info(solo5_block_info &info) {
|
||||||
|
+ block_info(solo5_block_info &) {
|
||||||
|
return SOLO5_R_EINVAL; }
|
||||||
|
|
||||||
|
virtual
|
||||||
|
solo5_result_t
|
||||||
|
- block_write(solo5_off_t offset, const uint8_t *buf, size_t size) {
|
||||||
|
+ block_write(solo5_off_t, const uint8_t *, size_t) {
|
||||||
|
return SOLO5_R_EINVAL; }
|
||||||
|
|
||||||
|
virtual
|
||||||
|
solo5_result_t
|
||||||
|
- block_read(solo5_off_t offset, uint8_t *buf, size_t size) {
|
||||||
|
+ block_read(solo5_off_t, uint8_t *, size_t) {
|
||||||
|
return SOLO5_R_EINVAL; }
|
||||||
|
};
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ struct Solo5::Net_device final : Device
|
@@ -162,7 +162,7 @@ struct Solo5::Net_device final : Device
|
||||||
Net_device(struct mft_entry &me,
|
Net_device(struct mft_entry &me,
|
||||||
Genode::Env &env,
|
Genode::Env &env,
|
||||||
|
@ -176,7 +223,13 @@ index eb55ffb..927a62f 100644
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -605,6 +613,39 @@ solo5_set_tls_base(uintptr_t base)
|
@@ -600,11 +608,44 @@ solo5_block_read(solo5_handle_t handle, solo5_off_t offset,
|
||||||
|
|
||||||
|
|
||||||
|
solo5_result_t
|
||||||
|
-solo5_set_tls_base(uintptr_t base)
|
||||||
|
+solo5_set_tls_base(uintptr_t)
|
||||||
|
{
|
||||||
return SOLO5_R_EUNSPEC;
|
return SOLO5_R_EUNSPEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,10 +344,18 @@ index 0f1ca5c..0000000
|
||||||
-uintptr_t SSP_GUARD;
|
-uintptr_t SSP_GUARD;
|
||||||
-void SSP_FAIL (void) { }
|
-void SSP_FAIL (void) { }
|
||||||
diff --git a/configure.sh b/configure.sh
|
diff --git a/configure.sh b/configure.sh
|
||||||
index be0f3a2..b8c8d66 100755
|
index be0f3a2..d5d0c14 100755
|
||||||
--- a/configure.sh
|
--- a/configure.sh
|
||||||
+++ b/configure.sh
|
+++ b/configure.sh
|
||||||
@@ -116,6 +116,10 @@ case ${CC_MACHINE} in
|
@@ -89,6 +89,7 @@ ld_is_lld()
|
||||||
|
|
||||||
|
# Allow external override of CC.
|
||||||
|
CC=${CC:-cc}
|
||||||
|
+CXX=${CXX:-c++}
|
||||||
|
LD=${LD:-ld}
|
||||||
|
|
||||||
|
CC_MACHINE=$(${CC} -dumpmachine)
|
||||||
|
@@ -116,6 +117,10 @@ case ${CC_MACHINE} in
|
||||||
CONFIG_ARCH=x86_64 CONFIG_HOST=OpenBSD
|
CONFIG_ARCH=x86_64 CONFIG_HOST=OpenBSD
|
||||||
CONFIG_GUEST_PAGE_SIZE=0x1000
|
CONFIG_GUEST_PAGE_SIZE=0x1000
|
||||||
;;
|
;;
|
||||||
|
@ -305,7 +366,24 @@ index be0f3a2..b8c8d66 100755
|
||||||
*)
|
*)
|
||||||
die "Unsupported toolchain target: ${CC_MACHINE}"
|
die "Unsupported toolchain target: ${CC_MACHINE}"
|
||||||
;;
|
;;
|
||||||
@@ -202,8 +206,8 @@ case "${CONFIG_HOST}" in
|
@@ -131,6 +136,7 @@ CONFIG_SPT=
|
||||||
|
CONFIG_VIRTIO=
|
||||||
|
CONFIG_MUEN=
|
||||||
|
CONFIG_GENODE=
|
||||||
|
+CONFIG_HOST_CRT=
|
||||||
|
MAKECONF_CFLAGS=
|
||||||
|
MAKECONF_LDFLAGS=
|
||||||
|
MAKECONF_SPT_CFLAGS=
|
||||||
|
@@ -143,6 +149,8 @@ case "${CONFIG_HOST}" in
|
||||||
|
cc_is_gcc || die "Only 'gcc' 4.x+ is supported on Linux"
|
||||||
|
CC_INCDIR=$(${CC} -print-file-name=include)
|
||||||
|
[ -d "${CC_INCDIR}" ] || die "Cannot determine gcc include directory"
|
||||||
|
+
|
||||||
|
+ CONFIG_HOST_CRT=1
|
||||||
|
mkdir -p ${HOST_INCDIR}
|
||||||
|
cp -R ${CC_INCDIR}/. ${HOST_INCDIR}
|
||||||
|
|
||||||
|
@@ -202,8 +210,8 @@ case "${CONFIG_HOST}" in
|
||||||
fi
|
fi
|
||||||
[ "${CONFIG_ARCH}" = "x86_64" ] && CONFIG_VIRTIO=1
|
[ "${CONFIG_ARCH}" = "x86_64" ] && CONFIG_VIRTIO=1
|
||||||
[ "${CONFIG_ARCH}" = "x86_64" ] && CONFIG_MUEN=1
|
[ "${CONFIG_ARCH}" = "x86_64" ] && CONFIG_MUEN=1
|
||||||
|
@ -315,7 +393,15 @@ index be0f3a2..b8c8d66 100755
|
||||||
;;
|
;;
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
# On FreeBSD/clang we use -nostdlibinc which gives us access to the
|
# On FreeBSD/clang we use -nostdlibinc which gives us access to the
|
||||||
@@ -240,6 +244,21 @@ case "${CONFIG_HOST}" in
|
@@ -221,6 +229,7 @@ case "${CONFIG_HOST}" in
|
||||||
|
x86/_types.h x86/_limits.h"
|
||||||
|
SRCS="float.h osreldate.h stddef.h stdint.h stdbool.h stdarg.h"
|
||||||
|
|
||||||
|
+ CONFIG_HOST_CRT=1
|
||||||
|
mkdir -p ${HOST_INCDIR}
|
||||||
|
mkdir -p ${HOST_INCDIR}/machine ${HOST_INCDIR}/sys ${HOST_INCDIR}/x86
|
||||||
|
for f in ${SRCS_MACH}; do cp -f ${INCDIR}/$f ${HOST_INCDIR}/machine; done
|
||||||
|
@@ -240,6 +249,21 @@ case "${CONFIG_HOST}" in
|
||||||
[ "${CONFIG_ARCH}" = "x86_64" ] && CONFIG_MUEN=1
|
[ "${CONFIG_ARCH}" = "x86_64" ] && CONFIG_MUEN=1
|
||||||
CONFIG_GENODE=
|
CONFIG_GENODE=
|
||||||
;;
|
;;
|
||||||
|
@ -337,9 +423,26 @@ index be0f3a2..b8c8d66 100755
|
||||||
OpenBSD)
|
OpenBSD)
|
||||||
# On OpenBSD/clang we use -nostdlibinc which gives us access to the
|
# On OpenBSD/clang we use -nostdlibinc which gives us access to the
|
||||||
# clang-provided headers for compiler instrinsics. We copy the rest
|
# clang-provided headers for compiler instrinsics. We copy the rest
|
||||||
@@ -311,6 +330,7 @@ CONFIG_HOST=${CONFIG_HOST}
|
@@ -259,6 +283,7 @@ case "${CONFIG_HOST}" in
|
||||||
|
SRCS_AMD64="amd64/_float.h amd64/stdarg.h amd64/endian.h"
|
||||||
|
SRCS="float.h stddef.h stdint.h stdbool.h stdarg.h"
|
||||||
|
|
||||||
|
+ CONFIG_HOST_CRT=1
|
||||||
|
mkdir -p ${HOST_INCDIR}
|
||||||
|
mkdir -p ${HOST_INCDIR}/machine ${HOST_INCDIR}/sys ${HOST_INCDIR}/amd64
|
||||||
|
for f in ${SRCS_MACH}; do cp -f ${INCDIR}/$f ${HOST_INCDIR}/machine; done
|
||||||
|
@@ -304,13 +329,16 @@ CONFIG_SPT=${CONFIG_SPT}
|
||||||
|
CONFIG_VIRTIO=${CONFIG_VIRTIO}
|
||||||
|
CONFIG_MUEN=${CONFIG_MUEN}
|
||||||
|
CONFIG_GENODE=${CONFIG_GENODE}
|
||||||
|
+CONFIG_HOST_CRT=${CONFIG_HOST_CRT}
|
||||||
|
MAKECONF_CFLAGS=${MAKECONF_CFLAGS}
|
||||||
|
MAKECONF_LDFLAGS=${MAKECONF_LDFLAGS}
|
||||||
|
CONFIG_ARCH=${CONFIG_ARCH}
|
||||||
|
CONFIG_HOST=${CONFIG_HOST}
|
||||||
CONFIG_GUEST_PAGE_SIZE=${CONFIG_GUEST_PAGE_SIZE}
|
CONFIG_GUEST_PAGE_SIZE=${CONFIG_GUEST_PAGE_SIZE}
|
||||||
MAKECONF_CC=${CC}
|
MAKECONF_CC=${CC}
|
||||||
|
+MAKECONF_CXX=${CXX}
|
||||||
MAKECONF_LD=${LD}
|
MAKECONF_LD=${LD}
|
||||||
+MAKECONF_HOSTCC=${HOSTCC:-$CC}
|
+MAKECONF_HOSTCC=${HOSTCC:-$CC}
|
||||||
MAKECONF_SPT_CFLAGS=${MAKECONF_SPT_CFLAGS}
|
MAKECONF_SPT_CFLAGS=${MAKECONF_SPT_CFLAGS}
|
||||||
|
@ -450,3 +553,18 @@ index 7171244..a10655f 100644
|
||||||
conflicts: [
|
conflicts: [
|
||||||
"solo5-bindings-hvt"
|
"solo5-bindings-hvt"
|
||||||
"solo5-bindings-spt"
|
"solo5-bindings-spt"
|
||||||
|
diff --git a/tests/Makefile.tests b/tests/Makefile.tests
|
||||||
|
index 2cd0dcd..d4e1191 100644
|
||||||
|
--- a/tests/Makefile.tests
|
||||||
|
+++ b/tests/Makefile.tests
|
||||||
|
@@ -69,8 +69,9 @@ manifest.c: manifest.json ../../include/solo5/mft_abi.h $(ELFTOOL)
|
||||||
|
$(CC) $(GENODE_APP_CFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
%.genode: %.genode.o manifest.genode.o $(LDS.genode) $(BINDINGS.genode)
|
||||||
|
+ ln -sf $(BINDINGS.genode) solo5.lib.so
|
||||||
|
@echo "LD $@"
|
||||||
|
- $(LD) $(GENODE_APP_LDFLAGS) -T $(LDS.genode) $(BINDINGS.genode) \
|
||||||
|
+ $(LD) $(GENODE_APP_LDFLAGS) -T $(LDS.genode) solo5.lib.so \
|
||||||
|
$< manifest.genode.o -o $@
|
||||||
|
|
||||||
|
ifdef CONFIG_HVT
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
let Genode =
|
||||||
|
env:DHALL_GENODE
|
||||||
|
? https://git.sr.ht/~ehmry/dhall-genode/blob/master/package.dhall
|
||||||
|
|
||||||
|
in λ(testInit : Genode.Init.Type)
|
||||||
|
→ Genode.Init::{
|
||||||
|
, verbose = True
|
||||||
|
, defaultRoutes =
|
||||||
|
Genode.Init.default.defaultRoutes
|
||||||
|
# [ Genode.ServiceRoute.parent "IO_MEM"
|
||||||
|
, Genode.ServiceRoute.parent "IO_PORT"
|
||||||
|
, Genode.ServiceRoute.parent "IRQ"
|
||||||
|
, Genode.ServiceRoute.child "Timer" "timer"
|
||||||
|
]
|
||||||
|
, children =
|
||||||
|
toMap
|
||||||
|
{ timer =
|
||||||
|
Genode.Init.Start::{
|
||||||
|
, binary = "timer"
|
||||||
|
, resources = { caps = 96, ram = Genode.units.MiB 1 }
|
||||||
|
, provides = [ "Timer" ]
|
||||||
|
}
|
||||||
|
, init = Genode.Init.toStart testInit
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue