make --xip and .wamr_mmap configurable from build menu
This commit is contained in:
218
flake.nix
218
flake.nix
@ -6,27 +6,29 @@ rec {
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
# Create a shell (and possibly package) for each possible system, not only x86_64-linux
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
# Create a shell (and possibly package) for each possible system, not only x86_64-linux
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
system:
|
||||
let
|
||||
# =========================================================================================
|
||||
# Define pkgs/stdenvs
|
||||
# =========================================================================================
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
overlays = [];
|
||||
overlays = [ ];
|
||||
};
|
||||
|
||||
i386_pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
overlays = [];
|
||||
overlays = [ ];
|
||||
|
||||
# Build crosscompiler
|
||||
crossSystem = {
|
||||
@ -37,23 +39,23 @@ rec {
|
||||
|
||||
boost_pkgs =
|
||||
import
|
||||
(builtins.fetchTarball {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/824421b1796332ad1bcb35bc7855da832c43305f.tar.gz";
|
||||
sha256 = "sha256:1w6cjnakz1yi66rs8c6nmhymsr7bj82vs2hz200ipi1sfiq8dy4y";
|
||||
})
|
||||
{
|
||||
inherit system;
|
||||
};
|
||||
(builtins.fetchTarball {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/824421b1796332ad1bcb35bc7855da832c43305f.tar.gz";
|
||||
sha256 = "sha256:1w6cjnakz1yi66rs8c6nmhymsr7bj82vs2hz200ipi1sfiq8dy4y";
|
||||
})
|
||||
{
|
||||
inherit system;
|
||||
};
|
||||
|
||||
libdwarf_pkgs =
|
||||
import
|
||||
(builtins.fetchTarball {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/f597e7e9fcf37d8ed14a12835ede0a7d362314bd.tar.gz";
|
||||
sha256 = "sha256:1l79hh7jh7m8yc5mvc8dbg6s8rf30bgm994kf07xriqbzwfn158r";
|
||||
})
|
||||
{
|
||||
inherit system;
|
||||
};
|
||||
(builtins.fetchTarball {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/f597e7e9fcf37d8ed14a12835ede0a7d362314bd.tar.gz";
|
||||
sha256 = "sha256:1l79hh7jh7m8yc5mvc8dbg6s8rf30bgm994kf07xriqbzwfn158r";
|
||||
})
|
||||
{
|
||||
inherit system;
|
||||
};
|
||||
|
||||
inherit (pkgs) lib stdenv;
|
||||
|
||||
@ -62,38 +64,39 @@ rec {
|
||||
# =========================================================================================
|
||||
|
||||
# Setup the shell when entering the "nix develop" environment (bash script).
|
||||
shellHook = let
|
||||
# Add project-local fish abbrs here
|
||||
abbrs = {
|
||||
fail = "perl ./scripts/menu.pl";
|
||||
shellHook =
|
||||
let
|
||||
# Add project-local fish abbrs here
|
||||
abbrs = {
|
||||
fail = "perl ./scripts/menu.pl";
|
||||
|
||||
# C/C++:
|
||||
# cmake-debug = "${cmakeDebug}";
|
||||
# cmake-release = "${cmakeRelease}";
|
||||
# build-debug = "${buildDebug}";
|
||||
# build-release = "${buildRelease}";
|
||||
};
|
||||
# C/C++:
|
||||
# cmake-debug = "${cmakeDebug}";
|
||||
# cmake-release = "${cmakeRelease}";
|
||||
# build-debug = "${buildDebug}";
|
||||
# build-release = "${buildRelease}";
|
||||
};
|
||||
|
||||
eraseAbbr = name: value: "abbr --erase ${name} 2>/dev/null";
|
||||
createAbbr = name: value: ''abbr -a ${name} "${value}"'';
|
||||
eraseAbbr = name: value: "abbr --erase ${name} 2>/dev/null";
|
||||
createAbbr = name: value: ''abbr -a ${name} "${value}"'';
|
||||
|
||||
# This will be sourced by the global fish config if INIT_PROJECT_SHELL gets unset
|
||||
unloadProjectShell = pkgs.writers.writeFish "unload-shell.fish" ''
|
||||
echo "Unloading \"${description}\" environment..."
|
||||
# This will be sourced by the global fish config if INIT_PROJECT_SHELL gets unset
|
||||
unloadProjectShell = pkgs.writers.writeFish "unload-shell.fish" ''
|
||||
echo "Unloading \"${description}\" environment..."
|
||||
|
||||
${builtins.concatStringsSep "\n" (lib.mapAttrsToList eraseAbbr abbrs)}
|
||||
'';
|
||||
${builtins.concatStringsSep "\n" (lib.mapAttrsToList eraseAbbr abbrs)}
|
||||
'';
|
||||
|
||||
# This will be sourced by the global fish config if INIT_PROJECT_SHELL gets set
|
||||
initProjectShell = pkgs.writers.writeFish "init-shell.fish" ''
|
||||
# Unload just in case, to not have redefinition errors
|
||||
source ${unloadProjectShell}
|
||||
# This will be sourced by the global fish config if INIT_PROJECT_SHELL gets set
|
||||
initProjectShell = pkgs.writers.writeFish "init-shell.fish" ''
|
||||
# Unload just in case, to not have redefinition errors
|
||||
source ${unloadProjectShell}
|
||||
|
||||
echo "Sourcing \"${description}\" environment..."
|
||||
echo "Sourcing \"${description}\" environment..."
|
||||
|
||||
${builtins.concatStringsSep "\n" (lib.mapAttrsToList createAbbr abbrs)}
|
||||
'';
|
||||
in
|
||||
${builtins.concatStringsSep "\n" (lib.mapAttrsToList createAbbr abbrs)}
|
||||
'';
|
||||
in
|
||||
builtins.concatStringsSep "\n" [
|
||||
# Launch into pure fish shell
|
||||
''
|
||||
@ -114,13 +117,12 @@ rec {
|
||||
# ===========================================================================================
|
||||
|
||||
python = pkgs.python314.withPackages (
|
||||
p:
|
||||
with p; [
|
||||
setuptools
|
||||
flask
|
||||
flask-mysqldb
|
||||
pyyaml
|
||||
]
|
||||
p: with p; [
|
||||
setuptools
|
||||
flask
|
||||
flask-mysqldb
|
||||
pyyaml
|
||||
]
|
||||
);
|
||||
|
||||
# perl = pkgs.perl.withPackages (p:
|
||||
@ -161,9 +163,10 @@ rec {
|
||||
pname = "wasi-sdk";
|
||||
version = "29";
|
||||
|
||||
src = let
|
||||
baseurl = "https://github.com/WebAssembly/wasi-sdk/releases/download";
|
||||
in
|
||||
src =
|
||||
let
|
||||
baseurl = "https://github.com/WebAssembly/wasi-sdk/releases/download";
|
||||
in
|
||||
builtins.fetchTarball {
|
||||
url = "${baseurl}/${pname}-${version}/${pname}-${version}.0-x86_64-linux.tar.gz";
|
||||
sha256 = "sha256:16afis71iqfvwiny4dz0lk9f7wbary0wa67ybwyhywr8g57ss6hq";
|
||||
@ -192,9 +195,10 @@ rec {
|
||||
pname = "iwasm";
|
||||
version = "2.4.4";
|
||||
|
||||
src = let
|
||||
baseurl = "https://github.com/bytecodealliance/wasm-micro-runtime/releases/download";
|
||||
in
|
||||
src =
|
||||
let
|
||||
baseurl = "https://github.com/bytecodealliance/wasm-micro-runtime/releases/download";
|
||||
in
|
||||
builtins.fetchTarball {
|
||||
url = "${baseurl}/WAMR-${version}/${pname}-${version}-x86_64-ubuntu-22.04.tar.gz";
|
||||
sha256 = "sha256:05irihz3yf7hpc0a59qz9i62imhrsni9xy9nxwsn6b8s92c1yzrp";
|
||||
@ -225,9 +229,10 @@ rec {
|
||||
pname = "wamrc";
|
||||
version = "2.4.4";
|
||||
|
||||
src = let
|
||||
baseurl = "https://github.com/bytecodealliance/wasm-micro-runtime/releases/download";
|
||||
in
|
||||
src =
|
||||
let
|
||||
baseurl = "https://github.com/bytecodealliance/wasm-micro-runtime/releases/download";
|
||||
in
|
||||
builtins.fetchTarball {
|
||||
url = "${baseurl}/WAMR-${version}/${pname}-${version}-x86_64-ubuntu-22.04.tar.gz";
|
||||
sha256 = "sha256:0264arh03gc35z0zdvw07qdvqgfvsxr3qgl1aszghwicmdmh4sqj";
|
||||
@ -294,50 +299,75 @@ rec {
|
||||
'';
|
||||
};
|
||||
|
||||
mkLibiwasm = {
|
||||
buildenv,
|
||||
platform,
|
||||
buildtype,
|
||||
cflags,
|
||||
extraCmakeFlags ? [],
|
||||
}:
|
||||
mkLibiwasm =
|
||||
{
|
||||
buildenv,
|
||||
platform,
|
||||
buildtype,
|
||||
cflags,
|
||||
extraCmakeFlags ? [ ],
|
||||
patches ? [ ],
|
||||
}:
|
||||
buildenv.mkDerivation {
|
||||
pname = "libiwasm";
|
||||
version = "2.4.4";
|
||||
src = wamr_src;
|
||||
|
||||
nativeBuildInputs = with pkgs; [cmake];
|
||||
inherit patches;
|
||||
|
||||
nativeBuildInputs = with pkgs; [ cmake ];
|
||||
|
||||
dontStrip = true;
|
||||
cmakeBuildType = buildtype;
|
||||
cmakeFlags =
|
||||
extraCmakeFlags
|
||||
++ [
|
||||
"-DCMAKE_VERBOSE_MAKEFILE=ON"
|
||||
"-DCMAKE_COLOR_DIAGNOSTICS=ON"
|
||||
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"
|
||||
];
|
||||
"-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"
|
||||
@ -349,6 +379,7 @@ rec {
|
||||
platform = "baremetal";
|
||||
buildtype = "MinSizeRel";
|
||||
cflags = "-O2 -ggdb3 -DNDEBUG";
|
||||
patches = [ ./patches/disable_wamr_mmap.patch ];
|
||||
extraCmakeFlags = [
|
||||
"-DCMAKE_SYSTEM_NAME=Generic"
|
||||
"-DCMAKE_SYSTEM_PROCESSOR=i386"
|
||||
@ -407,7 +438,7 @@ rec {
|
||||
# Add dependencies to buildInputs if they will end up copied or linked into the final output or otherwise used at runtime:
|
||||
# - Libraries used by compilers, for example zlib
|
||||
# - Interpreters needed by patchShebangs for scripts which are installed, which can be the case for e.g. perl
|
||||
buildInputs = with pkgs; [];
|
||||
buildInputs = with pkgs; [ ];
|
||||
|
||||
# ===========================================================================================
|
||||
# Define buildable + installable packages
|
||||
@ -462,7 +493,8 @@ rec {
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
# Provide package for "nix build"
|
||||
packages = {
|
||||
default = fail-bin;
|
||||
@ -472,7 +504,7 @@ rec {
|
||||
wamrc = wamrc;
|
||||
};
|
||||
apps = {
|
||||
default = flake-utils.lib.mkApp {drv = fail-bin;};
|
||||
default = flake-utils.lib.mkApp { drv = fail-bin; };
|
||||
fail = fail-bin;
|
||||
wasi-sdk = wasi-sdk;
|
||||
iwasm = iwasm;
|
||||
@ -502,6 +534,8 @@ rec {
|
||||
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";
|
||||
CROSS_CC = "${i386_pkgs.stdenv.cc}/bin/i386-elf-gcc";
|
||||
|
||||
Reference in New Issue
Block a user