Compare commits

...

5 Commits

  1. 75
      Tuprules.tup
  2. 157
      default.nix
  3. 6
      flake.lock
  4. 3
      flake.nix
  5. 23
      repos/Tuprules.tup
  6. 4
      repos/base-nova/Tuprules.tup
  7. 13
      repos/base/Tupfile
  8. 20
      repos/base/Tuprules.tup
  9. 2
      repos/base/genode-base.pc.in
  10. 80
      repos/base/src/lib/cxx/Tupfile
  11. 4
      repos/gems/Tuprules.tup
  12. 1
      repos/gems/src/lib/vfs/Tuprules.tup
  13. 5
      repos/gems/src/lib/vfs/audit/Tupfile
  14. 5
      repos/gems/src/lib/vfs/trace/Tupfile
  15. 9
      repos/os/Tupfile
  16. 2
      repos/os/Tuprules.tup
  17. 2
      repos/os/genode-os.pc.in
  18. 2
      repos/os/src/lib/net/Tupfile
  19. 70
      toolchain.nix
  20. 47
      tup-genode/gcc.tup
  21. 40
      tup-genode/llvm.tup
  22. 8
      update-tup.sh

@ -1,26 +1,38 @@
.gitignore
AR = @(AR)
AS = @(AS)
CC = @(CC)
CXX = @(CXX)
LD= @(LD)
OBJCOPY = @(OBJCOPY)
OUT_DIR=$(TUP_CWD)/out
DEV_DIR = $(TUP_CWD)/dev
DEV_LIB_DIR = $(DEV_DIR)/lib
ifdef IS_GCC
include tup-genode/gcc.tup
endif
ifdef IS_LLVM
include tup-genode/llvm.tup
endif
ifeq ($(TOOLCHAIN_CONFIGURED),)
error no toolchain configuration is active
endif
ifneq ($(TOOLCHAIN_CONFIGURED),X)
error "multiple toolchain configurations are active "
endif
ifeq (@(TUP_ARCH),i386)
X86 = y
CC_MARCH = -march=i686 -m32
LD_MARCH = -melf_i386
AS_MARCH = -march=i686 --32
endif
ifeq (@(TUP_ARCH),x86_64)
X86 = y
TOOL_CHAIN_PREFIX=genode-x86-
CC_MARCH = -m64 -mcmodel=large
LD_MARCH = -melf_x86_64
endif
ifeq (@(TUP_ARCH),arm_v8)
CC_MARCH = -march=armv8-a
endif
GENODE_DIR = $(TUP_CWD)
@ -28,9 +40,9 @@ GENODE_DIR = $(TUP_CWD)
!prg = | $(DEV_DIR)/<lib> $(DEV_DIR)/<pkg-config> \
|> ^o LD %o^ \
$(LD) $(LD_MARCH) $(LDFLAGS) \
%f \
-L$(DEV_LIB_DIR) \
`$(PKG_CONFIG) --libs $(LIBS) genode-prg` \
%f \
$(LIBGCC) \
-o %o \
|> %d
@ -50,26 +62,9 @@ GENODE_DIR = $(TUP_CWD)
|> $(DEV_LIB_DIR)/%b \
$(DEV_DIR)/<lib> \
export CC
export CXX
export LD
CC = $CC
CXX = $CXX
LD= $LD
OBJCOPY = $OBJCOPY
ifdef CXXFLAGS
CXXFLAGS = @(CXXFLAGS)
endif
CXXFLAGS += -Wno-undefined-bool-conversion -Wno-unknown-attributes -Wsystem-headers -Werror -Wno-uninitialized -Wno-mismatched-tags
LIBGCC = `$(CC) $(CC_MARCH) -print-libgcc-file-name`
export PKG_CONFIG_PATH
PKG_CONFIG_DIR = $(DEV_DIR)/lib/pkgconfig
PKG_CONFIG = PKG_CONFIG_PATH=$(PKG_CONFIG_DIR):$PKG_CONFIG_PATH pkg-config
PKG_CONFIG = PKG_CONFIG_PATH=$(PKG_CONFIG_DIR) @(PKGCONFIG)
CFLAGS += -g
CXXFLAGS += -g
@ -80,27 +75,11 @@ else
OLEVEL = -O2
endif
!ir = | $(DEV_DIR)/<pkg-config> |> clang $(OLEVEL) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) `$(PKG_CONFIG) --cflags $(LIBS)` $(CPPFLAGS) -S -emit-llvm %f |> %B.ll
!asm = |> ^ CC %b^ @(CC_WRAPPER) $(CC) $(OLEVEL) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) -D__ASSEMBLY__ $(CPPFLAGS) -c %f -o %o |> %B.o
!cc = | $(DEV_DIR)/<pkg-config> |> ^o CC %f^ @(CC_WRAPPER) $(CC) $(OLEVEL) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) $(CPPFLAGS) `$(PKG_CONFIG) --cflags $(LIBS) $(LIBS_CFLAGS)` -c -fPIC %f -o %o |> %B.o
!cxx = | $(DEV_DIR)/<pkg-config> |> ^o CXX %b^ @(CC_WRAPPER) $(CXX) $(OLEVEL) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) $(CPPFLAGS) `$(PKG_CONFIG) --cflags $(LIBS)` -c -fPIC %f -o %o |> %B.o
!ld = | $(DEV_DIR)/<lib> $(DEV_DIR)/<pkg-config> |> ^o LD %o^ $(LD) $(LDFLAGS) `$(PKG_CONFIG) --libs $(LIBS)` --whole-archive --start-group %f --no-whole-archive --end-group -o %o |>
export STRIP
!strip = |> $STRIP -o %o %f |>
!ln = |> ln -s %f %o |>
!incbin = |> ^ incbin %f^ \
export SYM=_binary_`echo %f | sed 's/\./_/g'`; \
echo ".global ${SYM}_start, ${SYM}_end; .data; .align 4; ${SYM}_start:; .incbin \"%f\"; ${SYM}_end:" \
| llvm-mc -filetype=obj - > %o \
|> binary_%b.o
export AR
!ar = |> $AR -rcs %o %f |> %d.a
@ -110,12 +89,12 @@ SED_PKGCONFIG_FLAGS += -e "s|@VERSION@|$(GIT_VERSION)|"
!sed_pkgconfig_file = |> ^o SED %B^ \
sed $(SED_PKGCONFIG_FLAGS) $(SED_FLAGS) < %f > %o; \
pkg-config --validate %o; \
$(PKG_CONFIG) --validate %o; \
|> $(PKG_CONFIG_DIR)/%B $(DEV_DIR)/<pkg-config>
!sed_pkgconfig_flags = |> ^o SED %d.pc^ \
sed $(SED_PKGCONFIG_FLAGS) $(SED_FLAGS) > %o; \
pkg-config --validate %o; \
$(PKG_CONFIG) --validate %o; \
|> $(PKG_CONFIG_DIR)/%d.pc $(DEV_DIR)/<pkg-config>
!emit_lib_pkg_config = |> ^ emit %d.a pkg-config^ \
@ -123,5 +102,5 @@ SED_PKGCONFIG_FLAGS += -e "s|@VERSION@|$(GIT_VERSION)|"
echo Description: Genode %d library >> %o; \
echo Version: $(GIT_VERSION) >> %o; \
echo Libs: -l:%d.a >> %o; \
pkg-config --validate %o; \
$(PKG_CONFIG) --validate %o; \
|> $(PKG_CONFIG_DIR)/%d.pc $(DEV_DIR)/<pkg-config>

@ -1,21 +1,33 @@
{ localSystem ? "x86_64-linux", crossSystem ? "x86_64-genode", self ? { }, ...
}@args:
let
pinnedNixpkgs = import (builtins.fetchGit {
url = "https://gitea.c3d2.de/ehmry/nixpkgs.git";
ref = "genode";
});
in { localSystem ? "x86_64-linux", crossSystem ? "x86_64-genode"
, nixpkgs ? pinnedNixpkgs, self ? { } }:
let
nixpkgs' = if builtins.isAttrs nixpkgs then
nixpkgs
else
nixpkgs { inherit localSystem crossSystem; };
inherit (nixpkgs') buildPackages llvmPackages;
sourceForgeToolchain = nixpkgs'.buildPackages.callPackage ./toolchain.nix { };
nixpkgs =
args.nixpkgs or (pinnedNixpkgs { inherit localSystem crossSystem; });
stdenvLlvm = let inherit (nixpkgs') stdenv;
in assert stdenv.cc.isClang; stdenv;
inherit (nixpkgs) stdenv buildPackages llvmPackages;
stdenvGcc = let
stdenv =
nixpkgs'.stdenvAdapters.overrideCC nixpkgs'.stdenv sourceForgeToolchain;
in assert stdenv.cc.isGNU; stdenv;
src = self.outPath or (builtins.fetchGit ./.);
version = self.lastModified or "unstable";
inherit (stdenv) lib targetPlatform;
inherit (stdenvLlvm) lib targetPlatform;
specs = with targetPlatform;
[ ]
@ -35,7 +47,7 @@ let
++ lib.optional isx86_64 "x86_64";
buildRepo = { repo, repoInputs }:
toTupConfig = stdenv: attrs:
let
tupArch = with stdenv.targetPlatform;
@ -57,14 +69,71 @@ let
abort "unhandled targetPlatform";
toTupConfig = attrs:
with builtins;
let op = config: name: "${config}CONFIG_${name}=${getAttr name attrs} ";
attrs' = with stdenv; { TUP_ARCH = tupArch; } // attrs;
in nixpkgs'.writeTextFile {
name = "tup.config";
text = with builtins;
let
op = config: name: ''
${config}CONFIG_${name}=${getAttr name attrs}
'';
in foldl' op "" (attrNames attrs);
};
tupConfigGcc = let
f = stdenv:
let prefix = bin: "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}${bin}";
in {
AR = prefix "ar";
CC = prefix "gcc";
CXX = prefix "g++";
LD = prefix "ld";
NM = prefix "nm";
OBJCOPY = prefix "objcopy";
OBJDUMP = prefix "objdump";
RANLIB = prefix "ranlib";
READELF = prefix "readelf";
STRIP = prefix "strip";
PKGCONFIG = "${nixpkgs'.buildPackages.pkgconfig}/bin/pkg-config";
IS_GCC = "";
LINUX_HEADERS = buildPackages.glibc.dev;
VERSION = version;
};
in toTupConfig stdenvGcc (f stdenvGcc);
tupConfigLlvm = let
f = stdenv:
let prefix = bin: "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}${bin}";
in {
AR = prefix "ar";
CC = prefix "cc";
CXX = prefix "c++";
LD = prefix "ld";
NM = prefix "nm";
OBJCOPY = prefix "objcopy";
OBJDUMP = prefix "objdump";
RANLIB = prefix "ranlib";
READELF = prefix "readelf";
STRIP = prefix "strip";
PKGCONFIG = "${nixpkgs'.buildPackages.pkgconfig}/bin/pkg-config";
IS_LLVM = "";
LIBCXXABI = llvmPackages.libcxxabi;
LIBCXX = llvmPackages.libcxx;
LIBUNWIND_BAREMETAL =
llvmPackages.libunwind.override { isBaremetal = true; };
LIBUNWIND = llvmPackages.libunwind;
LINUX_HEADERS = buildPackages.glibc.dev;
VERSION = version;
};
in toTupConfig stdenvLlvm (f stdenvLlvm);
buildRepo = { stdenv, repo, repoInputs }:
let
in stdenv.mkDerivation {
name = "genode-${repo}-${version}";
outputs = [ "out" "dev" ];
pname = "genode-" + repo;
inherit src repo specs version;
setupHook = ./setup-hooks.sh;
@ -76,23 +145,19 @@ let
depsBuildBuild = with buildPackages; [ llvm pkgconfig tup ];
tupConfig = toTupConfig {
LIBCXX = llvmPackages.libcxx;
LIBCXXABI = llvmPackages.libcxxabi;
LIBUNWIND = llvmPackages.libunwind;
LIBUNWIND_BAREMETAL =
llvmPackages.libunwind.override { isBaremetal = true; };
LINUX_HEADERS = buildPackages.glibc.dev;
OLEVEL = "-O2";
TUP_ARCH = tupArch;
VERSION = version;
};
tupConfig = if stdenv.cc.isGNU then
tupConfigGcc
else if stdenv.cc.isClang then
tupConfigLlvm
else
throw "no Tup config for this stdenv";
configurePhase = ''
# Configure Tup
echo $tupConfig | tr ' CONFIG_' '\nCONFIG_' > tup.config
set -v
install -m666 $tupConfig tup.config
echo CONFIG_NIX_OUTPUTS_OUT=$out >> tup.config
echo CONFIG_NIX_OUTPUTS_DEV=$dev >> tup.config
echo CONFIG_NIX_OUTPUTS_DEV=$out >> tup.config
# Disable other repos
for R in repos/*; do
@ -104,13 +169,13 @@ let
tup generate buildPhase.sh
# Redirect artifacts to Nix store
mkdir -p $out/lib $dev/include
mkdir -p $out/lib $out/include
ln -s $out out
ln -s $dev dev
ln -s $out dev
'';
buildPhase = ''
test -d repos/$repo/src/ld && cp -rv repos/$repo/src/ld $dev/
test -d repos/$repo/src/ld && cp -rv repos/$repo/src/ld $out/
pushd .
set -v
source buildPhase.sh
@ -124,18 +189,18 @@ let
for DIR in repos/$repo/include; do
for SPEC in $specs; do
if [ -d $DIR/spec/$SPEC ]; then
cp -r $DIR/spec/$SPEC/* $dev/include
cp -r $DIR/spec/$SPEC/* $out/include
rm -r $DIR/spec/$SPEC
fi
done
rm -rf $DIR/spec
cp -r $DIR $dev/
cp -r $DIR $out/
done
fi
touch $dev/.genode
for pc in $dev/lib/pkgconfig/*.pc; do
sed -e "s|^Libs: |Libs: -L$dev/lib |" -i $pc
touch $out/.genode
for pc in $out/lib/pkgconfig/*.pc; do
sed -e "s|^Libs: |Libs: -L$out/lib |" -i $pc
done
'';
@ -147,41 +212,35 @@ let
maintainers = [ maintainers.ehmry ];
};
shellHook = ''
export PROMPT_DIRTRIM=2
export PS1="\[\033[1;30m\]Genode-dev [\[\033[1;37m\]\w\[\033[1;30m\]] $\[\033[0m\] "
export PS2="\[\033[1;30m\]>\[\033[0m\] "
if [ -e "configs/.gitignore" ]; then
local CFG=configs/${targetPlatform.config}.config
echo $tupConfig | tr ' CONFIG_' '\nCONFIG_' > $CFG
tup variant $CFG
fi
'';
};
buildRepo' = { ... } @ args: buildRepo ({ stdenv = stdenvGcc; } // args);
in rec {
base = buildRepo {
base = buildRepo' {
repo = "base";
repoInputs = [ ];
};
base-linux = buildRepo {
base-linux = buildRepo' {
repo = "base-linux";
repoInputs = [ base ];
};
base-nova = buildRepo {
base-nova = buildRepo' {
repo = "base-nova";
repoInputs = [ base ];
};
os = buildRepo {
os = buildRepo' {
repo = "os";
repoInputs = [ base ];
};
gems = buildRepo {
gems = buildRepo' {
repo = "gems";
repoInputs = [ os ];
};
inherit stdenvGcc stdenvLlvm tupConfigGcc tupConfigLlvm;
}

@ -2,9 +2,9 @@
"inputs": {
"nixpkgs": {
"inputs": {},
"narHash": "sha256-/9hMb9pgV8awDYYchUueplyKF6bz23b7z5gqQ999nro=",
"originalUrl": "git+https://gitea.c3d2.de/ehmry/nixpkgs.git?ref=genode",
"url": "git+https://gitea.c3d2.de/ehmry/nixpkgs.git?ref=genode&rev=d63ee96d86672a9cb23d83d50ee02687eded2818"
"narHash": "sha256-ddVEifoNDi/5YVOEnoJRjRiIM4vfa5m46+t0Wf7beQo=",
"originalUrl": "git+https://gitea.c3d2.de/ehmry/nixpkgs.git?ref=genode-devel",
"url": "git+https://gitea.c3d2.de/ehmry/nixpkgs.git?ref=genode-devel&rev=ffad0e9b6604e2670de1d756d102f91d5b951359"
}
},
"version": 3

@ -3,7 +3,7 @@
description = "Genode system flake";
inputs.nixpkgs.uri = "git+https://gitea.c3d2.de/ehmry/nixpkgs.git?ref=genode";
inputs.nixpkgs.uri = "git+https://gitea.c3d2.de/ehmry/nixpkgs.git?ref=genode-devel";
outputs = { self, nixpkgs }:
let
@ -13,6 +13,7 @@
nixpkgs = builtins.getAttr system nixpkgs.legacyPackages;
};
defaultPackage = packages.base-linux;
devShell = packages.base;
};
localSystems = [ "x86_64-linux" ];

@ -29,3 +29,26 @@ endif
BASE_DIR = $(GENODE_DIR)/repos/base
&BASE_DIR = base
ifndef NIX_OUTPUTS_DEV
ifeq (@(TUP_ARCH),i386)
CPPFLAGS += -I$(BASE_DIR)/include/spec/x86_32
CPPFLAGS += -I$(BASE_DIR)/include/spec/x86
CPPFLAGS += -I$(BASE_DIR)/include/spec/32bit
endif
ifeq (@(TUP_ARCH),x86_64)
CPPFLAGS += -I$(BASE_DIR)/include/spec/x86_64
CPPFLAGS += -I$(BASE_DIR)/include/spec/x86
CPPFLAGS += -I$(BASE_DIR)/include/spec/64bit
endif
ifeq (@(TUP_ARCH),arm64)
CPPFLAGS += -I$(BASE_DIR)/include/spec/arm_64
CPPFLAGS += -I$(BASE_DIR)/include/spec/64bit
endif
CPPFLAGS += -I$(BASE_DIR)/include
endif

@ -6,6 +6,10 @@ ifeq (@(TUP_ARCH),x86_64)
CPPFLAGS += -I$(TUP_CWD)/include/spec/64bit
endif
ifdef IS_GCC
CXXFLAGS += -Wno-attributes
endif
CPPFLAGS += -I$(TUP_CWD)/include
include &(BASE_DIR)/Tuprules.tup

@ -3,12 +3,23 @@ include_rules
ifdef NIX_OUTPUTS_DEV
SED_FLAGS += -e "s|@includedir@|@(NIX_OUTPUTS_DEV)/include|"
SED_FLAGS += -e "s|@lddir@|@(NIX_OUTPUTS_DEV)/ld|"
ifeq (@(TUP_ARCH),i386)
SED_FLAGS += -e "s|@includes@|-I\${includedir}/spec/x86_32 -I\${includedir}/spec/x86 -I\${includedir}/spec/32bit -I\${includedir}|"
endif
ifeq (@(TUP_ARCH),x86_64)
SED_FLAGS += -e "s|@includes@|-I\${includedir}/spec/x86_64 -I\${includedir}/spec/x86 -I\${includedir}/spec/64bit -I\${includedir}|"
endif
else
SED_FLAGS += -e "s|@includes@||"
SED_FLAGS += -e "s|@includedir@|`nix-store --add $(REP_DIR)/include`|"
SED_FLAGS += -e "s|@lddir@|`nix-store --add $(REP_DIR)/src/ld`|"
endif
SED_FLAGS += -e "s|@toolchainincludedir@|`$(CC) $(CC_MARCH) -print-file-name=include`|"
SED_FLAGS += -e "s|@libgcc@||"
SED_FLAGS += -e "s|@cc@|$(CC)|"

@ -1,30 +1,10 @@
REP_DIR = $(TUP_CWD)
ifeq (@(TUP_ARCH),i386)
CPPFLAGS += -I$(BASE_DIR)/include/spec/x86_32
CPPFLAGS += -I$(BASE_DIR)/include/spec/x86
CPPFLAGS += -I$(BASE_DIR)/include/spec/32bit
endif
ifeq (@(TUP_ARCH),x86_64)
CPPFLAGS += -I$(BASE_DIR)/include/spec/x86_64
CPPFLAGS += -I$(BASE_DIR)/include/spec/x86
CPPFLAGS += -I$(BASE_DIR)/include/spec/64bit
endif
ifeq (@(TUP_ARCH),arm64)
CPPFLAGS += -I$(BASE_DIR)/include/spec/arm_64
CPPFLAGS += -I$(BASE_DIR)/include/spec/64bit
endif
CPPFLAGS += -I$(BASE_DIR)/include
# Override base macros to bypass pkg-config
CXXFLAGS += \
-ffunction-sections \
-fno-strict-aliasing \
-nostdinc \
-Wall \
-std=gnu++17 \

@ -9,4 +9,4 @@ Name: base
Description: Genode base repository
URL: https://genode.org/
Version: @VERSION@
Cflags: -I${includedir} -I@toolchainincludedir@
Cflags: @includes@

@ -1,19 +1,3 @@
ifndef LIBCXX
error LIBCXX not configured
endif
ifndef LIBCXXABI
error LIBCXXABI not configured
endif
ifndef LIBUNWIND_BAREMETAL
error LIBUNWIND_BAREMETAL not configured
endif
ifndef LIBUNWIND
error LIBUNWIND not configured
endif
include_rules
COMMON_FLAGS = -ffunction-sections -fno-strict-aliasing
@ -21,13 +5,6 @@ COMMON_FLAGS = -ffunction-sections -fno-strict-aliasing
CFLAGS += $(COMMON_FLAGS)
CXXFLAGS += $(COMMON_FLAGS)
CPPFLAGS += -I@(LIBCXX)/include/c++/v1
CPPFLAGS += -I@(LIBCXXABI)/include
LLVM_LIBS += @(LIBCXXABI)/lib/libc++abi.a
: foreach *.cc |> !cxx |> {obj}
#
# Prevent symbols of the gcc support libs from being discarded during 'ld -r'
#
@ -86,22 +63,69 @@ EH_SYMBOLS += \
__aeabi_unwind_cpp_pr0 \
__aeabi_unwind_cpp_pr1 \
ifdef IS_LLVM
ifndef LIBCXX
error LIBCXX not configured
endif
ifndef LIBCXXABI
error LIBCXXABI not configured
endif
ifndef LIBUNWIND_BAREMETAL
error LIBUNWIND_BAREMETAL not configured
endif
ifndef LIBUNWIND
error LIBUNWIND not configured
endif
CPPFLAGS += -I@(LIBCXX)/include/c++/v1
CPPFLAGS += -I@(LIBCXXABI)/include
LLVM_LIBS += @(LIBCXXABI)/lib/libc++abi.a
endif
CPPFLAGS += -I`$(CC) -print-file-name=include`
: foreach *.cc |> !cxx |> {obj}
REDEF_SYMBOLS = `echo $(EH_SYMBOLS) | awk -v RS=' ' '{ print "--redefine-sym "$1"=_cxx_"$1 }'`
: foreach *.c |> !cc |> {obj}
ifdef IS_LLVM
: {obj} |> \
$(LD) $(LD_MARCH) $(KEEP_SYMBOLS) -r %f $(LLVM_LIBS) @(LIBUNWIND)/lib/libunwind.a -o %o |> supc++.tmp
: {obj} |> \
$(LD) $(LD_MARCH) $(KEEP_SYMBOLS) -r %f $(LLVM_LIBS) @(LIBUNWIND_BAREMETAL)/lib/libunwind.a -o %o |> supc++-baremetal.tmp
: foreach *.c |> !cc |> {obj}
export OBJCOPY
: supc++.tmp |> $OBJCOPY $(LOCAL_SYMBOLS) $(REDEF_SYMBOLS) %f %o |> supc++.o
: supc++.tmp |> $(OBJCOPY) $(LOCAL_SYMBOLS) $(REDEF_SYMBOLS) %f %o |> supc++.o
: supc++-baremetal.tmp |> $OBJCOPY $(LOCAL_SYMBOLS) $(REDEF_SYMBOLS) %f %o |> supc++-baremetal.o
#
: supc++.o |> !ar |> cxx.a {bin}
: supc++-baremetal.o |> !ar |> cxx-baremetal.a {bin}
: foreach {bin} |> !collect_static |>
: |> !emit_lib_pkg_config |>
endif
ifdef IS_GCC
LIBCXX_GCC += `$(CXX) $(CC_MARCH) -print-file-name=libsupc++.a`
#LIBCXX_GCC += `$(CXX) $(CC_MARCH) -print-file-name=libgcc_eh.a || true`
: {obj} |> \
$(LD) $(LD_MARCH) $(KEEP_SYMBOLS) -r %f $(LIBCXX_GCC) -o %o |> supc++.tmp
: supc++.tmp |> $OBJCOPY $(LOCAL_SYMBOLS) $(REDEF_SYMBOLS) %f %o |> supc++.o
: supc++.o |> !ar |> cxx.a {bin}
: foreach {bin} |> !collect_static |>
: |> !emit_lib_pkg_config |>
endif

@ -1 +1,5 @@
REP_DIR = $(TUP_CWD)
ifndef NIX_OUTPUTS_DEV
include ../os/Tuprules.tup
endif

@ -0,0 +1 @@
LIBS += genode-lib ldso-startup

@ -0,0 +1,5 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} |> !lib |> vfs_%d.lib.so {lib}
: foreach {lib} |> !collect_shared |>

@ -0,0 +1,5 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} |> !lib |> vfs_%d.lib.so {lib}
: foreach {lib} |> !collect_shared |>

@ -1,5 +1,10 @@
ifdef NIX_OUTPUTS_DEV
include_rules
ifdef NIX_OUTPUTS_DEV
SED_FLAGS += -e "s|@includedir@|@(NIX_OUTPUTS_DEV)/include/os|"
: *.pc.in |> !sed_pkgconfig_file |>
SED_FLAGS += -e "s|@includes@|-I${includedir}|"
else
SED_FLAGS += -e "s|@includes@||"
endif
: foreach *.pc.in |> !sed_pkgconfig_file |>

@ -17,3 +17,5 @@ endif
CPPFLAGS += -I$(REP_DIR)/include
CXXFLAGS += -std=gnu++17
LIBS += genode-base

@ -5,4 +5,4 @@ Description: Genode os repository
URL: https://genode.org/
Version: @VERSION@
Requires: genode-base
Cflags: -I${includedir}
Cflags: @includes@

@ -1,5 +1,7 @@
include_rules
LIBS += genode-base
: foreach *.cc |> !cxx |> {obj}
: {obj} |> !ar |> {bin}
: {bin} |> !collect_static |>

@ -0,0 +1,70 @@
# Shameless plagiarism of Blitz's toolchain expression:
# https://github.com/blitz/genode-nix
#
# WARNING: these binaries are from sourceforge and
# have not been publicly verified by Genode Labs.
#
{ stdenv, fetchurl, ncurses5, expat, makeWrapper, wrapCC }:
let
cc = stdenv.mkDerivation rec {
pname = "genode-toolchain";
version = "19.05";
src = fetchurl ({
x86_64-linux = {
url =
"mirror://sourceforge/project/genode/${pname}/${version}/${pname}-${version}-x86_64.tar.xz";
sha256 = "036czy21zk7fvz1y1p67q3d5hgg8rb8grwabgrvzgdsqcv2ls6l9";
};
}.${stdenv.buildPlatform.system} or (throw
"cannot install Genode toolchain on this platform"));
nativeBuildInputs = [ makeWrapper ];
phases = [ "unpackPhase" "fixupPhase" ];
dontStrip = true;
dontPatchELF = true;
libPath = stdenv.lib.makeLibraryPath [ "$out" stdenv.cc.cc expat ncurses5 ];
unpackPhase = ''
mkdir $out
tar xf $src --strip-components=5 -C $out
'';
preFixup = ''
for p in $(find "$out" -type f -executable); do
if isELF "$p"; then
echo "Patchelfing $p"
patchelf "$p"
patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$p" || true
patchelf --set-rpath ${libPath} "$p" || true
fi
done
pushd $out/bin
for BIN in genode-aarch64-*; do
makeWrapper ''${BIN} aarch64-unknown-genode-''${BIN#genode-aarch64-}
done
for BIN in genode-arm-*; do
makeWrapper ''${BIN} arm-unknown-genode-''${BIN#genode-arm-}
done
for BIN in genode-riscv-*; do
makeWrapper ''${BIN} riscv-unknown-genode-''${BIN#genode-riscv-}
done
for BIN in genode-x86-*; do
makeWrapper ''${BIN} i686-unknown-genode-''${BIN#genode-x86-}
makeWrapper ''${BIN} x86_64-unknown-genode-''${BIN#genode-x86-}
done
popd
'';
};
wrapped = wrapCC (cc // { isGNU = true; });
in wrapped.overrideAttrs (attrs: {
targetPrefix = "genode-x86-64-";
})

@ -0,0 +1,47 @@
TOOLCHAIN_CONFIGURED=$(TOOLCHAIN_CONFIGURED)X
ifeq (@(TUP_ARCH),i386)
CC_MARCH = -march=i686 -m32
LD_MARCH = -melf_i386
AS_MARCH = -march=i686 --32
endif
ifeq (@(TUP_ARCH),x86_64)
CC_MARCH = -m64 -mcmodel=large
LD_MARCH = -melf_x86_64
endif
ifeq (@(TUP_ARCH),arm_v8)
CC_MARCH = -march=armv8-a
endif
ifdef CXXFLAGS
CXXFLAGS = @(CXXFLAGS)
endif
CXXFLAGS += -Wno-error=implicit-fallthrough
CXXFLAGS += -Wno-error=unknown-pragmas
CXXFLAGS += -Wextra
CXXFLAGS += -Weffc++
CXXFLAGS += -Werror
CXXFLAGS += -Wsuggest-override
CXXFLAGS += -Wno-unknown-pragmas
LIBGCC = `$(CC) $(CC_MARCH) -print-libgcc-file-name`
!ir = | $(DEV_DIR)/<pkg-config> |> clang $(OLEVEL) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) `$(PKG_CONFIG) --cflags $(LIBS)` $(CPPFLAGS) -S -emit-llvm %f |> %B.ll
!asm = |> ^ CC %b^ @(CC_WRAPPER) $(CC) $(OLEVEL) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) -D__ASSEMBLY__ $(CPPFLAGS) -c %f -o %o |> %B.o
!cc = | $(DEV_DIR)/<pkg-config> |> ^o CC %f^ @(CC_WRAPPER) $(CC) $(OLEVEL) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) $(CPPFLAGS) `$(PKG_CONFIG) --cflags $(LIBS) $(LIBS_CFLAGS)` -c -fPIC %f -o %o |> %B.o
!cxx = | $(DEV_DIR)/<pkg-config> |> ^o CXX %b^ @(CC_WRAPPER) $(CXX) $(OLEVEL) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) $(CPPFLAGS) `$(PKG_CONFIG) --cflags $(LIBS)` -c -fPIC %f -o %o |> %B.o
!ld = | $(DEV_DIR)/<lib> $(DEV_DIR)/<pkg-config> |> ^o LD %o^ $(LD) $(LDFLAGS) `$(PKG_CONFIG) --libs $(LIBS)` --whole-archive --start-group %f --no-whole-archive --end-group -o %o |>
!incbin = |> ^ incbin %f^ \
export SYM=_binary_`echo %f | sed 's/\./_/g'`; \
echo ".global ${SYM}_start, ${SYM}_end; .data; .align 4; ${SYM}_start:; .incbin \"%f\"; ${SYM}_end:" \
| llvm-mc -filetype=obj - > %o \
|> binary_%b.o

@ -0,0 +1,40 @@
TOOLCHAIN_CONFIGURED=$(TOOLCHAIN_CONFIGURED)X
ifeq (@(TUP_ARCH),i386)
CC_MARCH = -march=i686 -m32
LD_MARCH = -melf_i386
AS_MARCH = -march=i686 --32
endif
ifeq (@(TUP_ARCH),x86_64)
CC_MARCH = -m64 -mcmodel=large
LD_MARCH = -melf_x86_64
endif
ifeq (@(TUP_ARCH),arm_v8)
CC_MARCH = -march=armv8-a
endif
ifdef CXXFLAGS
CXXFLAGS = @(CXXFLAGS)
endif
CXXFLAGS += -Wno-undefined-bool-conversion -Wno-unknown-attributes -Wsystem-headers -Werror -Wno-uninitialized -Wno-mismatched-tags
LIBGCC = `$(CC) $(CC_MARCH) -print-libgcc-file-name`
!ir = | $(DEV_DIR)/<pkg-config> |> clang $(OLEVEL) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) `$(PKG_CONFIG) --cflags $(LIBS)` $(CPPFLAGS) -S -emit-llvm %f |> %B.ll
!asm = |> ^ CC %b^ @(CC_WRAPPER) $(CC) $(OLEVEL) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) -D__ASSEMBLY__ $(CPPFLAGS) -c %f -o %o |> %B.o
!cc = | $(DEV_DIR)/<pkg-config> |> ^o CC %f^ @(CC_WRAPPER) $(CC) $(OLEVEL) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) $(CPPFLAGS) `$(PKG_CONFIG) --cflags $(LIBS) $(LIBS_CFLAGS)` -c -fPIC %f -o %o |> %B.o
!cxx = | $(DEV_DIR)/<pkg-config> |> ^o CXX %b^ @(CC_WRAPPER) $(CXX) $(OLEVEL) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) $(CPPFLAGS) `$(PKG_CONFIG) --cflags $(LIBS)` -c -fPIC %f -o %o |> %B.o
!ld = | $(DEV_DIR)/<lib> $(DEV_DIR)/<pkg-config> |> ^o LD %o^ $(LD) $(LDFLAGS) `$(PKG_CONFIG) --libs $(LIBS)` --whole-archive --start-group %f --no-whole-archive --end-group -o %o |>
!incbin = |> ^ incbin %f^ \
export SYM=_binary_`echo %f | sed 's/\./_/g'`; \
echo ".global ${SYM}_start, ${SYM}_end; .data; .align 4; ${SYM}_start:; .incbin \"%f\"; ${SYM}_end:" \
| llvm-mc -filetype=obj - > %o \
|> binary_%b.o

@ -0,0 +1,8 @@
#! /bin/sh
set -e
mkdir -p configs
nix build .#packages.x86_64-linux-x86_64-genode.tupConfigGcc -o configs/x86_64-gcc.config
nix build .#packages.x86_64-linux-x86_64-genode.tupConfigLlvm -o configs/x86_64-llvm.config
nix run nixpkgs#tup -c tup variant configs/x86_64-gcc.config || true
nix run nixpkgs#tup -c tup variant configs/x86_64-llvm.config || true
Loading…
Cancel
Save