diff --git a/fs/Dockerfile b/fs/Dockerfile index 06f39b6e..ae3fb6b2 100644 --- a/fs/Dockerfile +++ b/fs/Dockerfile @@ -1,5 +1,5 @@ # Final image -FROM --platform=linux/riscv64 ubuntu:22.04 +FROM ubuntu:22.04 ARG TOOLS_DEB=machine-emulator-tools-v0.16.2.deb ADD ${TOOLS_DEB} /tmp/ RUN apt-get update && \ diff --git a/sys-utils/Makefile b/sys-utils/Makefile index 311fc3e6..aa0c1035 100644 --- a/sys-utils/Makefile +++ b/sys-utils/Makefile @@ -16,21 +16,13 @@ UTILITIES := hex xhalt yield rollup ioctl-echo-loop -UTILITIES_WITH_TOOLCHAIN := $(addsuffix -with-toolchain,$(UTILITIES)) all: $(UTILITIES) $(UTILITIES): @$(MAKE) -C $@ -with-toolchain: - @$(MAKE) $(UTILITIES_WITH_TOOLCHAIN) - -$(UTILITIES_WITH_TOOLCHAIN): - @$(MAKE) -C $@ with-toolchain - clean: @$(foreach utility,$(UTILITIES),$(MAKE) -C $(utility) clean;) - -.PHONY: all with-toolchain $(UTILITIES) $(UTILITIES_WITH_TOOLCHAIN) +.PHONY: all $(UTILITIES) diff --git a/sys-utils/hex/Makefile b/sys-utils/hex/Makefile index 6603d725..8158df9d 100644 --- a/sys-utils/hex/Makefile +++ b/sys-utils/hex/Makefile @@ -14,65 +14,18 @@ # limitations under the License. # -UNAME:=$(shell uname) +TOOLCHAIN_PREFIX ?= riscv64-linux-gnu- -TOOLCHAIN_IMAGE ?= cartesi/toolchain -TOOLCHAIN_TAG ?= 0.16.0 -RISCV_ARCH ?= rv64gc -RISCV_ABI ?= lp64d - -TOOLCHAIN_PREFIX ?= riscv64-cartesi-linux-gnu- - -RVCC = $(TOOLCHAIN_PREFIX)gcc -RVCXX = $(TOOLCHAIN_PREFIX)g++ -RVCOPY = $(TOOLCHAIN_PREFIX)objcopy -RVDUMP = $(TOOLCHAIN_PREFIX)objdump -STRIP = $(TOOLCHAIN_PREFIX)strip -RISCV_CFLAGS :=-march=$(RISCV_ARCH) -mabi=$(RISCV_ABI) - -CONTAINER_MAKE := /usr/bin/make -CONTAINER_BASE := /opt/cartesi/tools -KERNEL_HEADERS_PATH := /opt/riscv/usr/include +CXX = $(TOOLCHAIN_PREFIX)g++ +STRIP = $(TOOLCHAIN_PREFIX)strip +CXXFLAGS = -Wall -Wextra -pedantic -O2 -std=c++20 +LDFLAGS = all: hex -hex.with-toolchain with-toolchain: - $(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain" - -extra.ext2.with-toolchain: - $(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain" - hex: hex.cpp - $(RVCXX) -O2 -o hex hex.cpp - $(STRIP) hex - -extra.ext2: hex - mkdir -m 0755 ./extra - cp ./hex ./extra/hex - xgenext2fs -i 512 -b 8192 -d extra $(basename $@) - rm -rf ./extra - -toolchain-exec: - @docker run --hostname $@ --rm \ - -e USER=$$(id -u -n) \ - -e GROUP=$$(id -g -n) \ - -e UID=$$(id -u) \ - -e GID=$$(id -g) \ - -v `pwd`:$(CONTAINER_BASE) \ - -w $(CONTAINER_BASE) \ - $(TOOLCHAIN_IMAGE):$(TOOLCHAIN_TAG) $(CONTAINER_COMMAND) - -toolchain-env: - @docker run --hostname toolchain-env -it --rm \ - -e USER=$$(id -u -n) \ - -e GROUP=$$(id -g -n) \ - -e UID=$$(id -u) \ - -e GID=$$(id -g) \ - -v `pwd`:$(CONTAINER_BASE) \ - -w $(CONTAINER_BASE) \ - $(TOOLCHAIN_IMAGE):$(TOOLCHAIN_TAG) + $(CXX) $(CFLAGS) -o $@ $< $(LDFLAGS) + $(STRIP) $@ clean: - @rm -rf hex extra.ext2 extra - -.PHONY: toolchain-exec toolchain-env + @rm -rf hex diff --git a/sys-utils/hex/README.md b/sys-utils/hex/README.md deleted file mode 100644 index 318db161..00000000 --- a/sys-utils/hex/README.md +++ /dev/null @@ -1,41 +0,0 @@ -## hex encode/decode tool - -### Requirements - -- Docker >= 18.x -- GNU Make >= 3.81 - -### Building - -```bash -$ cd sys-utils/hex -$ make -``` - -#### Makefile targets - -The following options are available as `make` targets: - -- **all**: builds the RISC-V hex executable -- **extra.ext2**: builds the extra.ext2 filesystem image with the hex tool inside -- **toolchain-env**: runs the toolchain image with current user UID and GID -- **clean**: clean generated artifacts - -#### Makefile container options - -You can pass the following variables to the make target if you wish to use different docker image tags. - -- TOOLCHAIN\_IMAGE: toolchain image name -- TOOLCHAIN\_TAG: toolchain image tag - -``` -$ make TOOLCHAIN_TAG=mytag -``` - -It's useful when you want to use prebuilt images like `cartesi/toolchain:latest` - -#### Usage - -The purpose of the hex tool please see the emulator documentation. - -The purpose of the `extra.ext2` image is to help the development creating a filesystem that contains the hex tool so it can be used with the emulator. For instructions on how to do that, please see the emulator documentation. diff --git a/sys-utils/ioctl-echo-loop/Makefile b/sys-utils/ioctl-echo-loop/Makefile index 7f03a8ca..b093757f 100644 --- a/sys-utils/ioctl-echo-loop/Makefile +++ b/sys-utils/ioctl-echo-loop/Makefile @@ -14,67 +14,20 @@ # limitations under the License. # -UNAME:=$(shell uname) +TOOLCHAIN_PREFIX ?= riscv64-linux-gnu- +PKG_CONFIG_PATH = /usr/riscv64-linux-gnu/lib/pkgconfig +export PKG_CONFIG_PATH -TOOLCHAIN_IMAGE ?= cartesi/toolchain -TOOLCHAIN_TAG ?= 0.16.0 -RISCV_ARCH ?= rv64gc -RISCV_ABI ?= lp64d - -TOOLCHAIN_PREFIX ?= riscv64-cartesi-linux-gnu- - -RVCC = $(TOOLCHAIN_PREFIX)gcc -RVCXX = $(TOOLCHAIN_PREFIX)g++ -RVCOPY = $(TOOLCHAIN_PREFIX)objcopy -RVDUMP = $(TOOLCHAIN_PREFIX)objdump -STRIP = $(TOOLCHAIN_PREFIX)strip -CFLAGS +=-Wall -Wextra -pedantic -O2 `pkg-config --cflags libcmt` -LDLIBS += `pkg-config --libs libcmt` - -CONTAINER_MAKE := /usr/bin/make -CONTAINER_BASE := /opt/cartesi/tools -KERNEL_HEADERS_PATH := /opt/riscv/usr/include +CC = $(TOOLCHAIN_PREFIX)gcc +STRIP = $(TOOLCHAIN_PREFIX)strip +CFLAGS = -Wall -Wextra -pedantic -O2 `pkg-config --cflags libcmt` +LDFLAGS = `pkg-config --libs libcmt` all: ioctl-echo-loop -ioctl-echo-loop.with-toolchain with-toolchain: - $(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain" - -extra.ext2.with-toolchain: - $(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain" - -ioctl-echo-loop: export PKG_CONFIG_PATH ?= /usr/riscv64-linux-gnu/lib/pkgconfig ioctl-echo-loop: ioctl-echo-loop.c - $(RVCC) $(CFLAGS) -o ioctl-echo-loop ioctl-echo-loop.c $(LDLIBS) - $(STRIP) ioctl-echo-loop - -extra.ext2: ioctl-echo-loop - mkdir -m 0755 ./extra - cp ./ioctl-echo-loop ./extra/ioctl-echo-loop - xgenext2fs -i 512 -b 8192 -d extra $(basename $@) - rm -rf ./extra - -toolchain-exec: - @docker run --hostname $@ --rm \ - -e USER=$$(id -u -n) \ - -e GROUP=$$(id -g -n) \ - -e UID=$$(id -u) \ - -e GID=$$(id -g) \ - -v `pwd`:$(CONTAINER_BASE) \ - -w $(CONTAINER_BASE) \ - $(TOOLCHAIN_IMAGE):$(TOOLCHAIN_TAG) $(CONTAINER_COMMAND) - -toolchain-env: - @docker run --hostname toolchain-env -it --rm \ - -e USER=$$(id -u -n) \ - -e GROUP=$$(id -g -n) \ - -e UID=$$(id -u) \ - -e GID=$$(id -g) \ - -v `pwd`:$(CONTAINER_BASE) \ - -w $(CONTAINER_BASE) \ - $(TOOLCHAIN_IMAGE):$(TOOLCHAIN_TAG) + $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) + $(STRIP) $@ clean: - @rm -rf ioctl-echo-loop extra.ext2 extra - -.PHONY: toolchain-exec toolchain-env + @rm -f ioctl-echo-loop diff --git a/sys-utils/rollup/Makefile b/sys-utils/rollup/Makefile index bc9fe3f8..aa0f72e7 100644 --- a/sys-utils/rollup/Makefile +++ b/sys-utils/rollup/Makefile @@ -14,67 +14,20 @@ # limitations under the License. # -UNAME:=$(shell uname) +TOOLCHAIN_PREFIX ?= riscv64-linux-gnu- +PKG_CONFIG_PATH ?= /usr/riscv64-linux-gnu/lib/pkgconfig +export PKG_CONFIG_PATH -TOOLCHAIN_IMAGE ?= cartesi/toolchain -TOOLCHAIN_TAG ?= 0.16.0 -RISCV_ARCH ?= rv64gc -RISCV_ABI ?= lp64d - -TOOLCHAIN_PREFIX ?= riscv64-cartesi-linux-gnu- - -RVCC = $(TOOLCHAIN_PREFIX)gcc -RVCXX = $(TOOLCHAIN_PREFIX)g++ -RVCOPY = $(TOOLCHAIN_PREFIX)objcopy -RVDUMP = $(TOOLCHAIN_PREFIX)objdump -STRIP = $(TOOLCHAIN_PREFIX)strip -CXXFLAGS := -Wall -Wextra -pedantic -O2 -std=c++20 `pkg-config --cflags libcmt` -LDLIBS := `pkg-config --libs libcmt` - -CONTAINER_MAKE := /usr/bin/make -CONTAINER_BASE := /opt/cartesi/tools -KERNEL_HEADERS_PATH := /opt/riscv/usr/include +CXX = $(TOOLCHAIN_PREFIX)g++ +STRIP = $(TOOLCHAIN_PREFIX)strip +CXXFLAGS = -Wall -Wextra -pedantic -O2 -std=c++20 `pkg-config --cflags libcmt` +LDFLAGS = `pkg-config --libs libcmt` all: rollup -rollup.with-toolchain with-toolchain: - $(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain" - -extra.ext2.with-toolchain: - $(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain" - -rollup: export PKG_CONFIG_PATH ?= /usr/riscv64-linux-gnu/lib/pkgconfig rollup: rollup.cpp - $(RVCXX) $(CXXFLAGS) -O2 -o rollup rollup.cpp $(LDLIBS) - $(STRIP) rollup - -extra.ext2: rollup - mkdir -m 0755 ./extra - cp ./rollup ./extra/rollup - xgenext2fs -i 512 -b 8192 -d extra $(basename $@) - rm -rf ./extra - -toolchain-exec: - @docker run --hostname $@ --rm \ - -e USER=$$(id -u -n) \ - -e GROUP=$$(id -g -n) \ - -e UID=$$(id -u) \ - -e GID=$$(id -g) \ - -v `pwd`:$(CONTAINER_BASE) \ - -w $(CONTAINER_BASE) \ - $(TOOLCHAIN_IMAGE):$(TOOLCHAIN_TAG) $(CONTAINER_COMMAND) - -toolchain-env: - @docker run --hostname toolchain-env -it --rm \ - -e USER=$$(id -u -n) \ - -e GROUP=$$(id -g -n) \ - -e UID=$$(id -u) \ - -e GID=$$(id -g) \ - -v `pwd`:$(CONTAINER_BASE) \ - -w $(CONTAINER_BASE) \ - $(TOOLCHAIN_IMAGE):$(TOOLCHAIN_TAG) + $(CXX) $(CXXFLAGS) -o $@ $< $(LDFLAGS) + $(STRIP) $@ clean: - @rm -rf rollup extra.ext2 extra - -.PHONY: toolchain-exec toolchain-env + @rm -f rollup diff --git a/sys-utils/xhalt/.gitignore b/sys-utils/xhalt/.gitignore deleted file mode 100644 index 99593ec3..00000000 --- a/sys-utils/xhalt/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -extra/halt -halt diff --git a/sys-utils/xhalt/Makefile b/sys-utils/xhalt/Makefile index d416378d..81ba3889 100644 --- a/sys-utils/xhalt/Makefile +++ b/sys-utils/xhalt/Makefile @@ -14,65 +14,18 @@ # limitations under the License. # -UNAME:=$(shell uname) +TOOLCHAIN_PREFIX ?= riscv64-linux-gnu- -TOOLCHAIN_IMAGE ?= cartesi/toolchain -TOOLCHAIN_TAG ?= 0.16.0 -RISCV_ARCH ?= rv64gc -RISCV_ABI ?= lp64d - -TOOLCHAIN_PREFIX ?= riscv64-cartesi-linux-gnu- - -RVCC = $(TOOLCHAIN_PREFIX)gcc -RVCXX = $(TOOLCHAIN_PREFIX)g++ -RVCOPY = $(TOOLCHAIN_PREFIX)objcopy -RVDUMP = $(TOOLCHAIN_PREFIX)objdump -STRIP = $(TOOLCHAIN_PREFIX)strip -RISCV_CFLAGS :=-march=$(RISCV_ARCH) -mabi=$(RISCV_ABI) - -CONTAINER_MAKE := /usr/bin/make -CONTAINER_BASE := /opt/cartesi/tools -KERNEL_HEADERS_PATH := /opt/riscv/usr/include +CC = $(TOOLCHAIN_PREFIX)gcc +STRIP = $(TOOLCHAIN_PREFIX)strip +CFLAGS = -Wall -Wextra -pedantic -O2 +LDFLAGS = all: xhalt -xhalt.with-toolchain with-toolchain: - $(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain" - -extra.ext2.with-toolchain: - $(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain" - xhalt: xhalt.c - $(RVCC) -O2 -o xhalt xhalt.c - $(STRIP) xhalt - -extra.ext2: xhalt - mkdir -m 0755 ./extra - cp ./xhalt ./extra/xhalt - xgenext2fs -i 512 -b 8192 -d extra $(basename $@) - rm -rf ./extra - -toolchain-exec: - @docker run --hostname $@ --rm \ - -e USER=$$(id -u -n) \ - -e GROUP=$$(id -g -n) \ - -e UID=$$(id -u) \ - -e GID=$$(id -g) \ - -v `pwd`:$(CONTAINER_BASE) \ - -w $(CONTAINER_BASE) \ - $(TOOLCHAIN_IMAGE):$(TOOLCHAIN_TAG) $(CONTAINER_COMMAND) - -toolchain-env: - @docker run --hostname toolchain-env -it --rm \ - -e USER=$$(id -u -n) \ - -e GROUP=$$(id -g -n) \ - -e UID=$$(id -u) \ - -e GID=$$(id -g) \ - -v `pwd`:$(CONTAINER_BASE) \ - -w $(CONTAINER_BASE) \ - $(TOOLCHAIN_IMAGE):$(TOOLCHAIN_TAG) + $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) + $(STRIP) $@ clean: - @rm -rf xhalt extra.ext2 extra - -.PHONY: toolchain-exec toolchain-env + @rm -f xhalt diff --git a/sys-utils/xhalt/README.md b/sys-utils/xhalt/README.md deleted file mode 100644 index 16a33a71..00000000 --- a/sys-utils/xhalt/README.md +++ /dev/null @@ -1,41 +0,0 @@ -## HTIF xhalt tool - -### Requirements - -- Docker >= 18.x -- GNU Make >= 3.81 - -### Building - -```bash -$ cd linux/htif -$ make -``` - -#### Makefile targets - -The following options are available as `make` targets: - -- **all**: builds the RISC-V xhalt executable -- **extra.ext2**: builds the extra.ext2 filesystem image with the xhalt tool inside -- **toolchain-env**: runs the toolchain image with current user UID and GID -- **clean**: clean generated artifacts - -#### Makefile container options - -You can pass the following variables to the make target if you wish to use different docker image tags. - -- TOOLCHAIN\_IMAGE: toolchain image name -- TOOLCHAIN\_TAG: toolchain image tag - -``` -$ make TOOLCHAIN_TAG=mytag -``` - -It's useful when you want to use prebuilt images like `cartesi/toolchain:latest` - -#### Usage - -The purpose of the xhalt tool please see the emulator documentation. - -The purpose of the `extra.ext2` image is to help the development creating a filesystem that contains the xhalt tool so it can be used with the emulator. For instructions on how to do that, please see the emulator documentation. diff --git a/sys-utils/yield/.gitignore b/sys-utils/yield/.gitignore deleted file mode 100644 index 99593ec3..00000000 --- a/sys-utils/yield/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -extra/halt -halt diff --git a/sys-utils/yield/Makefile b/sys-utils/yield/Makefile index f9eb5f21..951f63b5 100644 --- a/sys-utils/yield/Makefile +++ b/sys-utils/yield/Makefile @@ -14,67 +14,20 @@ # limitations under the License. # -UNAME:=$(shell uname) +TOOLCHAIN_PREFIX ?= riscv64-linux-gnu- +PKG_CONFIG_PATH ?= /usr/riscv64-linux-gnu/lib/pkgconfig +export PKG_CONFIG_PATH -TOOLCHAIN_IMAGE ?= cartesi/toolchain -TOOLCHAIN_TAG ?= 0.16.0 -RISCV_ARCH ?= rv64gc -RISCV_ABI ?= lp64d - -TOOLCHAIN_PREFIX ?= riscv64-cartesi-linux-gnu- - -RVCC = $(TOOLCHAIN_PREFIX)gcc -RVCXX = $(TOOLCHAIN_PREFIX)g++ -RVCOPY = $(TOOLCHAIN_PREFIX)objcopy -RVDUMP = $(TOOLCHAIN_PREFIX)objdump -STRIP = $(TOOLCHAIN_PREFIX)strip -CFLAGS :=-Wall -Wextra -pedantic -O2 `pkg-config --cflags libcmt` -LDLIBS := `pkg-config --libs libcmt` - -CONTAINER_MAKE := /usr/bin/make -CONTAINER_BASE := /opt/cartesi/tools -KERNEL_HEADERS_PATH := /opt/riscv/usr/include +CC = $(TOOLCHAIN_PREFIX)gcc +STRIP = $(TOOLCHAIN_PREFIX)strip +CFLAGS = -Wall -Wextra -pedantic -O2 `pkg-config --cflags libcmt` +LDFLAGS = `pkg-config --libs libcmt` all: yield -yield.with-toolchain with-toolchain: - $(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain" - -extra.ext2.with-toolchain: - $(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain" - -yield: export PKG_CONFIG_PATH ?= /usr/riscv64-linux-gnu/lib/pkgconfig yield: yield.c - $(RVCC) $(CFLAGS) -O2 -o yield yield.c $(LDLIBS) - $(STRIP) yield - -extra.ext2: yield - mkdir -m 0755 ./extra - cp ./yield ./extra/yield - xgenext2fs -i 512 -b 8192 -d extra $(basename $@) - rm -rf ./extra - -toolchain-exec: - @docker run --hostname $@ --rm \ - -e USER=$$(id -u -n) \ - -e GROUP=$$(id -g -n) \ - -e UID=$$(id -u) \ - -e GID=$$(id -g) \ - -v `pwd`:$(CONTAINER_BASE) \ - -w $(CONTAINER_BASE) \ - $(TOOLCHAIN_IMAGE):$(TOOLCHAIN_TAG) $(CONTAINER_COMMAND) - -toolchain-env: - @docker run --hostname toolchain-env -it --rm \ - -e USER=$$(id -u -n) \ - -e GROUP=$$(id -g -n) \ - -e UID=$$(id -u) \ - -e GID=$$(id -g) \ - -v `pwd`:$(CONTAINER_BASE) \ - -w $(CONTAINER_BASE) \ - $(TOOLCHAIN_IMAGE):$(TOOLCHAIN_TAG) + $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) + $(STRIP) $@ clean: - @rm -rf yield extra.ext2 extra - -.PHONY: toolchain-exec toolchain-env + @rm -f yield diff --git a/sys-utils/yield/README.md b/sys-utils/yield/README.md deleted file mode 100644 index b656be16..00000000 --- a/sys-utils/yield/README.md +++ /dev/null @@ -1,41 +0,0 @@ -## HTIF yield tool - -### Requirements - -- Docker >= 18.x -- GNU Make >= 3.81 - -### Building - -```bash -$ cd linux/htif -$ make -``` - -#### Makefile targets - -The following options are available as `make` targets: - -- **all**: builds the RISC-V yield executable -- **extra.ext2**: builds the extra.ext2 filesystem image with the yield tool inside -- **toolchain-env**: runs the toolchain image with current user UID and GID -- **clean**: clean generated artifacts - -#### Makefile container options - -You can pass the following variables to the make target if you wish to use different docker image tags. - -- TOOLCHAIN\_IMAGE: toolchain image name -- TOOLCHAIN\_TAG: toolchain image tag - -``` -$ make TOOLCHAIN_TAG=mytag -``` - -It's useful when you want to use prebuilt images like `cartesi/toolchain:latest` - -#### Usage - -The purpose of the yield tool please see the emulator documentation. - -The purpose of the `extra.ext2` image is to help the development creating a filesystem that contains the yield tool so it can be used with the emulator. For instructions on how to do that, please see the emulator documentation.