From 334d1ab756615989042961c45cd92cff30f0be5e Mon Sep 17 00:00:00 2001 From: Andrea Cervesato Date: Fri, 26 Jan 2024 13:35:45 +0100 Subject: [PATCH] Remove unmaintained cross feature This documentation is not maintained and it required to be moved inside a separate project. We remove it and keep it out from the plain project for now. --- .gitignore | 4 --- README.md | 7 +--- build.zig | 84 ---------------------------------------------- cross/mk-initrd.sh | 30 ----------------- cross/run-qemu.sh | 20 ----------- cross/sysinfo.zig | 9 ----- docs/cross.md | 67 ------------------------------------ 7 files changed, 1 insertion(+), 220 deletions(-) delete mode 100644 build.zig delete mode 100755 cross/mk-initrd.sh delete mode 100755 cross/run-qemu.sh delete mode 100644 cross/sysinfo.zig delete mode 100644 docs/cross.md diff --git a/.gitignore b/.gitignore index 68c4b9a..1c741ab 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,3 @@ ltx libltx.so transport.in .venv -zig-cache -zig-out -cross/initrds -cross/kernels diff --git a/README.md b/README.md index 00b2f63..8bb5b6a 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,7 @@ LTX itself just needs Clang or GCC. The tests require Python 3.7+ with ## Build LTX can also be built as library in order to link its API inside a project and -to run a custom initialization process for specific systems. This is currently -used to [cross-compile kernel](/docs/cross.md) and to execute `ltx` as init -process. +to run a custom initialization process for specific systems, such as `initrd`. # libltx build make shared @@ -55,9 +53,6 @@ For testing: # execute LTX communication tests pytest -v tests/test_ltx.py -We can also [easily cross-compile LTX](/docs/cross.md) using `zig >= -0.11.0`. Beware that this is an **experimental feature**. - ## Run inside container We provide a `Dockerfile` that can be used to run LTX inside a container. diff --git a/build.zig b/build.zig deleted file mode 100644 index bafa0f3..0000000 --- a/build.zig +++ /dev/null @@ -1,84 +0,0 @@ -const std = @import("std"); - -// This is not an imperative build script -pub fn build(b: *std.Build) void { - const target = b.standardTargetOptions(.{}); - const optimize = b.standardOptimizeOption(.{}); - - const exe = b.addExecutable(.{ - .name = "ltx", - .link_libc = true, - .target = target, - .optimize = optimize, - }); - - exe.addIncludePath("msgpack"); - - const std_cflags = [_][]const u8{ - "-std=gnu18", - "-pedantic", - "-Wall", - "-W", - }; - - const dbg_cflags = [_][]const u8{ - "-D DEBUG", - "-g", - }; - - const cflags = if (optimize == .Debug) - &(std_cflags ++ dbg_cflags) - else - &std_cflags; - - exe.addCSourceFiles(&.{ - "ltx.c", - "msgpack/message.c", - "msgpack/unpack.c", - }, cflags); - - b.installArtifact(exe); - - const run_cmd = b.addRunArtifact(exe); - run_cmd.step.dependOn(b.getInstallStep()); - - if (b.args) |args| { - run_cmd.addArgs(args); - } - - const run_step = b.step("run", "Run the app"); - run_step.dependOn(&run_cmd.step); - - const sysinfo = b.addExecutable(.{ - .name = "sysinfo", - .target = target, - .optimize = optimize, - .root_source_file = .{ .path = "cross/sysinfo.zig" }, - }); - - b.installArtifact(sysinfo); - - const tests = .{ "message", "unpack", "utils" }; - const test_step = b.step("test", "Run the C unit tests"); - - inline for (tests) |name| { - const texe = b.addExecutable(.{ - .name = "test_" ++ name, - .link_libc = true, - .target = target, - .optimize = optimize, - }); - - texe.addIncludePath("msgpack"); - texe.addCSourceFiles(&.{ - "tests/test_" ++ name ++ ".c", - "msgpack/message.c", - "msgpack/unpack.c", - }, cflags); - - texe.linkSystemLibraryNeeded("check"); - - const test_cmd = b.addRunArtifact(texe); - test_step.dependOn(&test_cmd.step); - } -} diff --git a/cross/mk-initrd.sh b/cross/mk-initrd.sh deleted file mode 100755 index 1bf4638..0000000 --- a/cross/mk-initrd.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/sh -eu - -rootdir=$(realpath $1) - -if [ -z $rootdir ]; then - echo "Expected directory as first positional parameter" - exit 1 -fi - -if [ ! -d $rootdir/bin ]; then - echo "Expected bin directory in $rootdir" - exit 1 -else - tests=$(find $rootdir/bin -type f -executable) - if [ -z $tests ]; then - echo "Expected tests in $rootdir/bin" - exit 1 - fi -fi - -if [ ! -x $rootdir/init ]; then - echo "Expected init executable (LTX) in $rootdir" - exit 1 -fi - -bname=$(basename $rootdir) -pdir=$(pwd) -cd $rootdir -find . | cpio -v -H newc -o | gzip -n > ../$bname.cpio.gz -cd $pdir diff --git a/cross/run-qemu.sh b/cross/run-qemu.sh deleted file mode 100755 index 34bc61c..0000000 --- a/cross/run-qemu.sh +++ /dev/null @@ -1,20 +0,0 @@ -arch=$1 -initrd=$2 -kernel=$3 - -Q=qemu-system - -case $arch in - arm64|aarch64) \ - $Q-aarch64 -m 1G \ - -smp 2 \ - -display none \ - -kernel $kernel \ - -initrd $initrd \ - -machine virt -cpu cortex-a57 \ - -serial stdio \ - -append 'console=ttyAMA0 earlyprintk=ttyAMA0';; - *) echo "Don't recognise $arch" - exit 1;; -esac - diff --git a/cross/sysinfo.zig b/cross/sysinfo.zig deleted file mode 100644 index eca7317..0000000 --- a/cross/sysinfo.zig +++ /dev/null @@ -1,9 +0,0 @@ -const std = @import("std"); -const os = std.os; -const log = std.log; - -pub fn main() anyerror!void { - const name = os.uname(); - - log.info("uname: {s} {s} {s} {s} {s} {s}", name); -} diff --git a/docs/cross.md b/docs/cross.md deleted file mode 100644 index 04896f6..0000000 --- a/docs/cross.md +++ /dev/null @@ -1,67 +0,0 @@ -# Init and cross compile - -It is possible to cross compile LTX and run it as init. There is a -script to do this and create an initrd suitable for direct booting in -QEMU. - -We can also cross compile the kernel and some test executables. The -only dependencies are Zig (`>= 0.11.0`), Clang, `cpio`, `gzip` and -some standard utils like `sh`, `find` etc. - -We refer to the directory containing this README as `$ltx`. - -## Create the initrd tree - -For example, create a directory structure as follows - -```sh -$ cd $ltx/cross -$ mkdir initrds -$ mkdir initrds/arm64/bin -``` - -The `arm64` folder will be the root dir of your image. You can select -a different location if you wish. The only requirement is the `bin` -folder which must contain one or more test executables (added below). - -## Build the initrd - -First we need to cross compile LTX and a test executable. - -```sh -$ cd $ltx -$ zig build -Dtarget=aarch64-linux-musl -$ cp zig-out/bin/ltx cross/initrds/arm64/init -$ cp zig-out/bin/sysinfo cross-initrds/arm64/bin/sysinfo -``` - -The LTX executable must be renamed to `init` and be placed in the root -of our initrd image. The `sysinfo` program just prints some -information and can be used as a smoke test. - -Now we can build the image: - -```sh -$ cross/mk-initrd.sh cross/initrds/arm64 -``` - -This will output the image `cross/initrds/arm64.cpio.gz`. Any files -you add to `cross/initrds/arm64` will be available in your root file -system. - -## Making a Linux image - -The Linux kernel can be cross compiled with LLVM in the following way. - -```sh -$ cd $linux_git_checkout -$ make LLVM=1 ARCH=arm64 defconfig -$ make LLVM=1 ARCH=arm64 menuconfig # Optional -$ make LLVM=1 ARCH=arm64 -j$(nproc) -$ mkdir $ltx/cross/kernels -$ cp arch/arm64/boot/Image.gz $ltx/cross/kernels/arm64-Image.gz -``` - -We need the `Image.gz` file on ARM64, other architectures use -different names. For example on x86 it is `bzImage`. -