replace build.just with compile.pl

This commit is contained in:
2026-06-05 17:14:34 +02:00
parent 9c42618028
commit bd6df6b4e9
6 changed files with 563 additions and 756 deletions

160
flake.nix
View File

@ -6,6 +6,10 @@ rec {
flake-utils.url = "github:numtide/flake-utils";
};
# TODO: Merge wasm_host_pool/_allocator and use #define flags instead
# TODO: Rewrite all perl scripts -> modularize common code and unify menu actions
# TODO: Write a test suite that verifies the build process (against the produced .elf, check if the expected stuff is in there)
outputs =
{
self,
@ -259,147 +263,6 @@ rec {
'';
};
wamr_src = pkgs.fetchFromGitea {
domain = "gitea.local.chriphost.de";
owner = "christoph";
# domain = "git.cs.tu-dortmund.de";
# owner = "christoph.urlacher";
repo = "wamr";
# With mmap_space in .text.wamr_mmap
rev = "f618cfffaf5ac344fa39abcd16c35278cdacee15";
hash = "sha256-nOLQLIVImPoClGWvmqgMFeC8s5MHLzkTSl/M03eQDaA=";
# With fail_marker_group1 in wasm_set_exception_local
# rev = "177fe78618ce3f74ed497c13ea80e8fbad779e82";
# hash = "sha256-H+ubCmL1YkI7kG7pYBs1+vpROm0hy2sryi0MWeQO3Bs=";
# With mmap_space in .text.wamr_aot
# rev = "cda2009deb85511089b04b0ac736ad4da2d07e58";
# hash = "sha256-CN6xTiwzF4Jbrpf21TF5c/C03Xb3urwkibRuIXjoU/w=";
# Without mmap_space in .text.wamr_aot
# rev = "4e7aed33fe53bf3ee4a3f2fe582c74816f850759";
# hash = "sha256-/4BKwoFDRfkA+DmbWagxdtkCDAED5rxbz5e4xvjvVWU=";
};
wamr = stdenv.mkDerivation {
pname = "wamr";
version = "2.4.4";
src = wamr_src;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out
cp -rv ./* $out/
runHook postInstall
'';
};
mkLibiwasm =
{
buildenv,
platform,
buildtype,
cflags,
extraCmakeFlags ? [ ],
patches ? [ ],
}:
buildenv.mkDerivation {
pname = "libiwasm";
version = "2.4.4";
src = wamr_src;
inherit patches;
nativeBuildInputs = with pkgs; [ cmake ];
dontStrip = true;
cmakeBuildType = buildtype;
cmakeFlags = extraCmakeFlags ++ [
"-DCMAKE_VERBOSE_MAKEFILE=ON"
"-DCMAKE_COLOR_DIAGNOSTICS=ON"
"-DWAMR_BUILD_PLATFORM=${platform}"
"-DWAMR_BUILD_TARGET=X86_32"
"-DWAMR_BUILD_AOT=1"
"-DWAMR_BUILD_WAMR_COMPILER=0"
"-DWAMR_BUILD_INTERP=1"
"-DWAMR_BUILD_FAST_INTERP=0"
"-DWAMR_BUILD_JIT=0"
"-DWAMR_BUILD_FAST_JIT=0"
"-DWAMR_BUILD_LIBC_BUILTIN=1"
"-DWAMR_BUILD_LIBC_WASI=0"
"-DWAMR_BUILD_SIMD=0"
];
# Since GCC 15, implicit declarations are an error. Disable this.
NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration " + cflags;
};
libiwasm-baremetal-mmap-debug = mkLibiwasm {
buildenv = i386_pkgs.stdenv;
platform = "baremetal";
buildtype = "Debug";
cflags = "-O0 -ggdb3";
extraCmakeFlags = [
"-DCMAKE_SYSTEM_NAME=Generic"
"-DCMAKE_SYSTEM_PROCESSOR=i386"
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
];
};
libiwasm-baremetal-mmap-release = mkLibiwasm {
buildenv = i386_pkgs.stdenv;
platform = "baremetal";
buildtype = "MinSizeRel";
cflags = "-O2 -ggdb3 -DNDEBUG";
extraCmakeFlags = [
"-DCMAKE_SYSTEM_NAME=Generic"
"-DCMAKE_SYSTEM_PROCESSOR=i386"
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
];
};
libiwasm-baremetal-debug = mkLibiwasm {
buildenv = i386_pkgs.stdenv;
platform = "baremetal";
buildtype = "Debug";
cflags = "-O0 -ggdb3";
patches = [ ./patches/disable_wamr_mmap.patch ];
extraCmakeFlags = [
"-DCMAKE_SYSTEM_NAME=Generic"
"-DCMAKE_SYSTEM_PROCESSOR=i386"
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
];
};
libiwasm-baremetal-release = mkLibiwasm {
buildenv = i386_pkgs.stdenv;
platform = "baremetal";
buildtype = "MinSizeRel";
cflags = "-O2 -ggdb3 -DNDEBUG";
patches = [ ./patches/disable_wamr_mmap.patch ];
extraCmakeFlags = [
"-DCMAKE_SYSTEM_NAME=Generic"
"-DCMAKE_SYSTEM_PROCESSOR=i386"
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
];
};
libiwasm-linux-debug = mkLibiwasm {
buildenv = pkgs.multiStdenv;
platform = "linux";
buildtype = "Debug";
cflags = "-O0 -ggdb3";
};
libiwasm-linux-release = mkLibiwasm {
buildenv = pkgs.multiStdenv;
platform = "linux";
buildtype = "MinSizeRel";
cflags = "-O2 -ggdb3 -DNDEBUG";
};
# ===========================================================================================
# Specify dependencies
# https://nixos.org/manual/nixpkgs/stable/#ssec-stdenv-dependencies-overview
@ -411,7 +274,7 @@ rec {
# - Setup hooks, for example makeWrapper/autoPatchelfHook
# - Interpreters needed by patchShebangs for build scripts (with the --build flag), which can be the case for e.g. perl
nativeBuildInputs = with pkgs; [
just
cmake
gdb
xxd
wabt
@ -525,19 +388,10 @@ rec {
# Dynamic libraries from buildinputs:
# LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
JUST_WORKING_DIRECTORY = "/home/christoph/Notes/TU/MastersThesis/FailNix";
JUST_JUSTFILE = "/home/christoph/Notes/TU/MastersThesis/FailNix/scripts/build.just";
# Those are read by the justfile
# Those are read by compile.pl / build.pl
FAIL_SHARE = "${fail-bin}/share";
WASI_ROOT = wasi-sdk;
WAMR_ROOT = wamr;
LIBIWASM_DEBUG = "${libiwasm-baremetal-debug}/lib";
LIBIWASM_RELEASE = "${libiwasm-baremetal-release}/lib";
LIBIWASM_MMAP_DEBUG = "${libiwasm-baremetal-mmap-debug}/lib";
LIBIWASM_MMAP_RELEASE = "${libiwasm-baremetal-mmap-release}/lib";
LIBIWASM_LINUX_DEBUG = "${libiwasm-linux-debug}/lib";
LIBIWASM_LINUX_RELEASE = "${libiwasm-linux-release}/lib";
WAMR_ROOT = "/home/christoph/Notes/TU/MastersThesis/FailNix/wamr";
CROSS_CC = "${i386_pkgs.stdenv.cc}/bin/i386-elf-gcc";
CROSS_CXX = "${i386_pkgs.stdenv.cc}/bin/i386-elf-g++";
LINUX_CC = "${pkgs.multiStdenv.cc}/bin/gcc";