diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7b536002..a9ba19fe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -129,6 +129,9 @@ jobs: - name: Rust build test run: | + # Some of the above are executed by root, creating ~/.cargo/git as + # that user, blocking downloads of own libraries. + rm -rf ~/.cargo # Once a release is out that can be built on stable, this switcharoo # can be removed -- until then, each release of RIOT is only # supported with the very Rust version that was the configured diff --git a/c2rust-built/Dockerfile b/c2rust-built/Dockerfile deleted file mode 100644 index cce24880..00000000 --- a/c2rust-built/Dockerfile +++ /dev/null @@ -1,95 +0,0 @@ -ARG DOCKER_REGISTRY="riot" -FROM ${DOCKER_REGISTRY}/riotdocker-base:latest - -COPY debian/control /dpkg-build/debian/ -# When playing with these, it is often practical to remove the comments on the -# `# true` / ... / `# RUN \` blocks (making the resulting images larger because -# of the intermediate files in the chain, but quick to rebuild on small -# changes) and moving the COPY lines down before the `dpkg-buildpackage` to not -# download and install all the dependencies again. The control file needs to -# stay up there as it influences what will be installed. -COPY debian/rules /dpkg-build/debian/ -COPY debian/changelog /dpkg-build/debian/ - -# noninteractive for the tzinfo -RUN \ - echo 'Update the package index files to latest available versions' >&2 && \ - apt-get update && \ - echo 'Install Build / install dependencies' >&2 && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - build-essential \ - ca-certificates \ - curl \ - debhelper \ - devscripts \ - dpkg-dev \ - equivs \ - && \ - mk-build-deps -i /dpkg-build/debian/control -t 'apt-get -y --no-install-recommends' && \ - echo 'Clean up installation files' >&2 && \ - apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ -# true -# -# # Note that --profile minimal doesn't cut it -# RUN \ - echo 'Install c2rust rust' >&2 && \ - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ -# true -# -# # Build using the provided Debian package sources -# # -# RUN \ - mkdir -p /dpkg-build/debian && \ - cd /dpkg-build && \ -# true -# -# # Build using Debian's mechanism; the actual build line is in ./debian/rules -# RUN \ - cd /dpkg-build && \ - PATH=~/.cargo/bin:$PATH dpkg-buildpackage -b && \ - cd / && \ -# true -# -# # Cleaning up as the relevant files were copied out, and the rest would just -# # make for a large image (which should only contain a minimal delta to the base -# # image in the end: the installed dependencies (libllvm), the installed -# # binaries and the debs that contain the stripped binaries and separate debug -# # symbols once more) -# RUN \ - rm -rf /dpkg-build && \ - rm -rf ~/.cargo && \ - rm -rf ~/.rustup && \ -# true -# -# # Besides copying the c2rust files to /usr/bin (which could also have been done -# # with --root /usr in the cargo line), this also ensures that the dependencies -# # stick around through the next step. -# RUN \ - apt-get -y install /c2rust_*.deb && \ -# true -# -# # Provide the package in an easy to match place independent of version and -# # architecture -# RUN \ - cp -l /c2rust_*.deb /c2rust.deb && \ -# true -# -# # TBD: Deduplicate list with above; feisty apt-get has no --mark-auto, -# # otherwise we could just --mark-auto above and autoremove --purge here. -# RUN \ - echo 'Removing packages only needed for building from container' >&2 && \ - apt-get purge -y --auto-remove \ - build-essential \ - ca-certificates \ - curl \ - debhelper \ - devscripts \ - dpkg-dev \ - equivs \ - c2rust-build-deps \ - && \ - echo 'Cleanup done' - -# Check they're still executable -RUN c2rust --version -RUN c2rust-transpile --version diff --git a/c2rust-built/README.md b/c2rust-built/README.md deleted file mode 100644 index 40eb9f9f..00000000 --- a/c2rust-built/README.md +++ /dev/null @@ -1,28 +0,0 @@ -This image contains built and usable versions of [c2rust]. -It is provided because upstream [does not release binaries] for c2rust and its companion tools. - -As this changes rarely, -and because on the github-workers infrastructure this is [difficult to get right], -this is not built and used through CI yet, -but manually built an published as: - - docker build . -t chrysn/c2rust-built - -The resulting image fulfils three roles: - -* c2rust can be executed in there immediately, or used as a base for other images. -* The binaries in `/usr/bin/c2rust` can be extracted and used in other images. -* The `./c2rust.deb` package can be copied and installed in other images. - Unlike copying the binaries over, this also ensures that the right LLVM dependencies are installed there. - -The parts that can be meaningfully performed by a Debian package are, -and the relevant files are located in the `debian/` directory. -As a side effect, -packages can be built using the same infrastructure even without a Docker container: -as long as a recent Rust version is present -and all the typical Debian tools are around, -`dpkg-buildpackage -b` will produce a usable package for the Debian (or derivative) installed on the system. - -[c2rust]: https://github.com/immunant/c2rust -[does not release binaries]: https://github.com/immunant/c2rust/issues/326 -[difficult to get right]: https://github.com/RIOT-OS/riotdocker/pull/141 diff --git a/c2rust-built/debian/changelog b/c2rust-built/debian/changelog deleted file mode 100644 index 0561e495..00000000 --- a/c2rust-built/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -c2rust (0.16.0-0) UNRELEASED; urgency=medium - - * Initial package as part of the riotdocker builds. - - -- Christian M. Amsüss Fri, 13 May 2022 09:06:27 +0200 diff --git a/c2rust-built/debian/control b/c2rust-built/debian/control deleted file mode 100644 index 322c4215..00000000 --- a/c2rust-built/debian/control +++ /dev/null @@ -1,18 +0,0 @@ -Source: c2rust -Section: devel -Priority: extra -Maintainer: Christian Amsüss -Build-Depends: cmake, - debhelper-compat (= 12), - libclang-dev, - libssl-dev, - llvm-dev, - pkg-config - -Package: c2rust -Architecture: any -Depends: ${misc:Depends}, ${shlibs:Depends} -Description: c2rust transpiler - A tool to translate C modules into semantically equivalent Rust code. - . - This package is built as part of RIOT's docker image creation. diff --git a/c2rust-built/debian/rules b/c2rust-built/debian/rules deleted file mode 100755 index 800ab62d..00000000 --- a/c2rust-built/debian/rules +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- - -%: - dh $@ - -override_dh_auto_install: - cargo install --no-track --locked c2rust --git https://github.com/chrysn-pull-requests/c2rust --branch for-riot-20220513 --root debian/c2rust/usr - # For unknown reasons --no-track doesn't keep cargo from installing .crates.toml and .crates2.json - rm -f debian/c2rust/usr/.??* diff --git a/riotbuild/Dockerfile b/riotbuild/Dockerfile index 746b735d..419d28f7 100644 --- a/riotbuild/Dockerfile +++ b/riotbuild/Dockerfile @@ -34,8 +34,6 @@ RUN mkdir /pkgs COPY files/libsocketcan-dev_0.0.11-1_i386.deb /pkgs/libsocketcan-dev_0.0.11-1_i386.deb COPY files/libsocketcan2_0.0.11-1_i386.deb /pkgs/libsocketcan2_0.0.11-1_i386.deb -COPY --from=chrysn/c2rust-built:for-riot /c2rust.deb /pkgs - # The following package groups will be installed: # - update the package index files to latest available version # - native platform development and build system functionality (about 400 MB installed) @@ -107,6 +105,11 @@ RUN \ llvm \ clang \ clang-tools \ + && echo 'Installing C2Rust (build) dependencies' >&2 && \ + apt-get -y --no-install-recommends install \ + libclang-dev \ + libssl-dev \ + llvm-dev \ && \ SYMS=$(find /usr/bin -type l) && \ for file in ${SYMS}; do \ @@ -309,6 +312,12 @@ RUN \ true; \ done" +RUN \ + echo 'Installing C2Rust' >&2 && \ + CARGO_HOME=/opt/rustup/.cargo cargo install --no-track --locked c2rust --git https://github.com/immunant/c2rust --rev ed56c794230bbf5a0e417941e4778316d31ab114 && \ + echo 'Cleaning up root-owned crates.io cache' >&2 && \ + rm -rf /opt/rustup/.cargo/{git,registry,.package-cache} + # get Dockerfile version from build args ARG RIOTBUILD_VERSION=unknown ENV RIOTBUILD_VERSION $RIOTBUILD_VERSION