Update SDK rules

This commit is contained in:
Ehmry - 2019-06-27 11:34:34 +02:00
parent 3d8ab16763
commit e1172fac40
20 changed files with 144 additions and 171 deletions

View File

@ -1,22 +0,0 @@
include_rules
: $(BASE_DIR)/src/ld/genode.ld |> !cp |> $(SDK_DIR)/ld/%b {ld}
: $(BASE_DIR)/src/ld/genode_dyn.dl |> !cp |> $(SDK_DIR)/ld/%b {ld}
: $(BASE_DIR)/src/ld/genode_dyn.ld |> !cp |> $(SDK_DIR)/ld/%b {ld}
: $(BASE_DIR)/src/ld/genode_rel.ld |> !cp |> $(SDK_DIR)/ld/%b {ld}
: $(BASE_DIR)/src/lib/ldso/startup/startup.cc |> ^ CC %f^ \
$(CXX) -c %f -o %o -fPIC |> %B.o
!merge = |> ^ MERGE %o^ $(AR) -rcs %o %f |>
: startup.o |> !merge |> $(SDK_DIR)/$(LOCAL_LIB_PREFIX)/arm64/ldso-startup.lib.a {startup}
: startup.o |> !merge |> $(SDK_DIR)/$(LOCAL_LIB_PREFIX)/x86_32/ldso-startup.lib.a {startup}
: startup.o |> !merge |> $(SDK_DIR)/$(LOCAL_LIB_PREFIX)/x86_64/ldso-startup.lib.a {startup}
: {ld} {startup} $(SDK_DIR)/<pkgconfigs> $(SDK_DIR)/<api_tarballs> |> \
tar cf %o --transform='s|^|$(SDK_PREFIX)/|' -C sdk . ; \
for t in %<api_tarballs>; do \
tar --concatenate -f %o $t; \
done \
|> sdk.tar

View File

@ -1,10 +0,0 @@
include_rules
SED_FLAGS_CMAKE += -e 's|@SDK_VERSION@|$(SDK_VERSION)|'
SED_FLAGS_CMAKE += -e 's|@SDK_PREFIX@|$(SDK_PREFIX)|'
ifeq ($(ARCH),x86_64)
SED_FLAGS_CMAKE += -e 's|@COMPILER_PREFIX@|/usr/local/genode-gcc/bin/genode-x86-|'
endif
: Toolchain.cmake.in |> sed $(SED_FLAGS_CMAKE) %f > %o |> %B

View File

@ -1,37 +1,40 @@
{ pkgs ? import <nixpkgs> {} }: with pkgs;
{ toolchain, pkgs ? import <nixpkgs> {} }: with pkgs;
let
genodeVersion = "19.05";
toolchain = import ../errata/toolchain.nix { inherit pkgs; };
upstream = fetchFromGitHub {
owner = "genodelabs";
repo = "genode";
rev = "19.05";
sha256 = "01sgixyvsq5g7fd0nj9j67d9jma0bhlprwyjf21dql9hqn5k0ngf";
};
version = "19.05";
tarball = fetchurl {
url = "https://github.com/genodelabs/genode/archive/19.05.tar.gz";
sha256 = "1mr81885ysjff7plfvav6cr3lx5yhlcyq63q8c8bfvgi1fcarbww";
};
in
stdenv.mkDerivation {
name = "genode-sdk-${genodeVersion}";
version = genodeVersion;
name = "genode-sdk-${version}";
inherit tarball version;
phases = "mainPhase";
toolchain_dir = toolchain.out;
tool_prefix = "genode-x86-";
inherit upstream;
src = upstream;
phases = [ "mainPhase" ];
spec_includes="-I\${includedir}/spec/x86_64 -I\${includedir}/spec/x86 -I\${includedir}/spec/64bit";
mainPhase = ''
dest=$out/opt/genode
mkdir -p $dest
export includedir=$out/include
export libdir=$out/lib
pkg_config_dir=$out/pkg-config
mkdir -p $includedir $pkg_config_dir
tar xf $src --strip-components=3 -C $dest
for i in ${./pkg-config}/*.pc; do
substituteAll "$i" "$out/pkg-config/`basename $i`"
done
for i in $dest/pkgconfig/*/*.pc; do
substituteInPlace "$i" \
--replace /opt/genode/sdk-${genodeVersion} $dest \
--replace @TOOLCHAIN_DIR@ $toolchain_dir \
; done
tar xfv ${tarball} \
--transform='s|genode-${version}/repos/base/include|genode-base/|' \
--transform='s|genode-${version}/repos/os/include|genode-os/|' \
--transform='s|genode-${version}/repos/gems/include|genode-gems/|' \
-C $includedir \
genode-${version}/repos/base/include \
genode-${version}/repos/os/include \
genode-${version}/repos/gems/include \
'';
}

View File

@ -1,13 +0,0 @@
includedir=@includedir@/genode-base
toolchaindir=@TOOLCHAIN_DIR@
cc=${toolchaindir}/bin/@TOOL_PREFIX@gcc
cxx=${toolchaindir}/bin/@TOOL_PREFIX@g++
ld=${toolchaindir}/bin/@TOOL_PREFIX@ld
ar=${toolchaindir}/bin/@TOOL_PREFIX@ar
ranlib=${toolchaindir}/bin/@TOOL_PREFIX@ranlib
Name: base
Description: Genode base library
URL: https://genode.org/
Version: @SDK_VERSION@
Cflags: -nostdinc -fPIC -I${includedir} @SPEC_INCLUDES@ -I${toolchaindir}/lib/gcc/x86_64-pc-elf/8.3.0/include

View File

@ -1,7 +0,0 @@
includedir=@includedir@/genode-gems
Name: base
Description: Genode gems headers
URL: https://genode.org/
Version: @SDK_VERSION@
Cflags: -I${includedir}

View File

@ -1,11 +0,0 @@
prefix=@prefix@
lddir=${prefix}/ld
libdir=@libdir@
toolchaindir=@TOOLCHAIN_DIR@
Name: genode-lib
Description: Flags for linking Genode libraries
URL: https://genode.org/
Version: @SDK_VERSION@
Requires: genode-base
Libs: -shared --eh-frame-hdr -melf_x86_64 -gc-sections -z max-page-size=0x1000 -T ${lddir}/genode_rel.ld --entry=0x0 ${libdir}/ldso-startup.lib.a ${toolchaindir}/lib/gcc/x86_64-pc-elf/8.3.0/64/libgcc.a

View File

@ -1,7 +0,0 @@
includedir=@includedir@/genode-os
Name: os
Description: Genode os API
URL: https://genode.org/
Version: @SDK_VERSION@
Cflags: -std=gnu++17 -I${includedir} @SPEC_INCLUDES@

View File

@ -1,12 +0,0 @@
prefix=@prefix@
lddir=${prefix}/ld
libdir=@libdir@
toolchaindir=@TOOLCHAIN_DIR@
ld=${toolchaindir}/bin/genode-x86-ld
Name: genode-prg
Description: Flags for dynamically-linked Genode programs
URL: https://genode.org/
Version: @SDK_VERSION@
Requires: genode-base
Libs: -melf_x86_64 -gc-sections -z max-page-size=0x1000 --dynamic-list=${lddir}/genode_dyn.dl -nostdlib -Ttext=0x01000000 --dynamic-linker=ld.lib.so --eh-frame-hdr -rpath-link=. -T ${lddir}/genode_dyn.ld ${libdir}/ld.lib.so ${toolchaindir}/lib/gcc/x86_64-pc-elf/8.3.0/64/libgcc.a

View File

@ -1,5 +0,0 @@
Name: ld
Description: Genode dynamic loader
URL: https://genode.org/
Version: @SDK_VERSION@
Libs: -l:ld.lib.so

View File

@ -1,7 +0,0 @@
libdir=@libdir@
Name: VFS
Description: Genode Virtual File-System library
URL: https://genode.org/
Version: @SDK_VERSION@
Libs: -L${libdir} -l:vfs.lib.so

View File

@ -1,17 +0,0 @@
include_rules
SED_FLAGS_arm64 += -e 's|@TOOL_PREFIX@|genode-arm-|'
SED_FLAGS_arm64 += -e 's|@SPEC_INCLUDES@| -I${includedir}/spec/arm_64 -I${includedir}/spec/64bit|'
SED_FLAGS_i386 += -e 's|@TOOL_PREFIX@|genode-x86-|'
SED_FLAGS_i386 += -e 's|@SPEC_INCLUDES@|-I${includedir}/spec/x86_32 -I${includedir}/spec/x86 -I${includedir}/spec/32bit|'
SED_FLAGS_x86_64 += -e 's|@TOOL_PREFIX@|genode-x86-|'
SED_FLAGS_x86_64 += -e 's|@SPEC_INCLUDES@|-I${includedir}/spec/x86_64 -I${includedir}/spec/x86 -I${includedir}/spec/64bit|'
: foreach *.pc.in |> !sed_pkgconfig_file |>
TAR_FLAGS += --transform='s|/include/|/include/genode-base/|'
TAR_FLAGS += -C $(REP_DIR) include
include $(SDK_TAR_INCLUDE)

View File

@ -1,6 +0,0 @@
include_rules
include $(SDK_ABI_INCLUDE)
: foreach *.pc.in |> !sed_pkgconfig_file |>
include $(SDK_TAR_INCLUDE)

View File

@ -1,8 +0,0 @@
include_rules
: *.pc.in |> !sed_pkgconfig_file |>
TAR_FLAGS += --transform='s|/include/|/include/genode-gems/|'
TAR_FLAGS += -C $(REP_DIR) include
include $(SDK_TAR_INCLUDE)

View File

@ -1,17 +0,0 @@
include_rules
SED_FLAGS += -e 's|@TOOLCHAIN_DIR@|/usr/local/genode-gcc|'
SED_FLAGS_arm64 += -e 's|@SPEC_INCLUDES@|-I${includedir}/spec/arm_64 -I${includedir}/spec/64bit|'
SED_FLAGS_i386 += -e 's|@SPEC_INCLUDES@|-I${includedir}/spec/x86_32 -I${includedir}/spec/x86 -I${includedir}/spec/32bit|'
SED_FLAGS_x86_64 += -e 's|@SPEC_INCLUDES@|-I${includedir}/spec/x86_64 -I${includedir}/spec/x86 -I${includedir}/spec/64bit|'
: genode-os.pc.in |> !sed_pkgconfig_file |>
TAR_FLAGS += --transform='s|/include/|/include/genode-os/|'
TAR_FLAGS += -C $(REP_DIR) include
include $(SDK_TAR_INCLUDE)

View File

@ -1,5 +0,0 @@
include_rules
include $(SDK_ABI_INCLUDE)
: vfs.pc.in |> !sed_pkgconfig_file |>
include $(SDK_TAR_INCLUDE)

50
tests/iso/Tupfile Normal file
View File

@ -0,0 +1,50 @@
include_rules
export SYSLINUX
# boot_modules.o {modules}
LINK_ADDRESS = 0x01000000
# : {modules}
: modules.txt |> \
awk -f a.awk < %f >> %o; \
awk -f b.awk < %f >> %o; \
awk -f c.awk < %f >> %o; \
|> modules.s
: | \
$(GENODE_DIR)/repos/base-nova/<core> \
$(GENODE_DIR)/repos/base-nova/<ld> \
|> \
$(CXX) -nostdlib \
-Wl,-z -Wl,max-page-size=0x1000 \
-Wl,-Ttext=$(LINK_ADDRESS) -Wl,-gc-sections \
-Wl,-nostdlib \
-Wl,--whole-archive -Wl,--start-group \
%<core> %<ld> \
-Wl,--no-whole-archive \
-Wl,--end-group $libgcc -o %o \
|> image.elf
: image.elf |> gzip --keep %f |> %b.gz
: hypervisor image.elf.gz |> \
mkdir -p tmp/syslinux; \
cp \
$SYSLINUX/share/syslinux/isolinux.bin \
$SYSLINUX/share/syslinux/ldlinux.c32 \
$SYSLINUX/share/syslinux/libcom32.c32 \
$SYSLINUX/share/syslinux/mboot.c32 \
isolinux.cfg \
tmp/syslinux; \
cp %f tmp; \
chmod -R 777 tmp; \
mkisofs -o %o \
-b syslinux/isolinux.bin -c syslinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-iso-level 2 \
tmp; \
rm -r tmp; \
|> output.iso

25
tests/iso/a.awk Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env -S awk -f
BEGIN {
print ".set MIN_PAGE_SIZE_LOG2, 12";
print ".set DATA_ACCESS_ALIGNM_LOG2, 3";
print "";
print ".section .data";
print "";
print ".p2align DATA_ACCESS_ALIGNM_LOG2";
print ".global _boot_modules_headers_begin";
print "_boot_modules_headers_begin:";
print "";
}
{
print ".quad _boot_module_"NR"_name";
print ".quad _boot_module_"NR"_begin";
print ".quad _boot_module_"NR"_end - _boot_module_"NR"_begin";
print "";
}
END {
print ".global _boot_modules_headers_end";
print "_boot_modules_headers_end:";
print "";
}

14
tests/iso/b.awk Normal file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env -S awk -f
BEGIN {
FS = "/"
}
{
print ".p2align DATA_ACCESS_ALIGNM_LOG2";
print "_boot_module_"NR"_name:";
print ".string \""$(NF)"\"";
print ".byte 0";
print "";
}

23
tests/iso/c.awk Normal file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env -S awk -f
BEGIN {
print ".section .data.boot_modules_binaries";
print "";
print ".global _boot_modules_binaries_begin";
print "_boot_modules_binaries_begin:";
print "";
}
{
print ".p2align MIN_PAGE_SIZE_LOG2";
print "_boot_module_"NR"_begin:";
print ".incbin \""$0"\"";
print "_boot_module_"NR"_end:";
print "";
}
END {
print ".p2align MIN_PAGE_SIZE_LOG2";
print ".global _boot_modules_binaries_end";
print "_boot_modules_binaries_end:";
print "";
}

5
tests/iso/isolinux.cfg Normal file
View File

@ -0,0 +1,5 @@
SERIAL
DEFAULT 0
LABEL 0
KERNEL mboot.c32
APPEND /hypervisor serial novga --- /image_elf.gz