From a33453a02ddfd044cc8539b8162f0b638b4c57f2 Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Sun, 9 Jun 2019 02:46:14 +1200 Subject: [PATCH 1/5] [AVR][No Upstream] Use forked LLVM with non-upstreamed fixes --- .gitmodules | 4 ++-- src/llvm-project | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index dd74d49828f75..d814322b7726c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -42,8 +42,8 @@ url = https://github.com/rust-lang-nursery/edition-guide.git [submodule "src/llvm-project"] path = src/llvm-project - url = https://github.com/rust-lang/llvm-project.git - branch = rustc/8.0-2019-03-18 + url = https://github.com/avr-rust/llvm-project.git + branch = avr-rustc/8.0-2019-03-18.new [submodule "src/doc/embedded-book"] path = src/doc/embedded-book url = https://github.com/rust-embedded/book.git diff --git a/src/llvm-project b/src/llvm-project index 788592fb2740d..275759724b089 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 788592fb2740d560d0614a77035b319b9d07aa38 +Subproject commit 275759724b0891ccbe080977faef5789da4b99bb From d49d927ab8485636286cf422979325215ababeaa Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Sun, 9 Jun 2019 01:57:40 +1200 Subject: [PATCH 2/5] [AVR] Fix debug printing of function pointers This commit fixes debug printing of function pointers on AVR. AVR does not support `addrspacecast` instructions, and so this patch modifies libcore so that a `ptrtoint` IR instruction is used and the address space cast is avoided. --- src/libcore/ptr/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs index 80ac67d8eb57c..caef99ca47ad3 100644 --- a/src/libcore/ptr/mod.rs +++ b/src/libcore/ptr/mod.rs @@ -2631,14 +2631,14 @@ macro_rules! fnptr_impls_safety_abi { #[stable(feature = "fnptr_impls", since = "1.4.0")] impl fmt::Pointer for $FnTy { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Pointer::fmt(&(*self as *const ()), f) + fmt::Pointer::fmt(&(*self as usize as *const ()), f) } } #[stable(feature = "fnptr_impls", since = "1.4.0")] impl fmt::Debug for $FnTy { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Pointer::fmt(&(*self as *const ()), f) + fmt::Pointer::fmt(&(*self as usize as *const ()), f) } } } From 4fc79776b2f4958da31d1c97281f081374801435 Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Thu, 16 May 2019 21:38:45 +1200 Subject: [PATCH 3/5] Merge pull request #135 from ratkins/patch-1 Add extra steps for macOS, as noted in #131 --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 327af708dc040..1f1989ddb789d 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,15 @@ First make sure you've installed all dependencies for building, as specified in the main Rust repository [here](https://github.com/rust-lang/rust/#building-from-source). Then use the following commands: +### Notes for macOS + +The conventional install directory for macOS is `/usr/local/avr-rust` rather than the Linux default `/opt/avr-rust`, so before the steps below, you must: + +1. Edit `build/config.toml` to set `prefix = '/usr/local/avr-rust'`. +2. Ensure `/usr/local/avr-rust` exists and has the correct permissions: `sudo mkdir /usr/local/avr-rust && sudo chown $USER:admin /usr/local/avr-rust` + +Finally, `realpath` isn't included by default on macOS but is included in GNU Coreutils, so you can either `brew install coreutils` so the `rustup toolchain...` step works properly, or just use the explicit path (`rustup toolchain link avr-toolchain /usr/local/avr-rust`). + ``` bash # Grab the avr-rust sources git clone https://github.com/avr-rust/rust.git From d1deb9e7e465b17c67465716c81086b808596514 Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Thu, 16 May 2019 21:44:46 +1200 Subject: [PATCH 4/5] [README] Add --recursive flag to git clone example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f1989ddb789d..6bc2d96a8d01f 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Finally, `realpath` isn't included by default on macOS but is included in GNU Co ``` bash # Grab the avr-rust sources -git clone https://github.com/avr-rust/rust.git +git clone https://github.com/avr-rust/rust.git --recursive # Create a directory to place built files in mkdir build && cd build From c7eb39cf09daa3f83b16b7456be17428f03801fa Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Sun, 4 Nov 2018 17:21:45 +1300 Subject: [PATCH 5/5] Add Gitlab CI config and Dockerfile --- .dockerignore | 1 + .gitlab-ci.yml | 29 +++++++++++++++++++++++++++++ Dockerfile | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000..84c048a73cc2e --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +/build/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000..2ff7e7cf573b7 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,29 @@ + image: docker:stable + + variables: + # When using dind service we need to instruct docker, to talk with the + # daemon started inside of the service. The daemon is available with + # a network connection instead of the default /var/run/docker.sock socket. + # + # The 'docker' hostname is the alias of the service container as described at + # https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#accessing-the-services + # + # Note that if you're using Kubernetes executor, the variable should be set to + # tcp://localhost:2375 because of how Kubernetes executor connects services + # to the job container + DOCKER_HOST: tcp://docker:2375/ + # When using dind, it's wise to use the overlayfs driver for + # improved performance. + DOCKER_DRIVER: overlay2 + + services: + - docker:dind + + before_script: + - docker info + + build: + stage: build + script: + - docker build -t avr-rust . + - docker run avr-rust echo hello world diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000..f8b3a6d28d1fa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +FROM ubuntu:18.04 + +USER root + +# Install dependencies. +RUN apt-get update && apt-get install -y build-essential cmake curl git python + +# Create a regular user. +RUN useradd -m rustacean + +# Copy the code over, create an empty directory for builds. +ADD . /code +# RUN cd /code +RUN mkdir /build && cd /build + +# symlink Rust build directory to the /build volume +# RUN mkdir /build && ln -sf /build /code/build + +# Compile rust. +# RUN /code/x.py build + +# Generate Makefile using settings suitable for an experimental compiler +RUN /code/configure \ + --enable-debug \ + --disable-docs \ + --enable-llvm-assertions \ + --enable-debug-assertions \ + --enable-optimize \ + --enable-llvm-release-debuginfo \ + --experimental-targets=AVR + +RUN make +RUN make install + +# Drop down to the regular user +USER rustacean + +VOLUME /code +VOLUME /build