From b4a7a69d7edc3b8a7507088866fb987483c4b765 Mon Sep 17 00:00:00 2001 From: chrysn Date: Mon, 2 May 2022 20:20:18 +0200 Subject: [PATCH 1/4] c2rust: Use 0.16 released version and stable Rust Installation via rustup is left in place to make backporting to focal easy. (MSRV is 1.58 which is present in Ubuntu LTS starting with Jammy). --- c2rust-built/Dockerfile | 12 ++---------- c2rust-built/README.md | 8 +++----- c2rust-built/debian/changelog | 4 ++-- c2rust-built/debian/install | 2 -- c2rust-built/debian/rules | 4 +++- 5 files changed, 10 insertions(+), 20 deletions(-) delete mode 100644 c2rust-built/debian/install diff --git a/c2rust-built/Dockerfile b/c2rust-built/Dockerfile index 7b2f89ef..e57f8745 100644 --- a/c2rust-built/Dockerfile +++ b/c2rust-built/Dockerfile @@ -10,7 +10,6 @@ COPY debian/control /dpkg-build/debian/ # stay up there as it influences what will be installed. COPY debian/rules /dpkg-build/debian/ COPY debian/changelog /dpkg-build/debian/ -COPY debian/install /dpkg-build/debian/ # noninteractive for the tzinfo RUN \ @@ -25,7 +24,6 @@ RUN \ devscripts \ dpkg-dev \ equivs \ - git \ && \ mk-build-deps -i /dpkg-build/debian/control -t 'apt-get -y --no-install-recommends' && \ echo 'Clean up installation files' >&2 && \ @@ -34,20 +32,15 @@ RUN \ # # # Note that --profile minimal doesn't cut it # RUN \ - echo 'Install c2rust rust nightly' >&2 && \ - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly-2019-12-05 && \ + 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 # # -# # Pinned to 6674d785 because that is know to work with 2019-12-05; upgrading -# # this should be unproblematic, but will need the right nightly set. -# # # RUN \ mkdir -p /dpkg-build/debian && \ cd /dpkg-build && \ - git clone --recursive https://github.com/immunant/c2rust && \ - git -C c2rust reset --hard 6674d785 && \ # true # # # Build using Debian's mechanism; the actual build line is in ./debian/rules @@ -87,7 +80,6 @@ RUN \ devscripts \ dpkg-dev \ equivs \ - git \ c2rust-build-deps \ && \ echo 'Cleanup done' diff --git a/c2rust-built/README.md b/c2rust-built/README.md index b79ffff7..faa1f2f6 100644 --- a/c2rust-built/README.md +++ b/c2rust-built/README.md @@ -12,19 +12,17 @@ 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_0.0_amd64.deb` package can be copied and installed 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 the right Rust nightly version is present +as long as a recent Rust version is present and all the typical Debian tools are around, -c2rust can be checked out under this directory, -and `dpkg-buildpackage -b` will produce a usable package for the Debian (or derivative) installed on the system. +`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 -[branch this is built from (for-riot)]: https://github.com/chrysn-pull-requests/c2rust/tree/for-riot [difficult to get right]: https://github.com/RIOT-OS/riotdocker/pull/141 diff --git a/c2rust-built/debian/changelog b/c2rust-built/debian/changelog index a7bfa033..0561e495 100644 --- a/c2rust-built/debian/changelog +++ b/c2rust-built/debian/changelog @@ -1,5 +1,5 @@ -c2rust (0.0) UNRELEASED; urgency=medium +c2rust (0.16.0-0) UNRELEASED; urgency=medium * Initial package as part of the riotdocker builds. - -- Christian M. Amsüss Tue, 08 Mar 2022 16:22:14 +0100 + -- Christian M. Amsüss Fri, 13 May 2022 09:06:27 +0200 diff --git a/c2rust-built/debian/install b/c2rust-built/debian/install deleted file mode 100644 index b7144eca..00000000 --- a/c2rust-built/debian/install +++ /dev/null @@ -1,2 +0,0 @@ -c2rust/target/release/c2rust usr/bin -c2rust/target/release/c2rust-transpile usr/bin diff --git a/c2rust-built/debian/rules b/c2rust-built/debian/rules index dc6d0041..d1ad5831 100755 --- a/c2rust-built/debian/rules +++ b/c2rust-built/debian/rules @@ -5,4 +5,6 @@ dh $@ override_dh_auto_install: - cargo +"`cat c2rust/rust-toolchain`" build --manifest-path c2rust/c2rust/Cargo.toml --locked --release + cargo install --no-track --locked c2rust --version 0.16.0 --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/.??* From 221dd2978ab746a43aacd8bf9bcf0c7d717d9b05 Mon Sep 17 00:00:00 2001 From: chrysn Date: Fri, 13 May 2022 09:53:05 +0200 Subject: [PATCH 2/4] c2rust: Use a single stable output file name --- c2rust-built/Dockerfile | 6 ++++++ c2rust-built/README.md | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/c2rust-built/Dockerfile b/c2rust-built/Dockerfile index e57f8745..cce24880 100644 --- a/c2rust-built/Dockerfile +++ b/c2rust-built/Dockerfile @@ -68,6 +68,12 @@ 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 \ diff --git a/c2rust-built/README.md b/c2rust-built/README.md index faa1f2f6..40eb9f9f 100644 --- a/c2rust-built/README.md +++ b/c2rust-built/README.md @@ -12,7 +12,7 @@ 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. +* 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, From 4729ba83a8641144e3df890908087ec96582570f Mon Sep 17 00:00:00 2001 From: chrysn Date: Fri, 13 May 2022 10:35:02 +0200 Subject: [PATCH 3/4] riotbuild: Use constant C2Rust deb file name --- riotbuild/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riotbuild/Dockerfile b/riotbuild/Dockerfile index 0539e833..4f881a9b 100644 --- a/riotbuild/Dockerfile +++ b/riotbuild/Dockerfile @@ -34,7 +34,7 @@ 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_0.0_amd64.deb /pkgs +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 From 1287480b4fdfd300de42db76e25674bdf03a8565 Mon Sep 17 00:00:00 2001 From: chrysn Date: Fri, 13 May 2022 14:45:45 +0200 Subject: [PATCH 4/4] c2rust: Use patched version for RISC-V support --- c2rust-built/debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c2rust-built/debian/rules b/c2rust-built/debian/rules index d1ad5831..800ab62d 100755 --- a/c2rust-built/debian/rules +++ b/c2rust-built/debian/rules @@ -5,6 +5,6 @@ dh $@ override_dh_auto_install: - cargo install --no-track --locked c2rust --version 0.16.0 --root debian/c2rust/usr + 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/.??*