Browse Source

Use patched binary toolchain from Genode Labs

- Fetch and patch GCC distribution
 - Pass Tup config as a file
 - Fold out and dev outputs
 - Remove shellHook code for compatibility with dev-shell
 - Tweak Tup Nix conditionals
 - Add Tupfile.ini
 - Remove custom setup-hook
staging
Emery Hemingway 2 years ago
parent
commit
969180525f
  1. 7
      .gitignore
  2. 0
      Tupfile.ini
  3. 96
      Tuprules.tup
  4. 227
      default.nix
  5. 6
      enter-shell.sh
  6. 4
      flake.lock
  7. 9
      flake.nix
  8. 26
      repos/Tuprules.tup
  9. 4
      repos/base-linux/src/core/Tupfile
  10. 4
      repos/base-linux/src/lib/base-common/Tupfile
  11. 16
      repos/base-linux/src/lib/ld/Tupfile
  12. 2
      repos/base-linux/src/lib/syscall/Tupfile
  13. 4
      repos/base-nova/Tuprules.tup
  14. 7
      repos/base-nova/src/core/Tupfile
  15. 13
      repos/base/Tupfile
  16. 23
      repos/base/Tuprules.tup
  17. 2
      repos/base/genode-base.pc.in
  18. 2
      repos/base/src/lib/alarm/Tupfile
  19. 90
      repos/base/src/lib/cxx/Tupfile
  20. 20
      repos/base/src/lib/ld/Tupfile
  21. 2
      repos/base/src/lib/ldso-startup/Tupfile
  22. 2
      repos/base/src/lib/timeout/Tupfile
  23. 6
      repos/gems/Tuprules.tup
  24. 1
      repos/gems/src/lib/vfs/Tuprules.tup
  25. 5
      repos/gems/src/lib/vfs/audit/Tupfile
  26. 5
      repos/gems/src/lib/vfs/trace/Tupfile
  27. 17
      repos/os/Tupfile
  28. 2
      repos/os/Tuprules.tup
  29. 4
      repos/os/genode-os.pc.in
  30. 2
      repos/os/src/lib/net/Tupfile
  31. 2
      repos/os/src/lib/vfs/Tupfile
  32. 1
      repos/os/src/lib/vfs/vfs.pc.in
  33. 7
      setup-hooks.sh
  34. 75
      toolchain.nix
  35. 47
      tup-genode/gcc.tup
  36. 40
      tup-genode/llvm.tup
  37. 8
      update-tup.sh

7
.gitignore

@ -13,3 +13,10 @@ result-*
/.tup
/build-*
/configs
##### TUP GITIGNORE #####
##### Lines below automatically generated by Tup.
##### Do not edit.
.tup
/.gitignore
/dev
/out

0
Tupfile.ini

96
Tuprules.tup

@ -1,44 +1,50 @@
.gitignore
AR = @(AR)
AS = @(AS)
CC = @(CC)
CXX = @(CXX)
LD= @(LD)
OBJCOPY = @(OBJCOPY)
STRIP = @(STRIP)
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)
!prg = | $(DEV_DIR)/<lib> $(DEV_DIR)/<pkg-config> \
|> ^o LD %o^ \
$(LD) $(LD_MARCH) $(LDFLAGS) \
-L$(DEV_LIB_DIR) \
`$(PKG_CONFIG) --libs $(LIBS) genode-prg` \
%f \
$(LIBGCC) \
-o %o \
|> %d
|> ^o LD %o^ $(LD) -o %o $(LD_MARCH) $(LDFLAGS) -L$(DEV_LIB_DIR) %f `$(PKG_CONFIG) --libs $(LIBS) genode-prg` $(LIBGCC) |> %d
!lib = | $(DEV_DIR)/<lib> $(DEV_DIR)/<pkg-config> |> ^o LD %o^ $(LD) $(LD_MARCH) %f $(LDFLAGS) `$(PKG_CONFIG) --libs genode-lib $(LIBS)` -L$(DEV_LIB_DIR) -o %o |> %d.lib.so
!collect_bin = |> ^ COLLECT %b^ \
$STRIP -o %o %f \
$(STRIP) -o %o %f \
|> $(OUT_DIR)/bin/%b $(OUT_DIR)/<bin>
!collect_shared = |> ^ COLLECT %b^ \
@ -50,26 +56,14 @@ 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`
PKG_CONFIG_DIR = $(DEV_DIR)/lib/pkgconfig
ifdef NIX_OUTPUTS_DEV
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):$PKG_CONFIG_PATH @(PKGCONFIG)
else
PKG_CONFIG = PKG_CONFIG_PATH=$(PKG_CONFIG_DIR) @(PKGCONFIG)
endif
CFLAGS += -g
CXXFLAGS += -g
@ -80,29 +74,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 |>
!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
!ar = |> $(AR) -rcs %o %f |> %d.a
GIT_VERSION = `git describe || echo @(VERSION)`
@ -110,12 +86,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 +99,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>

227
default.nix

@ -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; };
nixpkgs =
args.nixpkgs or (pinnedNixpkgs { inherit localSystem crossSystem; });
inherit (nixpkgs') buildPackages llvmPackages;
inherit (nixpkgs) stdenv buildPackages llvmPackages;
sourceForgeToolchain = nixpkgs'.buildPackages.callPackage ./toolchain.nix { };
stdenvLlvm = let inherit (nixpkgs') stdenv;
in assert stdenv.cc.isClang; stdenv;
stdenvGcc = let
env =
nixpkgs'.stdenvAdapters.overrideCC nixpkgs'.stdenv sourceForgeToolchain;
in assert env.cc.isGNU; env;
src = self.outPath or (builtins.fetchGit ./.);
version = self.lastModified or "unstable";
inherit (stdenv) lib targetPlatform;
inherit (stdenvLlvm) lib targetPlatform;
specs = with targetPlatform;
[ ]
@ -35,9 +47,9 @@ let
++ lib.optional isx86_64 "x86_64";
buildRepo = { repo, repoInputs }:
toTupConfig = env: attrs:
let
tupArch = with stdenv.targetPlatform;
tupArch = with env.targetPlatform;
if isAarch32 then
"arm"
@ -57,17 +69,95 @@ let
abort "unhandled targetPlatform";
toTupConfig = attrs:
with builtins;
let op = config: name: "${config}CONFIG_${name}=${getAttr name attrs} ";
in foldl' op "" (attrNames attrs);
attrs' = with env; { TUP_ARCH = tupArch; } // attrs;
in with builtins;
env.mkDerivation {
name = "tup.config";
nativeBuildInputs = with nixpkgs'.buildPackages; [
binutils
pkgconfig
which
];
text = let
op = config: name: ''
${config}CONFIG_${name}=${getAttr name attrs}
'';
in foldl' op "" (attrNames attrs);
passAsFile = [ "text" ];
preferLocalBuild = true;
buildCommand = let
subst = let
vars = [ "AR" "NM" ];
f = other: var:
other + ''
echo CONFIG_${var}=`which ''$${var}` >> $out
'';
in foldl' f "" vars;
utils = let
vars = [ "pkg-config" "objcopy" ];
f = other: var:
other + ''
echo CONFIG_${var}=`which ${var}` >> $out
'';
in foldl' f "" vars;
in ''
cp $textPath $out
${subst}
${utils}
'';
};
in stdenv.mkDerivation {
name = "genode-${repo}-${version}";
outputs = [ "out" "dev" ];
inherit src repo specs version;
tupConfigGcc = let
f = env:
let prefix = bin: env.cc.targetPrefix + bin;
in {
CC = prefix "gcc";
CXX = prefix "g++";
LD = prefix "ld";
OBJCOPY = prefix "objcopy";
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 = env:
let prefix = bin: "${env.cc}/bin/${env.cc.targetPrefix}${bin}";
in {
CC = prefix "cc";
CXX = prefix "c++";
LD = prefix "ld";
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 = { env, repo, repoInputs }:
let
setupHook = ./setup-hooks.sh;
in env.mkDerivation {
pname = "genode-" + repo;
inherit src repo specs version;
nativeBuildInputs = repoInputs;
# This is wrong, why does pkg-config not collect buildInputs?
@ -76,23 +166,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 env.cc.isGNU then
tupConfigGcc
else if env.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 +190,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,22 +210,22 @@ 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
'';
meta = with stdenv.lib; {
meta = with env.lib; {
description =
"The Genode operation system framework (${repo} repository).";
homepage = "https://genode.org/";
@ -147,41 +233,44 @@ 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 ({ env = stdenvGcc; } // args);
#builtins.throw "create the tup config file in the stdenv environment, replacing CC/CXX with environmental variables"
in rec {
base = buildRepo {
repo = "base";
repoInputs = [ ];
};
packages = rec {
base = buildRepo' {
repo = "base";
repoInputs = [ ];
};
base-linux = buildRepo {
repo = "base-linux";
repoInputs = [ base ];
};
base-linux = buildRepo' {
repo = "base-linux";
repoInputs = [ base ];
};
base-nova = buildRepo {
repo = "base-nova";
repoInputs = [ base ];
};
base-nova = buildRepo' {
repo = "base-nova";
repoInputs = [ base ];
};
os = buildRepo {
repo = "os";
repoInputs = [ base ];
};
os = buildRepo' {
repo = "os";
repoInputs = [ base ];
};
gems = buildRepo' {
repo = "gems";
repoInputs = [ base os ];
};
inherit stdenvGcc stdenvLlvm tupConfigGcc tupConfigLlvm;
gems = buildRepo {
repo = "gems";
repoInputs = [ os ];
};
defaultPackage = packages.base-linux;
devShell = packages.base;
}

6
enter-shell.sh

@ -0,0 +1,6 @@
#! /bin/sh
set -e
nix build .#packages.x86_64-linux-x86_64-genode.tupConfigGcc -o tup.config
export SHELL=bash
exec nix dev-shell

4
flake.lock

@ -2,9 +2,9 @@
"inputs": {
"nixpkgs": {
"inputs": {},
"narHash": "sha256-/9hMb9pgV8awDYYchUueplyKF6bz23b7z5gqQ999nro=",
"narHash": "sha256-EqxCk6ORqq4fkewWttpvks0VycBec9X9spAZ+Pq/CEI=",
"originalUrl": "git+https://gitea.c3d2.de/ehmry/nixpkgs.git?ref=genode",
"url": "git+https://gitea.c3d2.de/ehmry/nixpkgs.git?ref=genode&rev=d63ee96d86672a9cb23d83d50ee02687eded2818"
"url": "git+https://gitea.c3d2.de/ehmry/nixpkgs.git?ref=genode&rev=cf50f3b8bdc28832249afab6bca68acad832e011"
}
},
"version": 3

9
flake.nix

@ -3,17 +3,16 @@
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";
outputs = { self, nixpkgs }:
let
mkOutput = { system, localSystem, crossSystem }: rec {
packages = import ./default.nix {
mkOutput = { system, localSystem, crossSystem }:
import ./default.nix {
inherit localSystem crossSystem self;
nixpkgs = builtins.getAttr system nixpkgs.legacyPackages;
};
defaultPackage = packages.base-linux;
};
localSystems = [ "x86_64-linux" ];
crossSystems = [ "x86_64-genode" ];

26
repos/Tuprules.tup

@ -19,13 +19,27 @@ endif
-e "s/^\(\w\+\) B \(\w\+\)\$/.bss; .global \1; .type \1,%%object; .size \1,\2; \1:/" \
-e "s/^\(\w\+\) U/.text; .global \1; $(ASM_SYM_DEPENDENCY)/" \
%f \
| $(CC) -x assembler -c - -o tmp.o; \
$(LD) -o %o \
-shared \
-T &(LD_SCRIPT_SO) \
tmp.o; \
rm tmp.o; \
| $(CC) $(CC_MARCH) -x assembler -c - -Wl,-shared -Wl,-T&(LD_SCRIPT_SO) -o %o \
|> $(DEV_LIB_DIR)/%B.lib.so $(DEV_DIR)/<lib>
BASE_DIR = $(GENODE_DIR)/repos/base
&BASE_DIR = base
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

4
repos/base-linux/src/core/Tupfile

@ -41,7 +41,7 @@ LDFLAGS += -Ttext=0x01000000
LDFLAGS += -T$(BASE_DIR)/src/ld/genode.ld
LDFLAGS += -T$(REP_DIR)/src/ld/stack_area.ld
LDFLAGS += -L$(DEV_LIB_DIR) `$(PKG_CONFIG) --libs cxx-baremetal`
PKG_LIBS = -L$(DEV_DIR)/lib `$(PKG_CONFIG) --libs cxx`
: {obj} | \
$(DEV_DIR)/<lib> \
@ -49,7 +49,7 @@ LDFLAGS += -L$(DEV_LIB_DIR) `$(PKG_CONFIG) --libs cxx-baremetal`
$(REP_DIR)/<base-common> \
$(REP_DIR)/<startup> \
$(REP_DIR)/<syscall> \
|> !ld %<base-common> %<startup> %<syscall> \
|> $(LD) -o %o $(LD_MARCH) $(LDFLAGS) --start-group %f %<base-common> %<startup> %<syscall> $(PKG_LIBS) -end-group $(LIBGCC) \
|> core-linux $(REP_DIR)/<core> {bin}
: {bin} |> !collect_bin |>

4
repos/base-linux/src/lib/base-common/Tupfile

@ -30,8 +30,6 @@ GENERIC_SRC_CC += \
$(GENERIC_DIR)/thread_myself.cc \
$(GENERIC_DIR)/trace.cc \
#CXXFLAGS += -mllvm -opt-bisect-limit=1
: foreach $(GENERIC_SRC_CC) |> !cxx |> {obj}
: foreach *.cc |> !cxx |> {obj}
: {obj} |> !ar |> | $(REP_DIR)/<base-common>
: {obj} |> !ar |> base-linux-common.lib.a | $(REP_DIR)/<base-common>

16
repos/base-linux/src/lib/ld/Tupfile

@ -32,21 +32,23 @@ LDFLAGS += -T$(REP_DIR)/src/ld/stack_area.ld
LDFLAGS += -T$(BASE_DIR)/src/ld/genode_rel.ld
LDFLAGS += --entry=_start_initial_stack
BASE_LIBS += \
$(REP_DIR)/src/lib/base/base-linux.lib.a \
BASE_PKGS += alarm cxx ldso-startup startup timeout
LDFLAGS += -L$(DEV_LIB_DIR) `$(PKG_CONFIG) --static --libs $(BASE_PKGS)`
BASE_LIBS += $(REP_DIR)/src/lib/base/base-linux.lib.a
: $(BASE_LIBS) {obj} | \
symbol.map \
$(DEV_DIR)/<lib> \
$(DEV_DIR)/<pkg-config> \
$(BASE_DIR)/<alarm> \
$(REP_DIR)/<base-common> \
$(BASE_DIR)/<cxx> \
$(BASE_DIR)/<ldso-startup> \
$(REP_DIR)/<startup> \
$(REP_DIR)/<syscall> \
$(BASE_DIR)/<timeout> \
|> \
$(LD) $(LDFLAGS) %<base-common> %<syscall> %f -o %o; \
$(LD) -o %o $(LD_MARCH) $(LDFLAGS) --whole-archive --start-group \
%<alarm> %<base-common> %<cxx> %<ldso-startup> %<startup> %<syscall> %<timeout> \
%f --end-group --no-whole-archive $(LIBGCC); \
printf "\x02" | dd of=%o bs=1 seek=16 count=1 conv=notrunc; \
|> ld-linux.lib.so $(REP_DIR)/<ld> {bin}

2
repos/base-linux/src/lib/syscall/Tupfile

@ -19,4 +19,4 @@ ifeq ($(SPEC_DIR),)
endif
: foreach $(SPEC_DIR)/*.S |> !asm |> {obj}
: {obj} |> !ar |> | $(REP_DIR)/<syscall>
: {obj} |> !ar |> syscall-linux.lib.a | $(REP_DIR)/<syscall>

4
repos/base-nova/Tuprules.tup

@ -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

7
repos/base-nova/src/core/Tupfile

@ -45,15 +45,14 @@ CXXFLAGS_$(GEN_CORE_DIR)/version.cc += -DGENODE_VERSION=\"`git describe`\"
: foreach $(SRC_CC) |> !cxx |> {obj}
LDFLAGS += -L$(DEV_LIB_DIR) `$(PKG_CONFIG) --libs cxx-baremetal`
: {obj} | \
$(DEV_DIR)/<lib> \
$(DEV_DIR)/<pkg-config> \
$(BASE_DIR)/<base-libs> \
$(REP_DIR)/<startup> \
$(REP_DIR)/<base-common> \
$(BASE_DIR)/<cxx> \
$(REP_DIR)/<startup> \
|> $(LD) $(LDFLAGS) -u _start -r \
%<base-libs> %<base-common> %<startup> %f -o %o \
--whole-archive --start-group %f %<base-libs> %<base-common> %<cxx> %<startup> --no-whole-archive --end-group -o %o \
|> core.o $(REP_DIR)/<core> {core}
: {core} |> cp %f %o |> $(OUT_DIR)/lib/core-nova.o

13
repos/base/Tupfile

@ -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)|"

23
repos/base/Tuprules.tup

@ -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 \
@ -44,5 +24,4 @@ GCC_INCLUDE = -I`$(CC) -print-file-name=include`
-c %f -o %o \
|> %B.o
!ld = |> ^ MERGE %o^ $(LD) \
$(LDFLAGS) --whole-archive --start-group %f --end-group --no-whole-archive -o %o |>
!ld = |> ^ MERGE %o^ $(LD) -o %o $(LDFLAGS) %f |>

2
repos/base/genode-base.pc.in

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

2
repos/base/src/lib/alarm/Tupfile

@ -1,5 +1,5 @@
include_rules
: foreach *.cc |> !cxx |> {obj}
: {obj} |> !ar |> {bin}
: {obj} |> !ar |> | $(BASE_DIR)/<alarm> {bin}
: foreach {bin} |> !collect_static |>
: |> !emit_lib_pkg_config |>

90
repos/base/src/lib/cxx/Tupfile

@ -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'
#
@ -75,33 +52,76 @@ LOCAL_SYMBOLS = \
#
# Symbols we wrap (see unwind.c)
#
EH_SYMBOLS = \
_Unwind_Complete \
_Unwind_DeleteException \
EH_SYMBOLS += _Unwind_Complete
EH_SYMBOLS += _Unwind_DeleteException
EH_SYMBOLS += _Unwind_Resume
#
# Additional functions for ARM
#
EH_SYMBOLS += \
__aeabi_unwind_cpp_pr0 \
__aeabi_unwind_cpp_pr1 \
EH_SYMBOLS += __aeabi_unwind_cpp_pr0
EH_SYMBOLS += __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
: foreach *.cc |> !cxx |> {obj}
REDEF_SYMBOLS = `echo $(EH_SYMBOLS) | awk -v RS=' ' '{ print "--redefine-sym "$1"=_cxx_"$1 }'`
: foreach *.c |> !cc |>
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++-baremetal.tmp |> $OBJCOPY $(LOCAL_SYMBOLS) $(REDEF_SYMBOLS) %f %o |> supc++-baremetal.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`
: {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 unwind.o |> !ar |> | $(BASE_DIR)/<cxx> {bin}
: foreach {bin} |> !collect_static |>
: |> !emit_lib_pkg_config |>
endif

20
repos/base/src/lib/ld/Tupfile

@ -1,3 +1,21 @@
include_rules
: $(REP_DIR)/lib/symbols/ld |> !abi_stub |>
SED_EXPR += -e "s/^\(\w\+\) D \(\w\+\)\$/.data; .global \1; .type \1,%object; .size \1,\2; \1: .skip 1/"
SED_EXPR += -e "s/^\(\w\+\) V/.data; .weak \1; .type \1,%object; \1: .skip 1/"
SED_EXPR += -e "s/^\(\w\+\) T/.text; .global \1; .type \1,%function; \1:/"
SED_EXPR += -e "s/^\(\w\+\) R \(\w\+\)\$/.section .rodata; .global \1; .type \1,%object; .size \1,\2; \1:/"
SED_EXPR += -e "s/^\(\w\+\) W/.text; .weak \1; .type \1,%function; \1:/"
SED_EXPR += -e "s/^\(\w\+\) B \(\w\+\)\$/.bss; .global \1; .type \1,%object; .size \1,\2; \1:/"
SED_EXPR += -e "s/^\(\w\+\) U/.text; .global \1; movq \1@GOTPCREL(%rip), %rax/"
: |> sed $(SED_EXPR) < $(REP_DIR)/lib/symbols/%d > %o |> %d.symbols.s {asm}
: foreach {asm} |> !cc |> %d.symbols.o {obj}
LDFLAGS += -shared --eh-frame-hdr
LDFLAGS += -z max-page-size=0x1000
LDFLAGS += -T$(BASE_DIR)/src/lib/ldso/linker.ld
LDFLAGS += -T$(BASE_DIR)/src/ld/genode_rel.ld
: {obj} |> !ld |> $(DEV_LIB_DIR)/%d.lib.so $(DEV_DIR)/<lib>
: foreach *.pc.in |> !sed_pkgconfig_file |>

2
repos/base/src/lib/ldso-startup/Tupfile

@ -2,6 +2,6 @@ LIBS += base
include_rules
: foreach startup.cc |> !cxx |> %B.o {obj}
: {obj} | |> !ar |> {bin}
: {obj} |> !ar |> | $(BASE_DIR)/<ldso-startup> {bin}
: foreach {bin} |> !collect_static |>
: |> !emit_lib_pkg_config |>

2
repos/base/src/lib/timeout/Tupfile

@ -14,6 +14,6 @@ else
endif
: foreach $(SRC_CC) |> !cxx |> {obj}
: {obj} |> !ar |> {bin}
: {obj} |> !ar |> | $(BASE_DIR)/<timeout> {bin}
: foreach {bin} |> !collect_static |>
: |> !emit_lib_pkg_config |>

6
repos/gems/Tuprules.tup

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

1
repos/gems/src/lib/vfs/Tuprules.tup

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

5
repos/gems/src/lib/vfs/audit/Tupfile

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

5
repos/gems/src/lib/vfs/trace/Tupfile

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

17
repos/os/Tupfile

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

2
repos/os/Tuprules.tup

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

4
repos/os/genode-os.pc.in

@ -1,8 +1,10 @@
includedir=@includedir@
libdir=@libdir@
Name: os
Description: Genode os repository
URL: https://genode.org/
Version: @VERSION@
Requires: genode-base
Cflags: -I${includedir}
Cflags: @includes@
Libs: -L${libdir}

2
repos/os/src/lib/net/Tupfile

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

2
repos/os/src/lib/vfs/Tupfile

@ -1,5 +1,7 @@
include_rules
LIBS += ldso-startup
: $(REP_DIR)/lib/symbols/vfs |> !abi_stub |>
: vfs.pc.in |> !sed_pkgconfig_file |>

1
repos/os/src/lib/vfs/vfs.pc.in

@ -1,4 +1,5 @@
Name: VFS
Description: Genode Virtual File-System library
Version: @VERSION@
Requires: genode-os
Libs: -l:vfs.lib.so

7
setup-hooks.sh

@ -1,7 +0,0 @@
addGenodePkgConfigPath () {
if test -e "$1/.genode" && test -d "$1/lib/pkgconfig"; then
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$1/lib/pkgconfig"
fi
}
addEnvHooks "$targetOffset" addGenodePkgConfigPath

75
toolchain.nix

@ -0,0 +1,75 @@
# 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"));
preferLocalBuild = true;
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 $out/bin/genode-aarch64-*; do
makeWrapper ''${BIN} aarch64-unknown-genode-''${BIN#$out/bin/genode-aarch64-}
done
for BIN in $out/bin/genode-arm-*; do
makeWrapper ''${BIN} arm-unknown-genode-''${BIN#$out/bin/genode-arm-}
done
for BIN in $out/bin/genode-riscv-*; do
makeWrapper ''${BIN} riscv-unknown-genode-''${BIN#$out/bin/genode-riscv-}
done
for BIN in $out/bin/genode-x86-*; do
makeWrapper ''${BIN} i686-unknown-genode-''${BIN#$out/bin/genode-x86-}
makeWrapper ''${BIN} x86_64-unknown-genode-''${BIN#$out/bin/genode-x86-}
done
popd
'';
} // {
isGNU = true;
targetPrefix = "genode-x86-";
};
wrapped = wrapCC cc;
wrapped' = wrapped.overrideAttrs (attrs: { inherit (cc) targetPrefix; });
in wrapped'

47
tup-genode/gcc.tup

@ -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 = `$(CXX) $(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) -o %o $(LDFLAGS) `$(PKG_CONFIG) --libs $(LIBS)` %f |>
!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

40
tup-genode/llvm.tup

@ -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

8
update-tup.sh

@ -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