Update to Nixpkgs-21.11
- gdb patch is upstream, remove - fix patchelf with empty rpaths - update to latest ERIS Nim implementation
This commit is contained in:
parent
ae591f0faf
commit
f5108bc99b
91
flake.lock
91
flake.lock
|
@ -1,15 +1,51 @@
|
|||
{
|
||||
"nodes": {
|
||||
"eris": {
|
||||
"inputs": {
|
||||
"nimble": "nimble",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1652741572,
|
||||
"narHash": "sha256-c+8/yxYckS2PrA7SoEmEr6dqDwzQnw1Hz2LhJBDN4DA=",
|
||||
"ref": "master",
|
||||
"rev": "27bd39452ec548744e14a3169e85602340125851",
|
||||
"revCount": 10,
|
||||
"type": "git",
|
||||
"url": "https://codeberg.org/eris/nix-eris"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://codeberg.org/eris/nix-eris"
|
||||
}
|
||||
},
|
||||
"nimble": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1617699750,
|
||||
"narHash": "sha256-jVsaLrPxppRW40hob3OR1tspdWcWXRwvu2mGVGqH/2Y=",
|
||||
"lastModified": 1652579357,
|
||||
"narHash": "sha256-hy50WWc872o177Ok4GQoMOi3La2DlzJyEboOD4iGE8Q=",
|
||||
"owner": "nix-community",
|
||||
"repo": "flake-nimble",
|
||||
"rev": "5d7a9c0d28472ad2ded4c3c335b8d3b1f6a65e6d",
|
||||
"rev": "a48df7c801b1da371492f5689dfbd5f6a128a6c2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nimble",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nimble_2": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1652924471,
|
||||
"narHash": "sha256-8lxEUhy5XXLaMy8J8eWwiufHUZpTnrI4ykS5lekPq3Y=",
|
||||
"owner": "nix-community",
|
||||
"repo": "flake-nimble",
|
||||
"rev": "c3993134d3d8e6a601311fb662b2698b26b43575",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -19,11 +55,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1607766819,
|
||||
"narHash": "sha256-bluEp6ld6wmpeLl5MQPQOpxWMDLnUYyQNEk2rMlAyiU=",
|
||||
"owner": "NixOS",
|
||||
"lastModified": 1641555862,
|
||||
"narHash": "sha256-AJK1Q5djPXs/ba3K6gHsVAer9yDPVLic78ZIDsFSkHU=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f448ec33655c48d7306456bee77f3cdabf3757fa",
|
||||
"rev": "d1acd89e0116ff88eba80541027429fc922612e9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -33,24 +69,53 @@
|
|||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1651431785,
|
||||
"narHash": "sha256-aOsD+YWXNBnnafsSWRnJ8+Lt3Y0YMxh7YiX/ncd20Q4=",
|
||||
"lastModified": 1652692103,
|
||||
"narHash": "sha256-ygRLh8g0F/WkVCSfQcxMoVaaD45i6Ky+f+b4wCOazag=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "556ce9a40abde33738e6c9eac65f965a8be3b623",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1641555862,
|
||||
"narHash": "sha256-AJK1Q5djPXs/ba3K6gHsVAer9yDPVLic78ZIDsFSkHU=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d1acd89e0116ff88eba80541027429fc922612e9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_4": {
|
||||
"locked": {
|
||||
"lastModified": 1653521725,
|
||||
"narHash": "sha256-JO3Ni/gV4+7eloZrXW0hY7PNfy5TGVJWOPEhtnV9ugQ=",
|
||||
"owner": "ehmry",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a6111a84ed26be4f87adf1821fb1c37b385252cd",
|
||||
"rev": "2ec153670397dd3393e6b79d3057c0279539eb10",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ehmry",
|
||||
"ref": "sigil-21",
|
||||
"ref": "sigil-21.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nimble": "nimble",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"eris": "eris",
|
||||
"nimble": "nimble_2",
|
||||
"nixpkgs": "nixpkgs_4"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
13
flake.nix
13
flake.nix
|
@ -1,9 +1,12 @@
|
|||
{
|
||||
description = "Nix flavored Genode distribution";
|
||||
|
||||
inputs.nixpkgs.url = "github:ehmry/nixpkgs/sigil-21";
|
||||
inputs = {
|
||||
eris.url = "git+https://codeberg.org/eris/nix-eris";
|
||||
nixpkgs.url = "github:ehmry/nixpkgs/sigil-21.11";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, nimble }:
|
||||
outputs = { self, eris, nixpkgs, nimble }:
|
||||
let
|
||||
systems = {
|
||||
localSystem = [ "x86_64-linux" ]; # build platforms
|
||||
|
@ -44,6 +47,8 @@
|
|||
crossSystem = system;
|
||||
}));
|
||||
|
||||
overlays = [ nimble.overlay eris.overlays.default self.overlay ];
|
||||
|
||||
in rec {
|
||||
|
||||
overlay =
|
||||
|
@ -197,7 +202,7 @@
|
|||
let f = import nixpkgs;
|
||||
in forAllSystems ({ system, localSystem, crossSystem }:
|
||||
if localSystem == crossSystem then
|
||||
nixpkgs.legacyPackages.${system}.extend self.overlay
|
||||
nixpkgs.legacyPackages.${system}.appendOverlays overlays
|
||||
else
|
||||
f {
|
||||
inherit localSystem;
|
||||
|
@ -206,7 +211,7 @@
|
|||
useLLVM = true;
|
||||
};
|
||||
config.allowUnsupportedSystem = true;
|
||||
overlays = [ self.overlay ];
|
||||
inherit overlays;
|
||||
});
|
||||
|
||||
packages =
|
||||
|
|
|
@ -81,20 +81,17 @@ in nullPkgs // {
|
|||
# keep libposix NEEDED
|
||||
}) prev.coreutils);
|
||||
|
||||
erisPatchHook = final.callPackage ./eris-patch-hook {
|
||||
patchelf = prev.patchelf.overrideAttrs (attrs: {
|
||||
patches = attrs.patched or [ ] ++ [
|
||||
./patchelf/dynstr.patch
|
||||
./patchelf/shiftFile.patch
|
||||
./patchelf/disable-assert.patch
|
||||
];
|
||||
});
|
||||
};
|
||||
|
||||
gdb = addPatchesTarget [
|
||||
./gdb/genode.patch
|
||||
# Upstreamed, remove at next release.
|
||||
] prev.gdb;
|
||||
erisPatchHook =
|
||||
final.buildPackages.nimPackages.callPackage ./eris-patch-hook {
|
||||
patchelf = prev.patchelf.overrideAttrs (attrs: {
|
||||
patches = attrs.patches or [ ] ++ [
|
||||
./patchelf/dynstr.patch
|
||||
./patchelf/shiftFile.patch
|
||||
./patchelf/disable-assert.patch
|
||||
./patchelf/rpath.patch
|
||||
];
|
||||
});
|
||||
};
|
||||
|
||||
genodeLibcCross = callPackage ./libc { };
|
||||
|
||||
|
@ -111,11 +108,11 @@ in nullPkgs // {
|
|||
|
||||
libcCrossChooser = name:
|
||||
if stdenv.targetPlatform.isGenode then
|
||||
targetPackages.genodeLibcCross
|
||||
final.genodeLibcCross
|
||||
else
|
||||
prev.libcCrossChooser name;
|
||||
|
||||
libsodium = overrideAttrsHost (attrs: {
|
||||
libsodium = overrideAttrsHost (_: {
|
||||
patches = (attrs.patches or [ ]) ++ [
|
||||
./libsodium/genode.patch
|
||||
# https://github.com/jedisct1/libsodium/pull/1006
|
||||
|
@ -129,9 +126,9 @@ in nullPkgs // {
|
|||
libtool =
|
||||
# Autotools related nonesense. Better to compile
|
||||
# everything static than to deal with this one.
|
||||
overrideAttrsTarget (attrs: {
|
||||
overrideAttrsTarget ({ nativeBuildInputs, ... }: {
|
||||
nativeBuildInputs = with final;
|
||||
attrs.nativeBuildInputs ++ [ autoconf automake115x ];
|
||||
nativeBuildInputs ++ [ autoconf automake115x ];
|
||||
patches = ./libtool/genode.patch;
|
||||
}) prev.libtool;
|
||||
|
||||
|
@ -160,27 +157,18 @@ in nullPkgs // {
|
|||
else
|
||||
prev.llvmPackages;
|
||||
|
||||
llvmPackages_11 = if targetPlatform.isGenode then
|
||||
(import ./llvm-11/override.nix { inherit final prev; })
|
||||
else
|
||||
prev.llvmPackages_11;
|
||||
llvmPackages_11 = (import ./llvm-11/override.nix { inherit final prev; });
|
||||
|
||||
ncurses =
|
||||
# https://invisible-island.net/autoconf/
|
||||
# Stay clear of upstream on this one.
|
||||
addPatchesHost [ ./ncurses/genode.patch ] prev.ncurses;
|
||||
|
||||
nim-unwrapped =
|
||||
# Fixes to the compiler and standard libary.
|
||||
prev.nim-unwrapped.overrideAttrs
|
||||
(attrs: { patches = attrs.patches ++ [ ./nim/genode.patch ]; });
|
||||
|
||||
nimblePackages =
|
||||
nimPackages =
|
||||
# Packages from the Nimble flake with adjustments.
|
||||
let pkgs' = flake.inputs.nimble.overlay (final // pkgs') final;
|
||||
in pkgs'.nimblePackages.extend (_: prev: {
|
||||
prev.nimPackages.overrideScope' (_: prev': {
|
||||
|
||||
genode = prev.genode.overrideAttrs (attrs: rec {
|
||||
genode = prev'.genode.overrideAttrs (attrs: rec {
|
||||
version = "20.11.1";
|
||||
src = fetchgit {
|
||||
inherit (attrs.src) url;
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
{ lib, stdenv, patchelf, nimblePackages }:
|
||||
{ buildNimPackage, patchelf, base32, eris }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
buildNimPackage {
|
||||
name = "eris_patch";
|
||||
nativeBuildInputs = with nimblePackages; [ nim ];
|
||||
buildInputs = with nimblePackages; [ eris ];
|
||||
buildInputs = [ base32 eris ];
|
||||
inherit patchelf;
|
||||
dontUnpack = true;
|
||||
nimFlags = [ "-d:release" ];
|
||||
buildPhase = ''
|
||||
HOME=$TMPDIR
|
||||
cp ${./eris_patch.nim} eris_patch.nim
|
||||
nim c $nimFlags eris_patch
|
||||
unpackPhase = "install -D ${./eris_patch.nim} ./src/eris_patch.nim";
|
||||
preConfigure = ''
|
||||
cat << EOF > eris_patch.nimble
|
||||
bin = @[ "src/eris_patch"]
|
||||
EOF
|
||||
'';
|
||||
installPhase = "install -Dt $out/bin eris_patch";
|
||||
setupHook = ./eris_patch.sh;
|
||||
}
|
||||
|
|
|
@ -10,13 +10,10 @@ let
|
|||
nixStore = getEnv("NIX_STORE", "/nix/store")
|
||||
manifestSubPath = "nix-support" / "eris-manifest.json"
|
||||
|
||||
const erisBlockSize = 32 shl 10
|
||||
# fix the block size for now
|
||||
|
||||
proc isElf(path: string): bool =
|
||||
var magic: array[4, char]
|
||||
let file = open(path)
|
||||
discard readChars(file, magic, 0, 4)
|
||||
discard readChars(file, magic)
|
||||
close(file)
|
||||
magic == [0x7f.char, 'E', 'L', 'F']
|
||||
|
||||
|
@ -68,17 +65,20 @@ proc resolveFile(outputRoot, filePath: string): PendingFile =
|
|||
if need == "ld.lib.so" or need.startsWith("urn:"): continue
|
||||
result.replacements[need] = resolveNeed(rpath, need)
|
||||
|
||||
var capCache = initTable[string, Cap]()
|
||||
var capCache = initTable[string, ErisCap]()
|
||||
|
||||
proc fileUrn(filePath: string; blockSize: Natural): string =
|
||||
proc fileUrn(filePath: string): string =
|
||||
## Determine the ERIS URN for ``filePath``.
|
||||
var cap: Cap
|
||||
var cap: ErisCap
|
||||
if capCache.hasKey(filePath):
|
||||
cap = capCache[filePath]
|
||||
else:
|
||||
try:
|
||||
let str = newFileStream(filePath)
|
||||
doAssert(not str.isNil) # yes, that happens
|
||||
let blockSize = if getFileSize(filePath) < (16 shl 10):
|
||||
bs1k
|
||||
else:
|
||||
bs32k
|
||||
let str = openFileStream(filePath)
|
||||
cap = waitFor encode(newDiscardStore(), blockSize, str)
|
||||
capCache["filePath"] = cap
|
||||
close(str)
|
||||
|
@ -157,22 +157,19 @@ while pendingFiles.len != 0:
|
|||
replaceCmd = patchelf & " --set-rpath '' " & filePath
|
||||
for need, replacementPath in pendingFile.replacements.pairs:
|
||||
if replacementPath == "": continue
|
||||
let urn = fileUrn(replacementPath, erisBlockSize)
|
||||
let urn = fileUrn(replacementPath)
|
||||
echo "replace reference to ", need, " with ", urn
|
||||
replaceCmd.add(" --replace-needed $# $#" % [need, urn])
|
||||
closure[replacementPath] = %urn
|
||||
for path, urn in fileClosure(replacementPath).pairs:
|
||||
closure[path] = %urn
|
||||
if pendingFile.replacements.len != 0:
|
||||
replaceCmd.add(" 2>&1")
|
||||
let (msg, exitCode) = execCmdEx(replaceCmd, options = {poUsePath})
|
||||
let exitCode = execCmd(replaceCmd)
|
||||
if exitCode != 0:
|
||||
echo "Patchelf failed"
|
||||
echo replaceCmd
|
||||
echo msg
|
||||
echo "Patchelf failed - ", replaceCmd
|
||||
quit exitCode
|
||||
outputManifests[pendingFile.outputRoot][filePath] = %* {
|
||||
"cap": fileUrn(filePath, erisBlockSize),
|
||||
"cap": fileUrn(filePath),
|
||||
"closure": closure,
|
||||
}
|
||||
if pendingFiles.len == prevPrevLen:
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
diff -ur a/bfd/config.bfd b/bfd/config.bfd
|
||||
--- a/bfd/config.bfd 2020-10-24 06:23:01.000000000 +0200
|
||||
+++ b/bfd/config.bfd 2020-12-03 16:05:35.739694255 +0100
|
||||
@@ -231,7 +231,7 @@
|
||||
targ_archs="$targ_archs bfd_i386_arch bfd_powerpc_arch bfd_rs6000_arch"
|
||||
want64=true
|
||||
;;
|
||||
- aarch64-*-elf | aarch64-*-rtems*)
|
||||
+ aarch64-*-elf | aarch64-*-rtems* | aarch64-*-genode*)
|
||||
targ_defvec=aarch64_elf64_le_vec
|
||||
targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec"
|
||||
want64=true
|
||||
@@ -655,7 +655,7 @@
|
||||
targ_selvecs="i386_elf32_vec iamcu_elf32_vec l1om_elf64_vec k1om_elf64_vec"
|
||||
want64=true
|
||||
;;
|
||||
- x86_64-*-elf* | x86_64-*-rtems* | x86_64-*-fuchsia)
|
||||
+ x86_64-*-elf* | x86_64-*-rtems* | x86_64-*-fuchsia | x86_64-*-genode*)
|
||||
targ_defvec=x86_64_elf64_vec
|
||||
targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec l1om_elf64_vec k1om_elf64_vec"
|
||||
case "${targ}" in
|
||||
diff -ur a/config.sub b/config.sub
|
||||
--- a/config.sub 2020-09-13 04:33:40.000000000 +0200
|
||||
+++ b/config.sub 2020-12-03 16:07:07.347015686 +0100
|
||||
@@ -1366,7 +1366,7 @@
|
||||
| skyos* | haiku* | rdos* | toppers* | drops* | es* \
|
||||
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
|
||||
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
|
||||
- | nsk* | powerunix)
|
||||
+ | nsk* | powerunix | genode*)
|
||||
# Remember, each alternative MUST END IN *, to match a version number.
|
||||
;;
|
||||
qnx*)
|
|
@ -19,11 +19,11 @@ let
|
|||
|
||||
tools = prev.llvmPackages_11.tools.extend (final': prev': {
|
||||
|
||||
llvm = addPatches [ ./llvm-genode.patch ] prev'.llvm;
|
||||
libllvm = addPatches [ ./llvm-genode.patch ] prev'.libllvm;
|
||||
|
||||
lld = addPatches [ ./lld-genode.patch ] prev'.lld;
|
||||
|
||||
clang-unwrapped = prev'.clang-unwrapped.overrideAttrs
|
||||
libclang = prev'.libclang.overrideAttrs
|
||||
({ patches ? [ ], postPatch, ... }: {
|
||||
patches = patches ++ [ ./clang-genode.patch ];
|
||||
postPatch = postPatch + ''
|
||||
|
@ -31,27 +31,44 @@ let
|
|||
'';
|
||||
});
|
||||
|
||||
lldClang = prev'.lldClang.override
|
||||
(with final.genodePackages; {
|
||||
gccForLibs = genodeSources.toolchain.cc;
|
||||
nixSupport = {
|
||||
cc-cflags = [
|
||||
"--gcc-toolchain=${genodeSources.toolchain.cc}"
|
||||
"--sysroot=${genodeSources.genodeBase}"
|
||||
"-I${genodeSources.genodeBase}/include"
|
||||
"-L${genodeSources.genodeBase}"
|
||||
];
|
||||
libcxx-ldflags = [ "${stdcxx}/lib/stdcxx.lib.so" ];
|
||||
};
|
||||
});
|
||||
clangUseLLVM = let inherit (final.genodePackages) genodeSources;
|
||||
in (prev'.clangNoLibcxx.override {
|
||||
gccForLibs = genodeSources.toolchain.cc;
|
||||
nixSupport = {
|
||||
cc-cflags = [
|
||||
"--gcc-toolchain=${genodeSources.toolchain.cc}"
|
||||
"--sysroot=${genodeSources.genodeBase}"
|
||||
"-I${genodeSources.genodeBase}/include"
|
||||
"-L${genodeSources.genodeBase}"
|
||||
];
|
||||
libcxx-ldflags = [ "${final.genodePackages.stdcxx}/lib/stdcxx.lib.so" ];
|
||||
};
|
||||
}).overrideAttrs ({ postFixup, ... }: {
|
||||
postFixup = postFixup + (with final; ''
|
||||
|
||||
lldClangNoLibcxx = prev'.lldClangNoLibcxx.override
|
||||
(with final.genodePackages; {
|
||||
nixSupport = {
|
||||
cc-cflags = [ "--sysroot=${genodeSources.genodeBase}" ];
|
||||
cc-ldflags = [ "-L${genodeSources.genodeBase}" ];
|
||||
};
|
||||
});
|
||||
for dir in ${genodeSources.toolchain.cc}/${stdenv.targetPlatform.config}/include/c++/*; do
|
||||
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
|
||||
done
|
||||
echo "-isystem ${genodeSources}/repos/libports/include/stdcxx" >> $out/nix-support/libcxx-cxxflags
|
||||
for dir in ${genodeSources.ports.stdcxx}/*/include/stdcxx; do
|
||||
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
|
||||
echo "-isystem $dir/std" >> $out/nix-support/libcxx-cxxflags
|
||||
echo "-isystem $dir/c_global" >> $out/nix-support/libcxx-cxxflags
|
||||
done
|
||||
echo "${genodePackages.stdcxx}/lib/stdcxx.lib.so" >> $out/nix-support/libcxx-ldflags
|
||||
'');
|
||||
});
|
||||
|
||||
clangNoLibcxx = prev'.clangNoLibcxx.override (with final.genodePackages; {
|
||||
nixSupport = {
|
||||
cc-cflags = [
|
||||
"--gcc-toolchain=${genodeSources.toolchain.cc}"
|
||||
"--sysroot=${genodeSources.genodeBase}"
|
||||
"-I${genodeSources.genodeBase}/include"
|
||||
];
|
||||
cc-ldflags = [ "-L${genodeSources.genodeBase}" ];
|
||||
};
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -1,344 +0,0 @@
|
|||
From 3a857e39ff3c9c8e7883c6f8189ccd0278c8484e Mon Sep 17 00:00:00 2001
|
||||
From: Emery Hemingway <ehmry@posteo.net>
|
||||
Date: Sat, 8 Feb 2020 14:32:18 +0100
|
||||
Subject: [PATCH 1/6] Genode: move dyncall failures to runtime
|
||||
|
||||
Do not use the "error" pragma to warn that dynamic library loading is
|
||||
not implemented, print a message at runtime and exit.
|
||||
---
|
||||
lib/pure/dynlib.nim | 26 ++++++++++++++++++++++++++
|
||||
lib/system/dyncalls.nim | 15 +++++++++------
|
||||
2 files changed, 35 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/lib/pure/dynlib.nim b/lib/pure/dynlib.nim
|
||||
index 42d13535f..d8934b0f0 100644
|
||||
--- a/lib/pure/dynlib.nim
|
||||
+++ b/lib/pure/dynlib.nim
|
||||
@@ -150,6 +150,32 @@ elif defined(nintendoswitch):
|
||||
proc symAddr(lib: LibHandle, name: cstring): pointer =
|
||||
raise newException(OSError, "symAddr not implemented on Nintendo Switch!")
|
||||
|
||||
+elif defined(genode):
|
||||
+ #
|
||||
+ # =========================================================================
|
||||
+ # Not implemented for Genode without POSIX. Raise an error if called.
|
||||
+ # =========================================================================
|
||||
+ #
|
||||
+
|
||||
+ template raiseErr(prc: string) =
|
||||
+ raise newException(OSError, prc & " not implemented, compile with POSIX suport")
|
||||
+
|
||||
+ proc dlclose(lib: LibHandle) =
|
||||
+ raiseErr(OSError, "dlclose")
|
||||
+ proc dlopen(path: cstring, mode: int): LibHandle =
|
||||
+ raiseErr(OSError, "dlopen")
|
||||
+ proc dlsym(lib: LibHandle, name: cstring): pointer =
|
||||
+ raiseErr(OSError, "dlsym")
|
||||
+ proc loadLib(path: string, global_symbols = false): LibHandle =
|
||||
+ raiseErr(OSError, "loadLib")
|
||||
+ proc loadLib(): LibHandle =
|
||||
+ raiseErr(OSError, "loadLib")
|
||||
+ proc unloadLib(lib: LibHandle) =
|
||||
+ raiseErr(OSError, "unloadLib")
|
||||
+ proc symAddr(lib: LibHandle, name: cstring): pointer =
|
||||
+ raiseErr(OSError, "symAddr")
|
||||
+
|
||||
+
|
||||
elif defined(windows) or defined(dos):
|
||||
#
|
||||
# =======================================================================
|
||||
diff --git a/lib/system/dyncalls.nim b/lib/system/dyncalls.nim
|
||||
index 1b0a3e64c..d1c6c2bd3 100644
|
||||
--- a/lib/system/dyncalls.nim
|
||||
+++ b/lib/system/dyncalls.nim
|
||||
@@ -170,14 +170,17 @@ elif defined(windows) or defined(dos):
|
||||
|
||||
elif defined(genode):
|
||||
|
||||
- proc nimUnloadLibrary(lib: LibHandle) {.
|
||||
- error: "nimUnloadLibrary not implemented".}
|
||||
+ proc nimUnloadLibrary(lib: LibHandle) =
|
||||
+ writeToStdErr("nimUnloadLibrary not implemented")
|
||||
+ quit(1)
|
||||
|
||||
- proc nimLoadLibrary(path: string): LibHandle {.
|
||||
- error: "nimLoadLibrary not implemented".}
|
||||
+ proc nimLoadLibrary(path: string): LibHandle =
|
||||
+ writeToStdErr("nimLoadLibrary not implemented")
|
||||
+ quit(1)
|
||||
|
||||
- proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr {.
|
||||
- error: "nimGetProcAddr not implemented".}
|
||||
+ proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr =
|
||||
+ writeToStdErr("nimGetProcAddr not implemented")
|
||||
+ quit(1)
|
||||
|
||||
elif defined(nintendoswitch) or defined(freertos):
|
||||
proc nimUnloadLibrary(lib: LibHandle) =
|
||||
--
|
||||
2.30.1
|
||||
|
||||
|
||||
From 70563e3a3d5357020c6e86db890b8f91026f7e6b Mon Sep 17 00:00:00 2001
|
||||
From: Emery Hemingway <ehmry@posteo.net>
|
||||
Date: Tue, 15 Oct 2019 10:19:27 +0200
|
||||
Subject: [PATCH 2/6] Genode: use stricter dataspace type in page allocator
|
||||
|
||||
---
|
||||
lib/genode/alloc.nim | 14 +++++++-------
|
||||
1 file changed, 7 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/lib/genode/alloc.nim b/lib/genode/alloc.nim
|
||||
index a21a3ad7b..3ddd3074b 100644
|
||||
--- a/lib/genode/alloc.nim
|
||||
+++ b/lib/genode/alloc.nim
|
||||
@@ -17,18 +17,18 @@ when not defined(genode):
|
||||
when not declared(GenodeEnv):
|
||||
include genode/env
|
||||
|
||||
-type DataspaceCapability {.
|
||||
- importcpp: "Genode::Dataspace_capability", pure.} = object
|
||||
+type RamDataspaceCapability {.
|
||||
+ importcpp: "Genode::Ram_dataspace_capability", pure.} = object
|
||||
|
||||
type
|
||||
Map = object
|
||||
attachment: pointer
|
||||
size: int
|
||||
- ds: DataspaceCapability
|
||||
+ ds: RamDataspaceCapability
|
||||
|
||||
SlabMeta = object
|
||||
next: ptr MapSlab
|
||||
- ds: DataspaceCapability
|
||||
+ ds: RamDataspaceCapability
|
||||
|
||||
MapSlab = object
|
||||
meta: SlabMeta
|
||||
@@ -45,11 +45,11 @@ proc capsAvail(env: GenodeEnv): int {.
|
||||
## Return the number of available capabilities.
|
||||
## Each dataspace allocation consumes a capability.
|
||||
|
||||
-proc allocDataspace(env: GenodeEnv; size: int): DataspaceCapability {.
|
||||
+proc allocDataspace(env: GenodeEnv; size: int): RamDataspaceCapability {.
|
||||
importcpp: "#->pd().alloc(@)".}
|
||||
## Allocate a dataspace and its capability.
|
||||
|
||||
-proc attachDataspace(env: GenodeEnv; ds: DataspaceCapability): pointer {.
|
||||
+proc attachDataspace(env: GenodeEnv; ds: RamDataspaceCapability): pointer {.
|
||||
importcpp: "#->rm().attach(@)".}
|
||||
## Attach a dataspace into the component address-space.
|
||||
|
||||
@@ -57,7 +57,7 @@ proc detachAddress(env: GenodeEnv; p: pointer) {.
|
||||
importcpp: "#->rm().detach(@)".}
|
||||
## Detach a dataspace from the component address-space.
|
||||
|
||||
-proc freeDataspace(env: GenodeEnv; ds: DataspaceCapability) {.
|
||||
+proc freeDataspace(env: GenodeEnv; ds: RamDataspaceCapability) {.
|
||||
importcpp: "#->pd().free(@)".}
|
||||
## Free a dataspace.
|
||||
|
||||
--
|
||||
2.30.1
|
||||
|
||||
|
||||
From e8809265a69c0110db4ded42ef01703118688439 Mon Sep 17 00:00:00 2001
|
||||
From: Emery Hemingway <ehmry@posteo.net>
|
||||
Date: Tue, 7 Apr 2020 10:03:13 +0530
|
||||
Subject: [PATCH 3/6] Genode: remove compiler configuration from nim.cfg
|
||||
|
||||
Self-hosting Nim is not supported on Genode and defining the
|
||||
cross-compilation environment can be done externally.
|
||||
---
|
||||
config/nim.cfg | 25 +------------------------
|
||||
1 file changed, 1 insertion(+), 24 deletions(-)
|
||||
|
||||
diff --git a/config/nim.cfg b/config/nim.cfg
|
||||
index a33a2f0a9..fca38bf8b 100644
|
||||
--- a/config/nim.cfg
|
||||
+++ b/config/nim.cfg
|
||||
@@ -111,7 +111,7 @@ path="$lib/pure"
|
||||
@end
|
||||
|
||||
@if unix:
|
||||
- @if not bsd or haiku:
|
||||
+ @if not (bsd or haiku or genode):
|
||||
# -fopenmp
|
||||
gcc.options.linker = "-ldl"
|
||||
gcc.cpp.options.linker = "-ldl"
|
||||
@@ -295,29 +295,6 @@ vcc.cpp.options.size = "/O1"
|
||||
# Configuration for the Tiny C Compiler:
|
||||
tcc.options.always = "-w"
|
||||
|
||||
-# Configuration for the Genode toolchain
|
||||
-@if genode:
|
||||
- noCppExceptions # avoid std C++
|
||||
- tlsEmulation:on # no TLS segment register magic
|
||||
- @if i386 or amd64:
|
||||
- gcc.exe = "genode-x86-gcc"
|
||||
- gcc.cpp.exe = "genode-x86-g++"
|
||||
- gcc.cpp.linkerexe = "genode-x86-ld"
|
||||
- @elif arm:
|
||||
- gcc.exe = "genode-arm-gcc"
|
||||
- gcc.cpp.exe = "genode-arm-g++"
|
||||
- gcc.cpp.linkerexe = "genode-arm-ld"
|
||||
- @elif arm64:
|
||||
- gcc.exe = "genode-aarch64-gcc"
|
||||
- gcc.cpp.exe = "genode-aarch64-g++"
|
||||
- gcc.cpp.linkerexe = "genode-aarch64-ld"
|
||||
- @elif riscv64:
|
||||
- gcc.exe = "genode-riscv-gcc"
|
||||
- gcc.cpp.exe = "genode-riscv-g++"
|
||||
- gcc.cpp.linkerexe = "genode-riscv-ld"
|
||||
- @end
|
||||
-@end
|
||||
-
|
||||
@if arm or arm64:
|
||||
--define:nimEmulateOverflowChecks
|
||||
@end
|
||||
--
|
||||
2.30.1
|
||||
|
||||
|
||||
From fc3193dd952012284246da027e634bb7a8f31581 Mon Sep 17 00:00:00 2001
|
||||
From: Emery Hemingway <ehmry@posteo.net>
|
||||
Date: Fri, 4 Dec 2020 12:53:51 +0100
|
||||
Subject: [PATCH 4/6] Genode: use new mutex API
|
||||
|
||||
---
|
||||
lib/genode_cpp/syslocks.h | 20 +++++++++-----------
|
||||
1 file changed, 9 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/lib/genode_cpp/syslocks.h b/lib/genode_cpp/syslocks.h
|
||||
index 8ba39abc2..c50180903 100644
|
||||
--- a/lib/genode_cpp/syslocks.h
|
||||
+++ b/lib/genode_cpp/syslocks.h
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/semaphore.h>
|
||||
-#include <base/lock.h>
|
||||
+#include <base/mutex.h>
|
||||
|
||||
namespace Nim {
|
||||
struct SysLock;
|
||||
@@ -22,15 +22,14 @@ namespace Nim {
|
||||
|
||||
struct Nim::SysLock
|
||||
{
|
||||
- Genode::Lock _lock_a, _lock_b;
|
||||
+ Genode::Mutex _mutex_a, _mutex_b;
|
||||
bool _locked;
|
||||
|
||||
void acquireSys()
|
||||
{
|
||||
- _lock_a.lock();
|
||||
+ Genode::Mutex::Guard guard(_mutex_a);
|
||||
_locked = true;
|
||||
- _lock_a.unlock();
|
||||
- _lock_b.lock();
|
||||
+ _mutex_b.acquire();
|
||||
}
|
||||
|
||||
bool tryAcquireSys()
|
||||
@@ -38,23 +37,22 @@ struct Nim::SysLock
|
||||
if (_locked)
|
||||
return false;
|
||||
|
||||
- _lock_a.lock();
|
||||
+ Genode::Mutex::Guard guard(_mutex_a);
|
||||
+
|
||||
if (_locked) {
|
||||
- _lock_a.unlock();
|
||||
return false;
|
||||
} else {
|
||||
_locked = true;
|
||||
- _lock_b.lock();
|
||||
- _lock_a.unlock();
|
||||
+ _mutex_b.acquire();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void releaseSys()
|
||||
{
|
||||
+ Genode::Mutex::Guard guard(_mutex_a);
|
||||
_locked = false;
|
||||
- _lock_a.unlock();
|
||||
- _lock_b.unlock();
|
||||
+ _mutex_b.release();
|
||||
}
|
||||
};
|
||||
|
||||
--
|
||||
2.30.1
|
||||
|
||||
|
||||
From 497b7f6c26813cdf333558241fd7298ccc8c8f2c Mon Sep 17 00:00:00 2001
|
||||
From: Emery Hemingway <ehmry@posteo.net>
|
||||
Date: Mon, 5 Apr 2021 09:21:23 +0200
|
||||
Subject: [PATCH 5/6] Genode: call nim_component_construct as a C procedure
|
||||
|
||||
---
|
||||
compiler/cgen.nim | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
|
||||
index 6bc6ca2d7..b924f9e10 100644
|
||||
--- a/compiler/cgen.nim
|
||||
+++ b/compiler/cgen.nim
|
||||
@@ -1443,7 +1443,7 @@ proc genMainProc(m: BModule) =
|
||||
|
||||
GenodeNimMain =
|
||||
"extern Genode::Env *nim_runtime_env;$N" &
|
||||
- "extern void nim_component_construct(Genode::Env*);$N$N" &
|
||||
+ "extern \"C\" void nim_component_construct(Genode::Env*);$N$N" &
|
||||
NimMainBody
|
||||
|
||||
ComponentConstruct =
|
||||
--
|
||||
2.30.1
|
||||
|
||||
|
||||
From 78e08f16d4af8a8514d01ceda92663f57209e140 Mon Sep 17 00:00:00 2001
|
||||
From: Emery Hemingway <ehmry@posteo.net>
|
||||
Date: Mon, 5 Apr 2021 17:44:31 +0200
|
||||
Subject: [PATCH 6/6] Genode: implement echo for NimStringV2
|
||||
|
||||
---
|
||||
compiler/ccgexprs.nim | 14 ++++++++++----
|
||||
1 file changed, 10 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
|
||||
index 4a469a013..54cfb494c 100644
|
||||
--- a/compiler/ccgexprs.nim
|
||||
+++ b/compiler/ccgexprs.nim
|
||||
@@ -1107,15 +1107,21 @@ proc genEcho(p: BProc, n: PNode) =
|
||||
# echo directly to the Genode LOG session
|
||||
var args: Rope = nil
|
||||
var a: TLoc
|
||||
- for it in n.sons:
|
||||
+ for i, it in n.sons:
|
||||
if it.skipConv.kind == nkNilLit:
|
||||
args.add(", \"\"")
|
||||
- else:
|
||||
+ elif n.len != 0:
|
||||
initLocExpr(p, it, a)
|
||||
- args.add(ropecg(p.module, ", Genode::Cstring($1->data, $1->len)", [rdLoc(a)]))
|
||||
+ if 0 < i:
|
||||
+ args.add(", ")
|
||||
+ case detectStrVersion(p.module)
|
||||
+ of 2:
|
||||
+ args.add(ropecg(p.module, "Genode::Cstring($1.p->data, $1.len)", [a.rdLoc]))
|
||||
+ else:
|
||||
+ args.add(ropecg(p.module, "Genode::Cstring($1->data, $1->len)", [a.rdLoc]))
|
||||
p.module.includeHeader("<base/log.h>")
|
||||
p.module.includeHeader("<util/string.h>")
|
||||
- linefmt(p, cpsStmts, """Genode::log(""$1);$n""", [args])
|
||||
+ linefmt(p, cpsStmts, """Genode::log($1);$n""", [args])
|
||||
else:
|
||||
if n.len == 0:
|
||||
linefmt(p, cpsStmts, "#echoBinSafe(NIM_NIL, $1);$n", [n.len])
|
||||
--
|
||||
2.30.1
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
commit 32003f90f7eb0d685913cf49a05f32f3125855b0
|
||||
Author: Emery Hemingway <ehmry@posteo.net>
|
||||
Date: 2022-05-18 20:17:03 -0500
|
||||
|
||||
Fix replacement of empty rpath with an empty rpath
|
||||
|
||||
diff --git a/src/patchelf.cc b/src/patchelf.cc
|
||||
index fd1e7b7..b9f58cd 100644
|
||||
--- a/src/patchelf.cc
|
||||
+++ b/src/patchelf.cc
|
||||
@@ -1426,7 +1426,7 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op,
|
||||
|
||||
|
||||
if (newRPath.size() <= rpathSize) {
|
||||
- strcpy(rpath, newRPath.c_str());
|
||||
+ if (rpath) strcpy(rpath, newRPath.c_str());
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue