diff options
Diffstat (limited to 'nixpkgs/pkgs/os-specific/linux/minimal-bootstrap')
18 files changed, 448 insertions, 210 deletions
diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix index 9c9682fdf9d5..dea5ad9f017f 100644 --- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix @@ -95,4 +95,5 @@ bootBash.runCommand "${pname}-${version}" { # Install make install + ln -s bash $out/bin/sh '' diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 2a10a3395ba7..55900f86d21c 100644 --- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -19,6 +19,7 @@ lib.makeScope bootBash = bash_2_05; gcc = gcc2; glibc = glibc22; + gawk = gawk-mes; }; binutils = callPackage ./binutils { @@ -27,11 +28,13 @@ lib.makeScope binutils = binutils-mes; glibc = glibc22; sed = heirloom.sed; + gawk = gawk-mes; }; binutils-mes = callPackage ./binutils { bash = bash_2_05; tinycc = tinycc-mes; sed = heirloom.sed; + gawk = gawk-mes; mesBootstrap = true; }; @@ -46,20 +49,29 @@ lib.makeScope bash = bash_2_05; gcc = gcc2; glibc = glibc22; + gawk = gawk-mes; }; findutils = callPackage ./findutils { bash = bash_2_05; gcc = gcc2; glibc = glibc22; + gawk = gawk-mes; }; - gawk = callPackage ./gawk { + gawk-mes = callPackage ./gawk/mes.nix { bash = bash_2_05; tinycc = tinycc-mes; gnused = gnused-mes; }; + gawk = callPackage ./gawk { + bash = bash_2_05; + gcc = gcc2; + glibc = glibc22; + bootGawk = gawk-mes; + }; + gcc2 = callPackage ./gcc/2.nix { bash = bash_2_05; gcc = gcc2-mes; @@ -76,11 +88,13 @@ lib.makeScope gcc46 = callPackage ./gcc/4.6.nix { gcc = gcc2; glibc = glibc22; + gawk = gawk-mes; }; inherit (callPackage ./glibc { bash = bash_2_05; gnused = gnused-mes; + gawk = gawk-mes; }) glibc22; gnugrep = callPackage ./gnugrep { @@ -130,6 +144,11 @@ lib.makeScope mes = lib.recurseIntoAttrs (callPackage ./mes { }); mes-libc = callPackage ./mes/libc.nix { }; + musl = callPackage ./musl { + gcc = gcc46; + gawk = gawk-mes; + }; + stage0-posix = callPackage ./stage0-posix { }; inherit (self.stage0-posix) kaem m2libc mescc-tools mescc-tools-extra; @@ -140,6 +159,7 @@ lib.makeScope xz = callPackage ./xz { bash = bash_2_05; tinycc = tinycc-mes; + gawk = gawk-mes; inherit (heirloom) sed; }; @@ -153,6 +173,7 @@ lib.makeScope echo ${bzip2.tests.get-version} echo ${diffutils.tests.get-version} echo ${findutils.tests.get-version} + echo ${gawk-mes.tests.get-version} echo ${gawk.tests.get-version} echo ${gcc2.tests.get-version} echo ${gcc2-mes.tests.get-version} @@ -164,6 +185,7 @@ lib.makeScope echo ${gzip.tests.get-version} echo ${heirloom.tests.get-version} echo ${mes.compiler.tests.get-version} + echo ${musl.tests.hello-world} echo ${tinycc-mes.compiler.tests.chain} echo ${xz.tests.get-version} mkdir ''${out} diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/gawk/common.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/gawk/common.nix new file mode 100644 index 000000000000..d95c66d86337 --- /dev/null +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/gawk/common.nix @@ -0,0 +1,11 @@ +{ lib }: + +{ + meta = with lib; { + description = "GNU implementation of the Awk programming language"; + homepage = "https://www.gnu.org/software/gawk"; + license = licenses.gpl3Plus; + maintainers = teams.minimal-bootstrap.members; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix index d840a204416d..935414f21760 100644 --- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix @@ -3,36 +3,41 @@ , hostPlatform , fetchurl , bash -, tinycc +, gcc +, glibc +, binutils +, linux-headers , gnumake -, gnupatch -, gnused , gnugrep +, gnused +, gnutar +, gzip +, bootGawk }: let + inherit (import ./common.nix { inherit lib; }) meta; pname = "gawk"; - # >=3.1.x is incompatible with mes-libc - version = "3.0.6"; + # >= 4.2.0 fails to cleanly build. may be worth investigating in the future. + # for now this version is sufficient to build glibc 2.16 + version = "4.1.4"; src = fetchurl { url = "mirror://gnu/gawk/gawk-${version}.tar.gz"; - sha256 = "1z4bibjm7ldvjwq3hmyifyb429rs2d9bdwkvs0r171vv1khpdwmb"; + sha256 = "0dadjkpyyizmyd0l098qps8lb39r0vrz3xl3hwz2cmjs5c70h0wc"; }; - - patches = [ - # for reproducibility don't generate date stamp - ./no-stamp.patch - ]; in bash.runCommand "${pname}-${version}" { - inherit pname version; + inherit pname version meta; nativeBuildInputs = [ - tinycc.compiler + gcc + binutils gnumake - gnupatch gnused gnugrep + gnutar + gzip + bootGawk ]; passthru.tests.get-version = result: @@ -40,33 +45,19 @@ bash.runCommand "${pname}-${version}" { ${result}/bin/awk --version mkdir $out ''; - - meta = with lib; { - description = "GNU implementation of the Awk programming language"; - homepage = "https://www.gnu.org/software/gawk"; - license = licenses.gpl3Plus; - maintainers = teams.minimal-bootstrap.members; - platforms = platforms.unix; - }; } '' # Unpack - ungz --file ${src} --output gawk.tar - untar --file gawk.tar - rm gawk.tar + tar xzf ${src} cd gawk-${version} - # Patch - ${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches} - # Configure - export CC="tcc -B ${tinycc.libs}/lib" - export ac_cv_func_getpgrp_void=yes - export ac_cv_func_tzset=yes + export C_INCLUDE_PATH="${glibc}/include:${linux-headers}/include" + export LIBRARY_PATH="${glibc}/lib" + export LIBS="-lc -lnss_files -lnss_dns -lresolv" bash ./configure \ + --prefix=$out \ --build=${buildPlatform.config} \ - --host=${hostPlatform.config} \ - --disable-nls \ - --prefix=$out + --host=${hostPlatform.config} # Build make gawk diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/gawk/mes.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/gawk/mes.nix new file mode 100644 index 000000000000..c14399309306 --- /dev/null +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/gawk/mes.nix @@ -0,0 +1,70 @@ +{ lib +, buildPlatform +, hostPlatform +, fetchurl +, bash +, tinycc +, gnumake +, gnupatch +, gnused +, gnugrep +}: +let + inherit (import ./common.nix { inherit lib; }) meta; + pname = "gawk-mes"; + # >=3.1.x is incompatible with mes-libc + version = "3.0.6"; + + src = fetchurl { + url = "mirror://gnu/gawk/gawk-${version}.tar.gz"; + sha256 = "1z4bibjm7ldvjwq3hmyifyb429rs2d9bdwkvs0r171vv1khpdwmb"; + }; + + patches = [ + # for reproducibility don't generate date stamp + ./no-stamp.patch + ]; +in +bash.runCommand "${pname}-${version}" { + inherit pname version meta; + + nativeBuildInputs = [ + tinycc.compiler + gnumake + gnupatch + gnused + gnugrep + ]; + + passthru.tests.get-version = result: + bash.runCommand "${pname}-get-version-${version}" {} '' + ${result}/bin/awk --version + mkdir $out + ''; +} '' + # Unpack + ungz --file ${src} --output gawk.tar + untar --file gawk.tar + rm gawk.tar + cd gawk-${version} + + # Patch + ${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches} + + # Configure + export CC="tcc -B ${tinycc.libs}/lib" + export ac_cv_func_getpgrp_void=yes + export ac_cv_func_tzset=yes + bash ./configure \ + --build=${buildPlatform.config} \ + --host=${hostPlatform.config} \ + --disable-nls \ + --prefix=$out + + # Build + make gawk + + # Install + install -D gawk $out/bin/gawk + ln -s gawk $out/bin/awk +'' diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/mes/default.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/mes/default.nix index 04ab2fdbfaf0..0cf66c5bc230 100644 --- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/mes/default.nix +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/mes/default.nix @@ -222,7 +222,6 @@ let mkdir -p ''${out}/bin ${srcPost.bin}/bin/mes-m2 -e main ${srcPost.bin}/bin/mescc.scm -- \ - --base-address 0x08048000 \ -L ''${srcPrefix}/lib \ -L ${libs}/lib \ -lc \ diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/musl/default.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/musl/default.nix new file mode 100644 index 000000000000..c252d60328e9 --- /dev/null +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/musl/default.nix @@ -0,0 +1,87 @@ +{ lib +, buildPlatform +, hostPlatform +, fetchurl +, bash +, gcc +, binutils +, gnumake +, gnugrep +, gnused +, gawk +, gnutar +, gzip +}: +let + pname = "musl"; + version = "1.2.4"; + + src = fetchurl { + url = "https://musl.libc.org/releases/musl-${version}.tar.gz"; + hash = "sha256-ejXq4z1TcqfA2hGI3nmHJvaIJVE7euPr6XqqpSEU8Dk="; + }; +in +bash.runCommand "${pname}-${version}" { + inherit pname version; + + nativeBuildInputs = [ + gcc + binutils + gnumake + gnused + gnugrep + gawk + gnutar + gzip + ]; + + passthru.tests.hello-world = result: + bash.runCommand "${pname}-simple-program-${version}" { + nativeBuildInputs = [ gcc binutils ]; + } '' + cat <<EOF >> test.c + #include <stdio.h> + int main() { + printf("Hello World!\n"); + return 0; + } + EOF + gcc -static -B${result}/lib -I${result}/include -o test test.c + ./test + mkdir $out + ''; + + meta = with lib; { + description = "An efficient, small, quality libc implementation"; + homepage = "https://musl.libc.org"; + license = licenses.mit; + maintainers = teams.minimal-bootstrap.members; + platforms = platforms.unix; + }; +} '' + # Unpack + tar xzf ${src} + cd musl-${version} + + # Patch + # https://github.com/ZilchOS/bootstrap-from-tcc/blob/2e0c68c36b3437386f786d619bc9a16177f2e149/using-nix/2a3-intermediate-musl.nix + sed -i 's|/bin/sh|${bash}/bin/bash|' \ + tools/*.sh + # patch popen/system to search in PATH instead of hardcoding /bin/sh + sed -i 's|posix_spawn(&pid, "/bin/sh",|posix_spawnp(\&pid, "sh",|' \ + src/stdio/popen.c src/process/system.c + sed -i 's|execl("/bin/sh", "sh", "-c",|execlp("sh", "-c",|'\ + src/misc/wordexp.c + + # Configure + bash ./configure \ + --prefix=$out \ + --build=${buildPlatform.config} \ + --host=${hostPlatform.config} + + # Build + make + + # Install + make install +'' diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/bootstrap-sources.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/bootstrap-sources.nix index 82ee4d12386e..203b480326e9 100644 --- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/bootstrap-sources.nix +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/bootstrap-sources.nix @@ -9,14 +9,6 @@ rec { outputHashAlgo = "sha256"; outputHash = "sha256-FpMp7z+B3cR3LkQ+PooH/b1/NlxH8NHVJNWifaPWt4U="; - # This 256 byte seed is the only pre-compiled binary in the bootstrap chain. - hex0-seed = import <nix/fetchurl.nix> { - name = "hex0-seed-${version}"; - url = "https://github.com/oriansj/bootstrap-seeds/raw/b1263ff14a17835f4d12539226208c426ced4fba/POSIX/x86/hex0-seed"; - hash = "sha256-QU3RPGy51W7M2xnfFY1IqruKzusrSLU+L190ztN6JW8="; - executable = true; - }; - /* Since `make-minimal-bootstrap-sources` requires nixpkgs and nix it will create a circular dependency if it is used in place of the diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/default.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/default.nix index c15223a43d48..9f3d61b92bc9 100644 --- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/default.nix +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/default.nix @@ -3,21 +3,23 @@ }: lib.makeScope newScope (self: with self; { - inherit (self.callPackage ./bootstrap-sources.nix {}) - version hex0-seed minimal-bootstrap-sources; + inherit (callPackage ./platforms.nix { }) platforms stage0Arch m2libcArch m2libcOS baseAddress; + + inherit (self.callPackage ./bootstrap-sources.nix {}) version minimal-bootstrap-sources; src = minimal-bootstrap-sources; m2libc = src + "/M2libc"; hex0 = callPackage ./hex0.nix { }; + inherit (self.hex0) hex0-seed; kaem = callPackage ./kaem { }; kaem-minimal = callPackage ./kaem/minimal.nix { }; - stage0-posix-x86 = callPackage ./stage0-posix-x86.nix { }; + mescc-tools-boot = callPackage ./mescc-tools-boot.nix { }; - inherit (self.stage0-posix-x86) blood-elf-0 hex2 kaem-unwrapped M1 M2; + inherit (self.mescc-tools-boot) blood-elf-0 hex2 kaem-unwrapped M1 M2; mescc-tools = callPackage ./mescc-tools { }; diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/hex0.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/hex0.nix index b85b2f2cac14..996f2f33ea35 100644 --- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/hex0.nix +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/hex0.nix @@ -1,15 +1,33 @@ { lib , derivationWithMeta -, hex0-seed +, hostPlatform , src , version +, platforms +, stage0Arch }: + +let + hash = { + "x86" = "sha256-QU3RPGy51W7M2xnfFY1IqruKzusrSLU+L190ztN6JW8="; + "AMD64" = "sha256-RCgK9oZRDQUiWLVkcIBSR2HeoB+Bh0czthrpjFEkCaY="; + }.${stage0Arch} or (throw "Unsupported system: ${hostPlatform.system}"); + + # Pinned from https://github.com/oriansj/stage0-posix/commit/3189b5f325b7ef8b88e3edec7c1cde4fce73c76c + # This 256 byte seed is the only pre-compiled binary in the bootstrap chain. + hex0-seed = import <nix/fetchurl.nix> { + name = "hex0-seed"; + url = "https://github.com/oriansj/bootstrap-seeds/raw/b1263ff14a17835f4d12539226208c426ced4fba/POSIX/${stage0Arch}/hex0-seed"; + executable = true; + inherit hash; + }; +in derivationWithMeta { inherit version; pname = "hex0"; builder = hex0-seed; args = [ - "${src}/x86/hex0_x86.hex0" + "${src}/${stage0Arch}/hex0_${stage0Arch}.hex0" (placeholder "out") ]; @@ -18,11 +36,13 @@ derivationWithMeta { homepage = "https://github.com/oriansj/stage0-posix"; license = licenses.gpl3Plus; maintainers = teams.minimal-bootstrap.members; - platforms = [ "i686-linux" ]; + inherit platforms; }; + passthru = { inherit hex0-seed; }; + # Ensure the untrusted hex0-seed binary produces a known-good hex0 outputHashMode = "recursive"; outputHashAlgo = "sha256"; - outputHash = "sha256-QU3RPGy51W7M2xnfFY1IqruKzusrSLU+L190ztN6JW8="; + outputHash = hash; } diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/kaem/default.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/kaem/default.nix index 77e9a8e8d63f..547790835c5d 100644 --- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/kaem/default.nix +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/kaem/default.nix @@ -6,6 +6,7 @@ , mescc-tools , mescc-tools-extra , version +, platforms }: # Once mescc-tools-extra is available we can install kaem at /bin/kaem @@ -46,6 +47,6 @@ derivationWithMeta { homepage = "https://github.com/oriansj/mescc-tools"; license = licenses.gpl3Plus; maintainers = teams.minimal-bootstrap.members; - platforms = [ "i686-linux" ]; + inherit platforms; }; } diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/kaem/minimal.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/kaem/minimal.nix index 24fc77f8d345..ae31302894aa 100644 --- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/kaem/minimal.nix +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/kaem/minimal.nix @@ -3,13 +3,15 @@ , src , hex0 , version +, platforms +, stage0Arch }: derivationWithMeta { inherit version; pname = "kaem-minimal"; builder = hex0; args = [ - "${src}/x86/kaem-minimal.hex0" + "${src}/${stage0Arch}/kaem-minimal.hex0" (placeholder "out") ]; @@ -18,7 +20,7 @@ derivationWithMeta { homepage = "https://github.com/oriansj/stage0-posix"; license = licenses.gpl3Plus; maintainers = teams.minimal-bootstrap.members; - platforms = [ "i686-linux" ]; + inherit platforms; }; } diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/stage0-posix-x86.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools-boot.nix index bcb02537b916..65f0fb4c2ff1 100644 --- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/stage0-posix-x86.nix +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools-boot.nix @@ -1,10 +1,3 @@ -# This is a translation of stage0-posix/stage0-posix/x86/mescc-tools-mini-kaem.kaem to nix -# https://github.com/oriansj/stage0-posix-x86/blob/56e6b8df3e95f4bc04f8b420a4cd8c82c70b9efa/mescc-tools-mini-kaem.kaem -# -# We have access to mini-kaem at this point but it doesn't support substituting -# environment variables. Without variables there's no way of passing in store inputs, -# or the $out path, other than as command line arguments directly - # Mes --- Maxwell Equations of Software # Copyright © 2017,2019 Jan Nieuwenhuizen <janneke@gnu.org> # Copyright © 2017,2019 Jeremiah Orians @@ -24,19 +17,35 @@ # You should have received a copy of the GNU General Public License # along with Mes. If not, see <http://www.gnu.org/licenses/>. +# This is a translation of stage0-posix/stage0-posix/x86/mescc-tools-mini-kaem.kaem to nix +# https://github.com/oriansj/stage0-posix-x86/blob/56e6b8df3e95f4bc04f8b420a4cd8c82c70b9efa/mescc-tools-mini-kaem.kaem +# +# We have access to mini-kaem at this point but it doesn't support substituting +# environment variables. Without variables there's no way of passing in store inputs, +# or the $out path, other than as command line arguments directly + # Warning all binaries prior to the use of blood-elf will not be readable by # Objdump, you may need to use ndism or gdb to view the assembly in the binary. { lib , derivationWithMeta +, hostPlatform , hex0 , m2libc , src , version +, platforms +, stage0Arch +, m2libcArch +, baseAddress }: rec { out = placeholder "out"; + endianFlag = if hostPlatform.isLittleEndian then "--little-endian" else "--big-endian"; + + bloodFlags = lib.optional hostPlatform.is64bit "--64"; + run = pname: builder: args: derivationWithMeta { inherit pname version builder args; @@ -46,7 +55,7 @@ rec { homepage = "https://github.com/oriansj/stage0-posix"; license = licenses.gpl3Plus; maintainers = teams.minimal-bootstrap.members; - platforms = [ "i686-linux" ]; + inherit platforms; }; }; @@ -54,7 +63,7 @@ rec { # Phase-1 Build hex1 from hex0 # ################################ - hex1 = run "hex1" hex0 ["${src}/x86/hex1_x86.hex0" out]; + hex1 = run "hex1" hex0 ["${src}/${stage0Arch}/hex1_${stage0Arch}.hex0" out]; # hex1 adds support for single character labels and is available in various forms # in mescc-tools/x86_bootstrap to allow you various ways to verify correctness @@ -63,7 +72,7 @@ rec { # Phase-2 Build hex2 from hex1 # ################################ - hex2-0 = run "hex2" hex1 ["${src}/x86/hex2_x86.hex1" out]; + hex2-0 = run "hex2" hex1 ["${src}/${stage0Arch}/hex2_${stage0Arch}.hex1" out]; # hex2 adds support for long labels and absolute addresses thus allowing it # to function as an effective linker for later stages of the bootstrap @@ -74,7 +83,7 @@ rec { # Phase-2b Build catm from hex2 # ################################# - catm = run "catm" hex2-0 ["${src}/x86/catm_x86.hex2" out]; + catm = run "catm" hex2-0 ["${src}/${stage0Arch}/catm_${stage0Arch}.hex2" out]; # catm removes the need for cat or shell support for redirection by providing # equivalent functionality via catm output_file input1 input2 ... inputN @@ -83,27 +92,27 @@ rec { # Phase-3 Build M0 from hex2 # ############################## - M0_hex2 = run "M0.hex2" catm [out "${src}/x86/ELF-i386.hex2" "${src}/x86/M0_x86.hex2"]; + M0_hex2 = run "M0.hex2" catm [out "${m2libc}/${m2libcArch}/ELF-${m2libcArch}.hex2" "${src}/${stage0Arch}/M0_${stage0Arch}.hex2"]; M0 = run "M0" hex2-0 [M0_hex2 out]; # M0 is the architecture specific version of M1 and is by design single # architecture only and will be replaced by the C code version of M1 ################################ - # Phase-4 Build cc_x86 from M0 # + # Phase-4 Build cc_arch from M0 # ################################ - cc_x86-0_hex2 = run "cc_x86-0.hex2" M0 ["${src}/x86/cc_x86.M1" out]; - cc_x86-1_hex2 = run "cc_x86-1.hex2" catm [out "${src}/x86/ELF-i386.hex2" cc_x86-0_hex2]; - cc_x86 = run "cc_x86" hex2-0 [cc_x86-1_hex2 out]; + cc_arch-0_hex2 = run "cc_arch-0.hex2" M0 ["${src}/${stage0Arch}/cc_${m2libcArch}.M1" out]; + cc_arch-1_hex2 = run "cc_arch-1.hex2" catm [out "${m2libc}/${m2libcArch}/ELF-${m2libcArch}.hex2" cc_arch-0_hex2]; + cc_arch = run "cc_arch" hex2-0 [cc_arch-1_hex2 out]; - ####################################### - # Phase-5 Build M2-Planet from cc_x86 # - ####################################### + ######################################## + # Phase-5 Build M2-Planet from cc_arch # + ######################################## M2-0_c = run "M2-0.c" catm [ out - "${m2libc}/x86/linux/bootstrap.c" + "${m2libc}/${m2libcArch}/linux/bootstrap.c" "${src}/M2-Planet/cc.h" "${m2libc}/bootstrappable.c" "${src}/M2-Planet/cc_globals.c" @@ -114,10 +123,10 @@ rec { "${src}/M2-Planet/cc_macro.c" "${src}/M2-Planet/cc.c" ]; - M2-0_M1 = run "M2-0.M1" cc_x86 [M2-0_c out]; - M2-0-0_M1 = run "M2-0-0.M1" catm [out "${src}/x86/x86_defs.M1" "${src}/x86/libc-core.M1" M2-0_M1]; + M2-0_M1 = run "M2-0.M1" cc_arch [M2-0_c out]; + M2-0-0_M1 = run "M2-0-0.M1" catm [out "${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1" "${m2libc}/${m2libcArch}/libc-core.M1" M2-0_M1]; M2-0_hex2 = run "M2-0.hex2" M0 [M2-0-0_M1 out]; - M2-0-0_hex2 = run "M2-0-0.hex2" catm [out "${src}/x86/ELF-i386.hex2" M2-0_hex2]; + M2-0-0_hex2 = run "M2-0-0.hex2" catm [out "${m2libc}/${m2libcArch}/ELF-${m2libcArch}.hex2" M2-0_hex2]; M2 = run "M2" hex2-0 [M2-0-0_hex2 out]; ############################################ @@ -125,8 +134,8 @@ rec { ############################################ blood-elf-0_M1 = run "blood-elf-0.M1" M2 [ - "--architecture" "x86" - "-f" "${m2libc}/x86/linux/bootstrap.c" + "--architecture" m2libcArch + "-f" "${m2libc}/${m2libcArch}/linux/bootstrap.c" "-f" "${m2libc}/bootstrappable.c" "-f" "${src}/mescc-tools/stringify.c" "-f" "${src}/mescc-tools/blood-elf.c" @@ -134,9 +143,9 @@ rec { "-o" out ]; - blood-elf-0-0_M1 = run "blood-elf-0-0.M1" catm [out "${m2libc}/x86/x86_defs.M1" "${m2libc}/x86/libc-core.M1" blood-elf-0_M1]; + blood-elf-0-0_M1 = run "blood-elf-0-0.M1" catm [out "${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1" "${m2libc}/${m2libcArch}/libc-core.M1" blood-elf-0_M1]; blood-elf-0_hex2 = run "blood-elf-0.hex2" M0 [blood-elf-0-0_M1 out]; - blood-elf-0-0_hex2 = run "blood-elf-0-0.hex2" catm [out "${m2libc}/x86/ELF-x86.hex2" blood-elf-0_hex2]; + blood-elf-0-0_hex2 = run "blood-elf-0-0.hex2" catm [out "${m2libc}/${m2libcArch}/ELF-${m2libcArch}.hex2" blood-elf-0_hex2]; blood-elf-0 = run "blood-elf-0" hex2-0 [blood-elf-0-0_hex2 out]; # This is the last stage where the binaries will not have debug info @@ -147,8 +156,8 @@ rec { ##################################### M1-macro-0_M1 = run "M1-macro-0.M1" M2 [ - "--architecture" "x86" - "-f" "${m2libc}/x86/linux/bootstrap.c" + "--architecture" m2libcArch + "-f" "${m2libc}/${m2libcArch}/linux/bootstrap.c" "-f" "${m2libc}/bootstrappable.c" "-f" "${src}/mescc-tools/stringify.c" "-f" "${src}/mescc-tools/M1-macro.c" @@ -157,10 +166,10 @@ rec { "-o" out ]; - M1-macro-0-footer_M1 = run "M1-macro-0-footer.M1" blood-elf-0 ["-f" M1-macro-0_M1 "--little-endian" "-o" out]; - M1-macro-0-0_M1 = run "M1-macro-0-0.M1" catm [out "${m2libc}/x86/x86_defs.M1" "${m2libc}/x86/libc-core.M1" M1-macro-0_M1 M1-macro-0-footer_M1]; + M1-macro-0-footer_M1 = run "M1-macro-0-footer.M1" blood-elf-0 (bloodFlags ++ ["-f" M1-macro-0_M1 endianFlag "-o" out]); + M1-macro-0-0_M1 = run "M1-macro-0-0.M1" catm [out "${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1" "${m2libc}/${m2libcArch}/libc-core.M1" M1-macro-0_M1 M1-macro-0-footer_M1]; M1-macro-0_hex2 = run "M1-macro-0.hex2" M0 [M1-macro-0-0_M1 out]; - M1-macro-0-0_hex2 = run "M1-macro-0-0.hex2" catm [out "${m2libc}/x86/ELF-x86-debug.hex2" M1-macro-0_hex2]; + M1-macro-0-0_hex2 = run "M1-macro-0-0.hex2" catm [out "${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2" M1-macro-0_hex2]; M1-0 = run "M1-0" hex2-0 [M1-macro-0-0_hex2 out]; # This is the last stage where catm will need to be used and the last stage where @@ -172,13 +181,13 @@ rec { ####################################### hex2_linker-0_M1 = run "hex2_linker-0.M1" M2 [ - "--architecture" "x86" + "--architecture" m2libcArch "-f" "${m2libc}/sys/types.h" "-f" "${m2libc}/stddef.h" - "-f" "${m2libc}/x86/linux/unistd.c" - "-f" "${m2libc}/x86/linux/fcntl.c" + "-f" "${m2libc}/${m2libcArch}/linux/unistd.c" + "-f" "${m2libc}/${m2libcArch}/linux/fcntl.c" "-f" "${m2libc}/fcntl.c" - "-f" "${m2libc}/x86/linux/sys/stat.c" + "-f" "${m2libc}/${m2libcArch}/linux/sys/stat.c" "-f" "${m2libc}/stdlib.c" "-f" "${m2libc}/stdio.h" "-f" "${m2libc}/stdio.c" @@ -191,19 +200,19 @@ rec { "-o" out ]; - hex2_linker-0-footer_M1 = run "hex2_linker-0-footer.M1" blood-elf-0 ["-f" hex2_linker-0_M1 "--little-endian" "-o" out]; + hex2_linker-0-footer_M1 = run "hex2_linker-0-footer.M1" blood-elf-0 (bloodFlags ++ ["-f" hex2_linker-0_M1 endianFlag "-o" out]); hex2_linker-0_hex2 = run "hex2_linker-0.hex2" M1-0 [ - "--architecture" "x86" - "--little-endian" - "-f" "${m2libc}/x86/x86_defs.M1" - "-f" "${m2libc}/x86/libc-full.M1" + "--architecture" m2libcArch + endianFlag + "-f" "${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1" + "-f" "${m2libc}/${m2libcArch}/libc-full.M1" "-f" hex2_linker-0_M1 "-f" hex2_linker-0-footer_M1 "-o" out ]; - hex2_linker-0-0_hex2 = run "hex2_linker-0-0.hex2" catm [out "${m2libc}/x86/ELF-x86-debug.hex2" hex2_linker-0_hex2]; + hex2_linker-0-0_hex2 = run "hex2_linker-0-0.hex2" catm [out "${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2" hex2_linker-0_hex2]; hex2-1 = run "hex2-1" hex2-0 [hex2_linker-0-0_hex2 out]; @@ -215,12 +224,12 @@ rec { ################################### M1-macro-1_M1 = run "M1-macro-1.M1" M2 [ - "--architecture" "x86" + "--architecture" m2libcArch "-f" "${m2libc}/sys/types.h" "-f" "${m2libc}/stddef.h" - "-f" "${m2libc}/x86/linux/fcntl.c" + "-f" "${m2libc}/${m2libcArch}/linux/fcntl.c" "-f" "${m2libc}/fcntl.c" - "-f" "${m2libc}/x86/linux/unistd.c" + "-f" "${m2libc}/${m2libcArch}/linux/unistd.c" "-f" "${m2libc}/string.c" "-f" "${m2libc}/stdlib.c" "-f" "${m2libc}/stdio.h" @@ -232,23 +241,23 @@ rec { "-o" out ]; - M1-macro-1-footer_M1 = run "M1-macro-1-footer.M1" blood-elf-0 ["-f" M1-macro-1_M1 "--little-endian" "-o" out]; + M1-macro-1-footer_M1 = run "M1-macro-1-footer.M1" blood-elf-0 (bloodFlags ++ ["-f" M1-macro-1_M1 endianFlag "-o" out]); M1-macro-1_hex2 = run "M1-macro-1.hex2" M1-0 [ - "--architecture" "x86" - "--little-endian" - "-f" "${m2libc}/x86/x86_defs.M1" - "-f" "${m2libc}/x86/libc-full.M1" + "--architecture" m2libcArch + endianFlag + "-f" "${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1" + "-f" "${m2libc}/${m2libcArch}/libc-full.M1" "-f" M1-macro-1_M1 "-f" M1-macro-1-footer_M1 "-o" out ]; M1 = run "M1" hex2-1 [ - "--architecture" "x86" - "--little-endian" - "--base-address" "0x8048000" - "-f" "${m2libc}/x86/ELF-x86-debug.hex2" + "--architecture" m2libcArch + endianFlag + "--base-address" baseAddress + "-f" "${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2" "-f" M1-macro-1_hex2 "-o" out ]; @@ -258,13 +267,13 @@ rec { ###################################### hex2_linker-2_M1 = run "hex2_linker-2.M1" M2 [ - "--architecture" "x86" + "--architecture" m2libcArch "-f" "${m2libc}/sys/types.h" "-f" "${m2libc}/stddef.h" - "-f" "${m2libc}/x86/linux/unistd.c" - "-f" "${m2libc}/x86/linux/fcntl.c" + "-f" "${m2libc}/${m2libcArch}/linux/unistd.c" + "-f" "${m2libc}/${m2libcArch}/linux/fcntl.c" "-f" "${m2libc}/fcntl.c" - "-f" "${m2libc}/x86/linux/sys/stat.c" + "-f" "${m2libc}/${m2libcArch}/linux/sys/stat.c" "-f" "${m2libc}/stdlib.c" "-f" "${m2libc}/stdio.h" "-f" "${m2libc}/stdio.c" @@ -277,23 +286,23 @@ rec { "-o" out ]; - hex2_linker-2-footer_M1 = run "hex2_linker-2-footer.M1" blood-elf-0 ["-f" hex2_linker-2_M1 "--little-endian" "-o" out]; + hex2_linker-2-footer_M1 = run "hex2_linker-2-footer.M1" blood-elf-0 (bloodFlags ++ ["-f" hex2_linker-2_M1 endianFlag "-o" out]); hex2_linker-2_hex2 = run "hex2_linker-2.hex2" M1 [ - "--architecture" "x86" - "--little-endian" - "-f" "${m2libc}/x86/x86_defs.M1" - "-f" "${m2libc}/x86/libc-full.M1" + "--architecture" m2libcArch + endianFlag + "-f" "${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1" + "-f" "${m2libc}/${m2libcArch}/libc-full.M1" "-f" hex2_linker-2_M1 "-f" hex2_linker-2-footer_M1 "-o" out ]; hex2 = run "hex2" hex2-1 [ - "--architecture" "x86" - "--little-endian" - "--base-address" "0x8048000" - "-f" "${m2libc}/x86/ELF-x86-debug.hex2" + "--architecture" m2libcArch + endianFlag + "--base-address" baseAddress + "-f" "${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2" "-f" hex2_linker-2_hex2 "-o" out ]; @@ -303,12 +312,12 @@ rec { ###################################### kaem_M1 = run "kaem.M1" M2 [ - "--architecture" "x86" + "--architecture" m2libcArch "-f" "${m2libc}/sys/types.h" "-f" "${m2libc}/stddef.h" "-f" "${m2libc}/string.c" - "-f" "${m2libc}/x86/linux/unistd.c" - "-f" "${m2libc}/x86/linux/fcntl.c" + "-f" "${m2libc}/${m2libcArch}/linux/unistd.c" + "-f" "${m2libc}/${m2libcArch}/linux/fcntl.c" "-f" "${m2libc}/fcntl.c" "-f" "${m2libc}/stdlib.c" "-f" "${m2libc}/stdio.h" @@ -322,24 +331,24 @@ rec { "-o" out ]; - kaem-footer_M1 = run "kaem-footer.M1" blood-elf-0 ["-f" kaem_M1 "--little-endian" "-o" out]; + kaem-footer_M1 = run "kaem-footer.M1" blood-elf-0 (bloodFlags ++ ["-f" kaem_M1 endianFlag "-o" out]); kaem_hex2 = run "kaem.hex2" M1 [ - "--architecture" "x86" - "--little-endian" - "-f" "${m2libc}/x86/x86_defs.M1" - "-f" "${m2libc}/x86/libc-full.M1" + "--architecture" m2libcArch + endianFlag + "-f" "${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1" + "-f" "${m2libc}/${m2libcArch}/libc-full.M1" "-f" kaem_M1 "-f" kaem-footer_M1 "-o" out ]; kaem-unwrapped = run "kaem-unwrapped" hex2 [ - "--architecture" "x86" - "--little-endian" - "-f" "${m2libc}/x86/ELF-x86-debug.hex2" + "--architecture" m2libcArch + endianFlag + "-f" "${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2" "-f" kaem_hex2 - "--base-address" "0x8048000" + "--base-address" baseAddress "-o" out ]; } diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools-extra/build.kaem b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools-extra/build.kaem index e50fc1c68474..fb27eccab830 100644 --- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools-extra/build.kaem +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools-extra/build.kaem @@ -19,7 +19,7 @@ ## You should have received a copy of the GNU General Public License ## along with mescc-tools. If not, see <http://www.gnu.org/licenses/>. -alias CC="${mescc-tools}/bin/M2-Mesoplanet --operating-system ${OPERATING_SYSTEM} --architecture ${ARCH} -f" +alias CC="${mescc-tools}/bin/M2-Mesoplanet --operating-system ${m2libcOS} --architecture ${m2libcArch} -f" cd ${src}/mescc-tools-extra # Create output folder diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools-extra/default.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools-extra/default.nix index 425a10cfb35a..eee00491c446 100644 --- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools-extra/default.nix +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools-extra/default.nix @@ -4,9 +4,12 @@ , mescc-tools , src , version +, platforms +, m2libcArch +, m2libcOS }: derivationWithMeta { - inherit version src mescc-tools; + inherit version src mescc-tools m2libcArch m2libcOS; pname = "mescc-tools-extra"; builder = kaem-unwrapped; args = [ @@ -16,14 +19,11 @@ derivationWithMeta { ./build.kaem ]; - ARCH = "x86"; - OPERATING_SYSTEM = "linux"; - meta = with lib; { description = "Collection of tools written for use in bootstrapping"; homepage = "https://github.com/oriansj/mescc-tools-extra"; license = licenses.gpl3Plus; maintainers = teams.minimal-bootstrap.members; - platforms = [ "i686-linux" ]; + inherit platforms; }; } diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/build.kaem b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/build.kaem index 3a7ae25fbd82..128ff360fd2c 100644 --- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/build.kaem +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/build.kaem @@ -46,13 +46,13 @@ ${replace} \ # Phase-12 Build M2-Mesoplanet from M2-Planet # ############################################### -${M2} --architecture ${ARCH} \ +${M2} --architecture ${m2libcArch} \ -f ${m2libc}/sys/types.h \ -f ${m2libc}/stddef.h \ - -f ${m2libc}/${ARCH}/linux/fcntl.c \ + -f ${m2libc}/${m2libcArch}/linux/fcntl.c \ -f ${m2libc}/fcntl.c \ - -f ${m2libc}/${ARCH}/linux/unistd.c \ - -f ${m2libc}/${ARCH}/linux/sys/stat.c \ + -f ${m2libc}/${m2libcArch}/linux/unistd.c \ + -f ${m2libc}/${m2libcArch}/linux/sys/stat.c \ -f ${m2libc}/stdlib.c \ -f ${m2libc}/stdio.h \ -f ${m2libc}/stdio.c \ @@ -69,20 +69,20 @@ ${M2} --architecture ${ARCH} \ --debug \ -o ./M2-Mesoplanet-1.M1 -${blood-elf-0} ${ENDIAN_FLAG} ${BLOOD_FLAG} -f ./M2-Mesoplanet-1.M1 -o ./M2-Mesoplanet-1-footer.M1 +${blood-elf-0} ${endianFlag} ${bloodFlag} -f ./M2-Mesoplanet-1.M1 -o ./M2-Mesoplanet-1-footer.M1 -${M1} --architecture ${ARCH} \ - ${ENDIAN_FLAG} \ - -f ${m2libc}/${ARCH}/${ARCH}_defs.M1 \ - -f ${m2libc}/${ARCH}/libc-full.M1 \ +${M1} --architecture ${m2libcArch} \ + ${endianFlag} \ + -f ${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \ + -f ${m2libc}/${m2libcArch}/libc-full.M1 \ -f ./M2-Mesoplanet-1.M1 \ -f ./M2-Mesoplanet-1-footer.M1 \ -o ./M2-Mesoplanet-1.hex2 -${hex2} --architecture ${ARCH} \ - ${ENDIAN_FLAG} \ - --base-address ${BASE_ADDRESS} \ - -f ${m2libc}/${ARCH}/ELF-${ARCH}-debug.hex2 \ +${hex2} --architecture ${m2libcArch} \ + ${endianFlag} \ + --base-address ${baseAddress} \ + -f ${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \ -f ./M2-Mesoplanet-1.hex2 \ -o ${out}/bin/M2-Mesoplanet @@ -90,12 +90,12 @@ ${hex2} --architecture ${ARCH} \ # Phase-13 Build final blood-elf from C sources # ################################################# -${M2} --architecture ${ARCH} \ +${M2} --architecture ${m2libcArch} \ -f ${m2libc}/sys/types.h \ -f ${m2libc}/stddef.h \ - -f ${m2libc}/${ARCH}/linux/fcntl.c \ + -f ${m2libc}/${m2libcArch}/linux/fcntl.c \ -f ${m2libc}/fcntl.c \ - -f ${m2libc}/${ARCH}/linux/unistd.c \ + -f ${m2libc}/${m2libcArch}/linux/unistd.c \ -f ${m2libc}/stdlib.c \ -f ${m2libc}/stdio.h \ -f ${m2libc}/stdio.c \ @@ -105,19 +105,20 @@ ${M2} --architecture ${ARCH} \ --debug \ -o ./blood-elf-1.M1 -${blood-elf-0} ${BLOOD_FLAG} ${ENDIAN_FLAG} -f ./blood-elf-1.M1 -o ./blood-elf-1-footer.M1 -${M1} --architecture ${ARCH} \ - ${ENDIAN_FLAG} \ - -f ${m2libc}/${ARCH}/${ARCH}_defs.M1 \ - -f ${m2libc}/${ARCH}/libc-full.M1 \ +${blood-elf-0} ${endianFlag} ${bloodFlag} -f ./blood-elf-1.M1 -o ./blood-elf-1-footer.M1 + +${M1} --architecture ${m2libcArch} \ + ${endianFlag} \ + -f ${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \ + -f ${m2libc}/${m2libcArch}/libc-full.M1 \ -f ./blood-elf-1.M1 \ -f ./blood-elf-1-footer.M1 \ -o ./blood-elf-1.hex2 -${hex2} --architecture ${ARCH} \ - ${ENDIAN_FLAG} \ - --base-address ${BASE_ADDRESS} \ - -f ${m2libc}/${ARCH}/ELF-${ARCH}-debug.hex2 \ +${hex2} --architecture ${m2libcArch} \ + ${endianFlag} \ + --base-address ${baseAddress} \ + -f ${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \ -f ./blood-elf-1.hex2 \ -o ${out}/bin/blood-elf @@ -129,11 +130,11 @@ ${hex2} --architecture ${ARCH} \ # Phase-14 Build get_machine from C sources # ############################################# -${M2} --architecture ${ARCH} \ +${M2} --architecture ${m2libcArch} \ -f ${m2libc}/sys/types.h \ -f ${m2libc}/stddef.h \ - -f ${m2libc}/${ARCH}/linux/unistd.c \ - -f ${m2libc}/${ARCH}/linux/fcntl.c \ + -f ${m2libc}/${m2libcArch}/linux/unistd.c \ + -f ${m2libc}/${m2libcArch}/linux/fcntl.c \ -f ${m2libc}/fcntl.c \ -f ${m2libc}/stdlib.c \ -f ${m2libc}/stdio.h \ @@ -143,20 +144,20 @@ ${M2} --architecture ${ARCH} \ --debug \ -o get_machine.M1 -${out}/bin/blood-elf ${BLOOD_FLAG} ${ENDIAN_FLAG} -f ./get_machine.M1 -o ./get_machine-footer.M1 +${out}/bin/blood-elf ${endianFlag} ${bloodFlag} -f ./get_machine.M1 -o ./get_machine-footer.M1 -${M1} --architecture ${ARCH} \ - ${ENDIAN_FLAG} \ - -f ${m2libc}/${ARCH}/${ARCH}_defs.M1 \ - -f ${m2libc}/${ARCH}/libc-full.M1 \ +${M1} --architecture ${m2libcArch} \ + ${endianFlag} \ + -f ${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \ + -f ${m2libc}/${m2libcArch}/libc-full.M1 \ -f ./get_machine.M1 \ -f ./get_machine-footer.M1 \ -o ./get_machine.hex2 -${hex2} --architecture ${ARCH} \ - ${ENDIAN_FLAG} \ - --base-address ${BASE_ADDRESS} \ - -f ${m2libc}/${ARCH}/ELF-${ARCH}-debug.hex2 \ +${hex2} --architecture ${m2libcArch} \ + ${endianFlag} \ + --base-address ${baseAddress} \ + -f ${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \ -f ./get_machine.hex2 \ -o ${out}/bin/get_machine @@ -164,11 +165,11 @@ ${hex2} --architecture ${ARCH} \ # Phase-15 Build M2-Planet from M2-Planet # ############################################ -${M2} --architecture ${ARCH} \ +${M2} --architecture ${m2libcArch} \ -f ${m2libc}/sys/types.h \ -f ${m2libc}/stddef.h \ - -f ${m2libc}/${ARCH}/linux/unistd.c \ - -f ${m2libc}/${ARCH}/linux/fcntl.c \ + -f ${m2libc}/${m2libcArch}/linux/unistd.c \ + -f ${m2libc}/${m2libcArch}/linux/fcntl.c \ -f ${m2libc}/fcntl.c \ -f ${m2libc}/stdlib.c \ -f ${m2libc}/stdio.h \ @@ -185,20 +186,19 @@ ${M2} --architecture ${ARCH} \ --debug \ -o ./M2-1.M1 -${out}/bin/blood-elf ${ENDIAN_FLAG} ${BLOOD_FLAG} -f ./M2-1.M1 -o ./M2-1-footer.M1 +${out}/bin/blood-elf ${endianFlag} ${bloodFlag} -f ./M2-1.M1 -o ./M2-1-footer.M1 -${M1} --architecture ${ARCH} \ - ${ENDIAN_FLAG} \ - -f ${m2libc}/${ARCH}/${ARCH}_defs.M1 \ - -f ${m2libc}/${ARCH}/libc-full.M1 \ +${M1} --architecture ${m2libcArch} \ + ${endianFlag} \ + -f ${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \ + -f ${m2libc}/${m2libcArch}/libc-full.M1 \ -f ./M2-1.M1 \ -f ./M2-1-footer.M1 \ -o ./M2-1.hex2 -${hex2} --architecture ${ARCH} \ - ${ENDIAN_FLAG} \ - --base-address ${BASE_ADDRESS} \ - -f ${m2libc}/${ARCH}/ELF-${ARCH}-debug.hex2 \ +${hex2} --architecture ${m2libcArch} \ + ${endianFlag} \ + --base-address ${baseAddress} \ + -f ${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \ -f ./M2-1.hex2 \ -o ${out}/bin/M2-Planet - diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/default.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/default.nix index c4aca823203d..4a9c734981e2 100644 --- a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/default.nix +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/default.nix @@ -1,5 +1,6 @@ { lib , derivationWithMeta +, hostPlatform , kaem-unwrapped , M1 , M2 @@ -8,13 +9,14 @@ , m2libc , src , version +, platforms +, m2libcArch +, baseAddress }: let - ARCH = "x86"; - BLOOD_FLAG = " "; - BASE_ADDRESS = "0x8048000"; - ENDIAN_FLAG = "--little-endian"; + endianFlag = if hostPlatform.isLittleEndian then "--little-endian" else "--big-endian"; + bloodFlag = if hostPlatform.is64bit then "--64" else " "; # We need a few tools from mescc-tools-extra to assemble the output folder buildMesccToolsExtraUtil = name: @@ -26,13 +28,13 @@ let "--strict" "--file" (builtins.toFile "build-${name}.kaem" '' - ''${M2} --architecture ''${ARCH} \ + ''${M2} --architecture ${m2libcArch} \ -f ''${m2libc}/sys/types.h \ -f ''${m2libc}/stddef.h \ - -f ''${m2libc}/''${ARCH}/linux/fcntl.c \ + -f ''${m2libc}/${m2libcArch}/linux/fcntl.c \ -f ''${m2libc}/fcntl.c \ - -f ''${m2libc}/''${ARCH}/linux/unistd.c \ - -f ''${m2libc}/''${ARCH}/linux/sys/stat.c \ + -f ''${m2libc}/${m2libcArch}/linux/unistd.c \ + -f ''${m2libc}/${m2libcArch}/linux/sys/stat.c \ -f ''${m2libc}/stdlib.c \ -f ''${m2libc}/stdio.h \ -f ''${m2libc}/stdio.c \ @@ -42,25 +44,25 @@ let --debug \ -o ${name}.M1 - ''${blood-elf-0} ''${ENDIAN_FLAG} -f ${name}.M1 -o ${name}-footer.M1 + ''${blood-elf-0} ${endianFlag} ${bloodFlag} -f ${name}.M1 -o ${name}-footer.M1 - ''${M1} --architecture ''${ARCH} \ - ''${ENDIAN_FLAG} \ - -f ''${m2libc}/''${ARCH}/''${ARCH}_defs.M1 \ - -f ''${m2libc}/''${ARCH}/libc-full.M1 \ + ''${M1} --architecture ${m2libcArch} \ + ${endianFlag} \ + -f ''${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \ + -f ''${m2libc}/${m2libcArch}/libc-full.M1 \ -f ${name}.M1 \ -f ${name}-footer.M1 \ -o ${name}.hex2 - ''${hex2} --architecture ''${ARCH} \ - ''${ENDIAN_FLAG} \ - -f ''${m2libc}/''${ARCH}/ELF-''${ARCH}-debug.hex2 \ + ''${hex2} --architecture ${m2libcArch} \ + ${endianFlag} \ + -f ''${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \ -f ${name}.hex2 \ - --base-address ''${BASE_ADDRESS} \ + --base-address ${baseAddress} \ -o ''${out} '') ]; - inherit version M1 M2 blood-elf-0 hex2 m2libc src ARCH BLOOD_FLAG BASE_ADDRESS ENDIAN_FLAG; + inherit version M1 M2 blood-elf-0 hex2 m2libc src; }; mkdir = buildMesccToolsExtraUtil "mkdir"; cp = buildMesccToolsExtraUtil "cp"; @@ -76,13 +78,13 @@ derivationWithMeta { "--file" ./build.kaem ]; - inherit version M1 M2 blood-elf-0 hex2 mkdir cp chmod replace m2libc src ARCH BLOOD_FLAG BASE_ADDRESS ENDIAN_FLAG; + inherit version M1 M2 blood-elf-0 hex2 mkdir cp chmod replace m2libc src m2libcArch baseAddress bloodFlag endianFlag; meta = with lib; { description = "Collection of tools written for use in bootstrapping"; homepage = "https://github.com/oriansj/mescc-tools"; license = licenses.gpl3Plus; maintainers = teams.minimal-bootstrap.members; - platforms = [ "i686-linux" ]; + inherit platforms; }; } diff --git a/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/platforms.nix b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/platforms.nix new file mode 100644 index 000000000000..c68f7630f3db --- /dev/null +++ b/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/platforms.nix @@ -0,0 +1,29 @@ +# Platform specific constants +{ lib +, hostPlatform +}: + +rec { + # meta.platforms + platforms = [ + "i686-linux" + "x86_64-linux" + ]; + + # system arch as used within the stage0 project + stage0Arch = { + "i686-linux" = "x86"; + "x86_64-linux" = "AMD64"; + }.${hostPlatform.system} or (throw "Unsupported system: ${hostPlatform.system}"); + + # lower-case form is widely used by m2libc + m2libcArch = lib.toLower stage0Arch; + + # Passed to M2-Mesoplanet as --operating-system + m2libcOS = if hostPlatform.isLinux then "linux" else throw "Unsupported system: ${hostPlatform.system}"; + + baseAddress = { + "i686-linux" = "0x08048000"; + "x86_64-linux" = "0x00600000"; + }.${hostPlatform.system} or (throw "Unsupported system: ${hostPlatform.system}"); +} |